> [!NOTE] > 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。 > [English](./README.en.md) · [原始项目](https://github.com/github/github-mcp-server) · [上游 README](https://github.com/github/github-mcp-server/blob/HEAD/README.md) > 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。 [](https://goreportcard.com/report/github.com/github/github-mcp-server) # GitHub MCP Server GitHub MCP Server 可将 AI 工具直接连接到 GitHub 平台。这使 AI 智能体(agent)、助手和聊天机器人能够读取仓库与代码文件、管理 issue 与 PR、分析代码并自动化工作流,全部通过自然语言交互完成。 ### 使用场景 - 仓库管理:浏览和查询代码、搜索文件、分析提交,并了解你有权访问的任意仓库的项目结构。 - Issue 与 PR 自动化:创建、更新和管理 issue 与 pull request。让 AI 协助分类 bug、审查代码变更并维护项目看板。 - CI/CD 与工作流智能:监控 GitHub Actions 工作流运行、分析构建失败、管理发布,并深入了解你的开发流水线。 - 代码分析:检查安全发现、审查 Dependabot 告警、理解代码模式,并全面了解你的代码库。 - 团队协作:访问讨论、管理通知、分析团队活动,并为团队简化流程。 面向希望将 AI 工具连接到 GitHub 上下文与能力的开发者,从简单的自然语言查询到复杂的多步骤智能体工作流均可支持。 --- ## 远程 GitHub MCP Server [](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=github&config=%7B%22type%22%3A%20%22http%22%2C%22url%22%3A%20%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D&quality=insiders) [](https://aka.ms/vs/mcp-install?%7B%22name%22%3A%22github%22%2C%22gallery%22%3Atrue%2C%22url%22%3A%22https%3A%2F%2Fapi.githubcopilot.com%2Fmcp%2F%22%7D) 远程 GitHub MCP Server 由 GitHub 托管,是上手运行最简便的方式。如果你的 MCP 宿主不支持远程 MCP 服务器,也不用担心!你可以改用[本地版 GitHub MCP Server](https://github.com/github/github-mcp-server?tab=readme-ov-file#local-github-mcp-server)。 ### 前置条件 1. 支持远程服务器的兼容 MCP 宿主(VS Code 1.101+、Claude Desktop、Cursor、Windsurf 等) 2. 已启用所有适用的[策略](https://github.com/github/github-mcp-server/blob/main/docs/policies-and-governance.md) ### 在 VS Code 中安装 如需快速安装,请使用上方的一键安装按钮。完成该流程后,切换 Agent 模式(位于 Copilot Chat 文本输入框旁),服务器即可启动。请确保你使用的是 [VS Code 1.101](https://code.visualstudio.com/updates/v1_101) 或[更高版本](https://code.visualstudio.com/updates),以支持远程 MCP 与 OAuth。 或者,若要手动配置 VS Code,请从下方示例中选择合适的 JSON 代码块,并将其添加到你的宿主配置中:
| 使用 OAuth | 使用 GitHub PAT |
|---|---|
| VS Code(1.101 或更高版本) | |
| ```json { "servers": { "github": { "type": "http", "url": "https://api.githubcopilot.com/mcp/" } } } ``` | ```json { "servers": { "github": { "type": "http", "url": "https://api.githubcopilot.com/mcp/", "headers": { "Authorization": "Bearer ${input:github_mcp_pat}" } } }, "inputs": [ { "type": "promptString", "id": "github_mcp_pat", "description": "GitHub Personal Access Token", "password": true } ] } ``` |
| 使用 URL 路径 | 使用 Header |
|---|---|
| ```json { "servers": { "github": { "type": "http", "url": "https://api.githubcopilot.com/mcp/insiders" } } } ``` | ```json { "servers": { "github": { "type": "http", "url": "https://api.githubcopilot.com/mcp/", "headers": { "X-MCP-Insiders": "true" } } } } ``` |







































