github mcp服务器
使用自然语言与GitHub对话——由模型上下文协议提供支持
](https://www.npmjs.com/package/github-mcp-server) ](https://github.com/AtlasJedi/mcp_github_connector)  ](https://nodejs.org)  
______________________________________________________________________
github-mcp-server 是一个 模型上下文协议(MCP) 服务器,该服务器将GitHub API公开为一组AI调用工具。将其连接到Claude、Cursor、Windsurf或任何兼容MCP的客户端,并开始使用纯英文管理您的存储库、问题、提取请求、分支和文件-无需GitHub UI,无需手动API调用。
“列出我的未决问题”•“创建从功能分支到主分支的PR”•“过去5次提交中有什么变化?”
______________________________________________________________________
运作原理
You (natural language prompt)
│
▼
AI Client ───────────────────────────────────────── Claude Desktop
(MCP host) Cursor / Windsurf
│ VS Code + Copilot
│ MCP protocol over stdio
▼
github-mcp-server (this project, runs locally)
│
│ GitHub REST API (authenticated with your token)
▼
GitHub服务器作为 本地子流程 当你开始对话时,你的AI客户端会自动生成。它通过以下方式进行通信 标准 --没有端口,没有云服务,没有代理。您的GitHub个人访问令牌永远不会离开您的计算机。
______________________________________________________________________
特性
8个类别的26个工具:
- 仓库 --列出、检查、创建、分叉、删除
- 问题 --列表、阅读、创建、更新、评论
- 拉取请求 --列出、检查、打开、合并
- 文件和内容 --读取文件、列出目录、使用提交进行写入和删除
- 分支 --列出、检查、创建、删除
- 提交 --浏览历史记录,检查差异和统计数据
- 搜索 --具有完整GitHub搜索语法的存储库、代码、问题和PR
- 用户 --您的个人资料或任何公共用户
______________________________________________________________________
快速开始
1.获取GitHub个人访问令牌
首选 **** 并生成具有所需作用域的经典令牌或细粒度令牌。
| 范围 | 需要 |
|---|---|
repo | 私有存储库、文件、分支、PR |
public_repo | 仅限公共存储库 |
read:user | 用户配置文件查找 |
2.配置您的AI客户端
克劳德桌面版 --编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "github-mcp-server"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}光标/风帆 --编辑 .cursor/mcp.json 或 .windsurf/mcp.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "github-mcp-server"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}VS代码(GitHub副本) --添加到您的 settings.json:
{
"mcp": {
"servers": {
"github": {
"type": "stdio",
"command": "npx",
"args": ["-y", "github-mcp-server"],
"env": {
"GITHUB_TOKEN": "ghp_your_token_here"
}
}
}
}
}3.重启你的AI客户端——就是这样
服务器根据需要自动启动。没有守护进程,没有后台进程。
______________________________________________________________________
安装
通过npx实现零安装 _(推荐)_
无需全局安装。您的客户端配置处理此问题:
GITHUB_TOKEN=ghp_... npx github-mcp-server通过npm进行全局安装
npm install -g github-mcp-server
GITHUB_TOKEN=ghp_... github-mcp-server来源
git clone https://github.com/AtlasJedi/mcp_github_connector
cd github-mcp-server
npm install
npm run build
GITHUB_TOKEN=ghp_... npm start______________________________________________________________________
可用工具
仓库
| 工具 | 说明 |
|---|---|
list_repos | 为自己或其他用户列出存储库 |
get_repo | 检查存储库——星号、语言、主题、URL |
create_repo | 创建新的公共或私有存储库 |
fork_repo | 将任何存储库分叉到您的帐户或组织 |
delete_repo | 永久删除存储库 |
问题
| 工具 | 说明 |
|---|---|
list_issues | 使用标签和状态过滤器列出打开/关闭的问题 |
get_issue | 阅读完整的问题正文和元数据 |
create_issue | 打开一个包含标签和指定人员的新问题 |
update_issue | 编辑标题、正文、州、标签或受让人 |
add_issue_comment | 对任何问题或公关发表评论 |
拉取请求
| 工具 | 说明 |
|---|---|
list_pull_requests | 列出打开、关闭或所有PR |
get_pull_request | 读取PR正文、差异统计数据和合并状态 |
create_pull_request | 从一个分支机构打开PR到另一个分支 |
merge_pull_request | 通过合并提交、挤压或重基进行合并 |
文件和内容
| 工具 | 说明 |
|---|---|
get_file_contents | 在任何引用处读取文件或列出目录 |
create_or_update_file | 写入文件——自动创建提交 |
delete_file | 删除文件--自动创建提交 |
分支
| 工具 | 说明 |
|---|---|
list_branches | 列出所有分支 |
get_branch | 检查分支及其最新提交 |
create_branch | 任何分支机构或SHA的分支机构 |
delete_branch | 删除分支 |
提交
| 工具 | 说明 |
|---|---|
list_commits | 使用可选路径过滤器浏览提交历史记录 |
get_commit | 查看提交的消息、作者和文件差异 |
搜索
| 工具 | 说明 |
|---|---|
search_repositories | 使用完整的GitHub搜索语法搜索仓库 |
search_code | 在所有公共存储库中搜索代码 |
search_issues | 在GitHub上搜索问题和PR |
用户
| 工具 | 说明 |
|---|---|
get_authenticated_user | 您自己的GitHub个人资料 |
get_user | 任何用户的公开资料 |
______________________________________________________________________
示例提示
连接后,在您的AI客户端中尝试以下操作:
What are my most recently updated repositories?Create an issue in myorg/myrepo titled "Fix the login timeout" with the label "bug"Show me all open PRs in facebook/reactCreate a pull request from feature/new-auth to main — write a description based on the branch nameWhat files changed in the last commit on the main branch of myorg/myrepo?Search for TypeScript MCP server repositories sorted by starsCreate a new file at docs/guide.md in myrepo with the content "# Guide\n\nWelcome."______________________________________________________________________
安全
- 您的令牌通过环境变量传递,除了GitHub API之外,从不在任何地方记录或传输。
- 当您的AI客户端会话结束时,服务器进程退出。
- 使用具有工作流所需最小范围的细粒度令牌。
______________________________________________________________________
贡献
欢迎发布问题和PR。
git clone https://github.com/AtlasJedi/mcp_github_connector
cd github-mcp-server
npm install
npm run dev # runs directly with tsx, no build step needed______________________________________________________________________
许可证
麻省理工学院©2025
