GitHub 官方 MCP
关于此服务器
GitHub 官方 MCP 服务器。让 AI 智能体直接管理仓库、Issue、Pull Request 与 GitHub Actions,支持远程托管与本地两种模式。
安装方式
claude mcp add --transport http github https://api.githubcopilot.com/mcp/官方 README 安装指南(英文原文)
Install in GitHub Copilot on VS Code
For quick installation, use one of the one-click install buttons above. Once you complete that flow, toggle Agent mode (located by the Copilot Chat text input) and the server will start.
More about using MCP server tools in VS Code's agent mode documentation.
Install in GitHub Copilot on other IDEs (JetBrains, Visual Studio, Eclipse, etc.)
Add one of the following JSON blocks to your IDE's MCP settings.
Log in with OAuth (no token to create or store). On github.com the official image already includes the app credentials, so you provide none yourself: it runs a browser-based login on first use and keeps the resulting token in memory only. In Docker this needs a fixed callback port published to loopback so the container's login callback is reachable:
{
"mcp": {
"servers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-p",
"127.0.0.1:8085:8085",
"-e",
"GITHUB_OAUTH_CALLBACK_PORT",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_OAUTH_CALLBACK_PORT": "8085"
}
}
}
}
}See Local Server OAuth Login for the native-binary flow (no fixed port needed), the headless/device-code fallback, GitHub Enterprise Server / ghe.com, and bringing your own OAuth or GitHub App.
For non-interactive stdio deployments, see GitHub App Authentication.
Or authenticate with a Personal Access Token. Set GITHUB_PERSONAL_ACCESS_TOKEN instead (it takes precedence over OAuth):
{
"mcp": {
"inputs": [
{
"type": "promptString",
"id": "github_token",
"description": "GitHub Personal Access Token",
"password": true
}
],
"servers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
}
}
}
}
}Optionally, you can add a similar example (i.e. without the mcp key) to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with other host applications that accept the same format.
<details>
<summary><b>Example JSON block without the MCP key included</b></summary>
<br>
{
"inputs": [
{
"type": "promptString",
"id": "github_token",
"description": "GitHub Personal Access Token",
"password": true
}
],
"servers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server"
],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}"
}
}
}
}</details>
Install in Other MCP Hosts
For other MCP host applications, please refer to our installation guides:
- Copilot CLI - Installation guide for GitHub Copilot CLI
- GitHub Copilot in other IDEs - Installation for JetBrains, Visual Studio, Eclipse, and Xcode with GitHub Copilot
- Claude Code & Claude Desktop - Installation guide for Claude Code and Claude Desktop
- Cursor - Installation guide for Cursor IDE
- Google Gemini CLI - Installation guide for Google Gemini CLI
- OpenCode - Installation guide for the OpenCode terminal agent
- Windsurf - Installation guide for Windsurf IDE
- Zed - Installation guide for Zed editor
For a complete overview of all installation options, see our Installation Guides Index.
> Note: Any host application that supports local MCP servers should be able to access the local GitHub MCP server. However, the specific configuration process, syntax and stability of the integration will vary by host application. While many may follow a similar format to the examples above, this is not guaranteed. Please refer to your host application's documentation for the correct MCP configuration syntax and setup process.
Build from source
If you don't have Docker, you can use go build to build the binary in the
cmd/github-mcp-server directory, and use the github-mcp-server stdio command with the GITHUB_PERSONAL_ACCESS_TOKEN environment variable set to your token. To specify the output location of the build, use the -o flag. You should configure your server to use the built executable as its command. For example:
{
"mcp": {
"servers": {
"github": {
"command": "/path/to/github-mcp-server",
"args": ["stdio"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
}CLI utilities
The github-mcp-server binary includes a few CLI subcommands that are helpful for debugging and exploring the server.
github-mcp-server tool-search "<query>"searches tools by name, description, and input parameter names. Use--max-resultsto return more matches.
Example (color output requires a TTY; use docker run -t (or -it) when running in Docker):
docker run -it --rm ghcr.io/github/github-mcp-server tool-search "issue" --max-results 5
github-mcp-server tool-search "issue" --max-results 5常见问题
GitHub MCP Server 能让 AI 做什么?
它是 GitHub 官方的 MCP 服务器,让 AI 智能体直接读写仓库、管理 Issue 和 Pull Request、查看 CI 运行结果、搜索代码,把整个 GitHub 工作流搬进对话里。
怎么安装 GitHub MCP Server 到 Claude Code?
推荐远程接入:claude mcp add --transport http github https://api.githubcopilot.com/mcp/,随后按提示完成 GitHub OAuth 授权即可,无需本地部署;也可以用 Docker 跑本地版。
GitHub MCP Server 免费吗?
服务器本身免费开源(MIT),托管端点对 GitHub 账号免费开放,权限跟随你的 GitHub 授权范围;操作私有仓库时注意为它配置最小必要权限。