GitHub MCP Server (Custom)
GitHub MCP Server(自定义)
一个自定义的 Model Context Protocol (MCP) 服务器,为 AI 代理提供对 GitHub 的完整 CRUD 访问:仓库、问题、拉取请求、分支、评论、审查和合并。使用官方 Python mcp SDK(FastMCP)和通过 httpx 的 GitHub REST API 构建。
共 23 个工具 — 完整列表见 server.py。亮点:
领域 | 工具 |
仓库 |
|
问题 |
|
分支 |
|
拉取请求 |
|
审查 |
|
提交 |
|
设置
安装依赖
pip install -r requirements.txt创建 GitHub 令牌
前往 https://github.com/settings/tokens 并创建以下任一类型:
一个具有
repo范围的经典 PAT,或一个细粒度 PAT,将
Contents、Issues、Pull requests和Metadata设置为读取和写入,范围限定为你希望代理访问的仓库。
将令牌设置为环境变量
export GITHUB_TOKEN=ghp_your_token_here独立运行(可选健全性检查)
python server.py它将等待 MCP 客户端通过 stdio 连接——这是预期的,它不是 Web 服务器。
Related MCP server: github-mcp
将其连接到 Claude Desktop
将此添加到你的 claude_desktop_config.json(Windows 上为 %APPDATA%\Claude\claude_desktop_config.json,macOS 上为 ~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"github": {
"command": "python",
"args": ["/absolute/path/to/server.py"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}重启 Claude Desktop,GitHub 工具将出现在工具选择器中。
将其连接到你自己的代理管道(例如 Jira → GitHub → Teams 项目)
由于这是一个标准的 MCP stdio 服务器,任何兼容 MCP 的客户端或 SDK 都可以将其作为子进程启动,并通过 stdin/stdout 与之通信——包括使用 MCP C# SDK 的 .NET 主机,或者如果你的编排器是多语言的,可以使用 Python/TypeScript SDK。将客户端指向:
command: python
args: ["/absolute/path/to/server.py"]
env: { "GITHUB_TOKEN": "<token>" }扩展它
要添加新工具,只需向 server.py 添加一个新的 @mcp.tool() 装饰函数,该函数调用 _request(method, path, ...) 来访问 GitHub REST API。文档字符串将成为显示给模型的工具描述,类型提示将成为输入模式——因此请确保两者准确。
注意事项
所有写操作(
create_*、update_*、delete_*、merge_*)都会在 GitHub 上产生真实更改——没有干运行模式。建议先在临时仓库上进行测试,尤其是merge_pull_request和delete_branch。速率限制遵循 GitHub 的标准 REST API 限制(截至撰写本文时,经过身份验证的请求为每小时 5,000 次)——服务器不进行自己的节流。
来自 GitHub 的错误(身份验证失败、404、合并冲突等)会以
RuntimeError的形式抛出,并包含 API 的响应正文,以便调用代理获得可读的消息来做出反应。
This server cannot be deployed
Maintenance
Related MCP Connectors
Access the GitHub API, enabling file operations, repository management, search functionality, and…
Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.
Read and write KukGit repositories, files, issues and pull requests from an AI assistant.
Git-backed platform for skills, tools, and context for AI agents
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceEnables LLMs to interact with GitHub repositories, issues, pull requests, and workflows through the Model Context Protocol. It provides a comprehensive set of tools for repository management, issue tracking, code search, and CI/CD automation.-
- AlicenseCqualityDmaintenanceEnables AI assistants to directly operate GitHub repositories, such as listing issues, through the Model Context Protocol.2140 npm2Apache 2.0

Tiger GitHub MCP Serverofficial
AlicenseNot gradedqualityCmaintenanceEnables LLMs to interact with GitHub via the Model Context Protocol, providing tools for repository management and other GitHub operations.31Apache 2.0- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with GitHub repositories, issues, pull requests, and content via the Model Context Protocol.1MIT