password
github
type
status
date
summary
tags
icon
Email
slug
category
GitHub 宣布推出开源本地 MCP 服务器,并与 Anthropic 合作用 Go 重写参考服务器,提升可用性和功能。包括自定义工具描述、代码扫描支持以及改善自然语言用户体验的新功能。
以下是 GitHub MCP Server 详细介绍
一、仓库简介
- 项目定位:GitHub MCP Server 是一个 Model Context Protocol (MCP) 服务器,旨在与 GitHub API 无缝集成。
- 核心功能:为开发者和工具提供高级自动化和交互能力。
二、使用场景
- 自动化 GitHub 工作流程和进程
- 从 GitHub 仓库提取和分析数据
- 构建与 GitHub 生态系统交互的 AI 驱动工具和应用
三、先决条件
- Docker 环境:若要在容器中运行服务器,需已安装 Docker。
- GitHub 个人访问令牌:创建并配置 GitHub Personal Access Token,根据需求启用相应的权限。
四、安装方法
(一)VS Code 安装
- 一键安装
- 在 README 顶部点击 one-click install 按钮进行快速安装。
- 手动配置
- 打开 VS Code 的 User Settings (JSON) 文件(可通过
Ctrl + Shift + P输入Preferences: Open User Settings (JSON)获取)。 - 将以下 JSON 块添加到文件中:
- 也可将此配置添加到工作区的
.vscode/mcp.json文件中,以便与他人共享配置。注意在.vscode/mcp.json文件中不需要mcp键。
(二)Claude Desktop 安装
(三)源码构建
- 前提条件:如果没有 Docker,可从
cmd/github-mcp-server目录使用 Go 构建二进制文件。
- 运行命令:使用
github-mcp-server stdio命令,并设置GITHUB_PERSONAL_ACCESS_TOKEN环境变量为您的令牌。
(四)GitHub Enterprise Server 支持
- 可通过
-gh-host标志或GH_HOST环境变量设置 GitHub Enterprise Server 主机名。
五、工具列表及参数说明
(一)工具和参数概览表:
类别 | 工具名称 | 描述 | 必需参数 | 可选参数 |
用户 | get_me | 获取已认证用户的详细信息 | 无 | 无 |
议题 | get_issue | 获取仓库中特定 Issue 的内容 | owner, repo, issue_number | 无 |
议题 | create_issue | 在 GitHub 仓库中创建一个新的 Issue | owner, repo, title | body, assignees, labels |
议题 | add_issue_comment | 向一个 Issue 添加评论 | owner, repo, issue_number, body | 无 |
议题 | list_issues | 列出和筛选仓库中的 Issues | owner, repo | state, labels, sort, direction, since, page, perPage |
议题 | update_issue | 更新 GitHub 仓库中已存在的 Issue | owner, repo, issue_number | title, body, state, labels, assignees, milestone |
议题 | search_issues | 搜索 Issues 和 Pull Requests | query | sort, order, page, per_page |
拉取请求 | get_pull_request | 获取特定 Pull Request 的详细信息 | owner, repo, pullNumber | 无 |
拉取请求 | list_pull_requests | 列出和筛选仓库中的 Pull Requests | owner, repo | state, sort, direction, perPage, page |
拉取请求 | merge_pull_request | 合并一个 Pull Request | owner, repo, pullNumber | commit_title, commit_message, merge_method |
拉取请求 | get_pull_request_files | 获取一个 Pull Request 中更改的文件列表 | owner, repo, pullNumber | 无 |
拉取请求 | get_pull_request_status | 获取一个 Pull Request 所有状态检查的合并状态 | owner, repo, pullNumber | 无 |
拉取请求 | update_pull_request_branch | 更新一个 Pull Request 的分支 | owner, repo, pullNumber | expectedHeadSha |
拉取请求 | get_pull_request_comments | 获取一个 Pull Request 的评审评论 | owner, repo, pullNumber | 无 |
拉取请求 | get_pull_request_reviews | 获取一个 Pull Request 的评审 | owner, repo, pullNumber | 无 |
拉取请求 | create_pull_request_review | 在一个 Pull Request 上创建一个评审 | owner, repo, pullNumber, event | body, commitId, comments |
拉取请求 | create_pull_request | 创建一个新的 Pull Request | owner, repo, title, head, base | body, draft, maintainer_can_modify |
仓库 | create_or_update_file | 在仓库中创建或更新单个文件 | owner, repo, path, message, content | branch, sha |
仓库 | push_files | 在一次提交中推送多个文件 | owner, repo, branch, files, message | 无 |
仓库 | search_repositories | 搜索 GitHub 仓库 | query | sort, order, page, perPage |
仓库 | create_repository | 创建一个新的 GitHub 仓库 | name | description, private, autoInit |
仓库 | get_file_contents | 获取文件或目录的内容 | owner, repo, path | ref |
仓库 | fork_repository | Fork 一个仓库 | owner, repo | organization |
仓库 | create_branch | 创建一个新的分支 | owner, repo, branch, sha | 无 |
仓库 | list_commits | 获取仓库中某个分支的提交记录 | owner, repo | sha, path, page, perPage |
搜索 | search_code | 在 GitHub 仓库中搜索代码 | query | sort, order, page, perPage |
搜索 | search_users | 搜索 GitHub 用户 | query | sort, order, page, perPage |
代码扫描 | get_code_scanning_alert | 获取一个代码扫描告警 | owner, repo, alertNumber | 无 |
代码扫描 | list_code_scanning_alerts | 列出一个仓库的代码扫描告警 | owner, repo | ref, state, severity |
功能详细描述
(一)用户相关
- get_me:获取已认证用户的详细信息,无需参数。
(二)Issues 相关
- get_issue
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)issue_number:议题编号(数字,必填)
- create_issue
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)title:议题标题(字符串,必填)body:议题正文内容(字符串,可选)assignees:分配给此议题的用户(字符串数组,可选)labels:应用于此议题的标签(字符串数组,可选)
- add_issue_comment
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)issue_number:议题编号(数字,必填)body:评论文本(字符串,必填)
- list_issues
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)state:按状态过滤(字符串,可选,可选值为 'open'、'closed'、'all')labels:按标签过滤(字符串数组,可选)sort:排序依据(字符串,可选,可选值为 'created'、'updated'、'comments')direction:排序方向(字符串,可选,可选值为 'asc'、'desc')since:按日期过滤(ISO 8601 时间戳,可选)page:页码(数字,可选)perPage:每页结果数(数字,可选)
- update_issue
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)issue_number:要更新的议题编号(数字,必填)title:新标题(字符串,可选)body:新描述(字符串,可选)state:新状态(字符串,可选,可选值为 'open' 或 'closed')labels:新标签(字符串数组,可选)assignees:新指派人(字符串数组,可选)milestone:新里程碑编号(数字,可选)
- search_issues
- 参数:
query:搜索查询(字符串,必填)sort:排序字段(字符串,可选)order:排序顺序(字符串,可选)page:页码(数字,可选)per_page:每页结果数(数字,可选)
(三)Pull Requests 相关
- get_pull_request
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)
- list_pull_requests
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)state:PR 状态(字符串,可选)sort:排序字段(字符串,可选)direction:排序方向(字符串,可选)perPage:每页结果数(数字,可选)page:页码(数字,可选)
- merge_pull_request
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)commit_title:合并提交的标题(字符串,可选)commit_message:合并提交的消息(字符串,可选)merge_method:合并方法(字符串,可选)
- get_pull_request_files
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)
- get_pull_request_status
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)
- update_pull_request_branch
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)expectedHeadSha:拉取请求 HEAD 引用的预期 SHA(字符串,可选)
- get_pull_request_comments
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)
- get_pull_request_reviews
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)
- create_pull_request_review
- 参数:
review_owner:仓库所有者(字符串,必填)review_repo:仓库名称(字符串,必填)pullNumber:拉取请求编号(数字,必填)body:审查评论文本(字符串,可选)event:审查操作(字符串,必填,可选值为 'APPROVE'、'REQUEST_CHANGES'、'COMMENT')commitId:要审查的提交的 SHA(字符串,可选)comments:行特定评论数组(数组,可选),每个对象包含path(字符串)、position(数字)、body(字符串)
- create_pull_request
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)title:PR 标题(字符串,必填)body:PR 描述(字符串,可选)head:包含更改的分支(字符串,必填)base:要合并到的分支(字符串,必填)draft:创建为草稿 PR(布尔值,可选)maintainer_can_modify:允许维护者编辑(布尔值,可选)
(四)Repositories 相关
- create_or_update_file
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)path:文件路径(字符串,必填)message:提交消息(字符串,必填)content:文件内容(字符串,必填)branch:分支名称(字符串,可选)sha:更新文件的文件 SHA(字符串,可选)
- push_files
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)branch:要推送到的分支(字符串,必填)files:要推送的文件数组,每个文件包含path(字符串)和content(字符串)(数组,必填)message:提交消息(字符串,必填)
- search_repositories
- 参数:
query:搜索查询(字符串,必填)sort:排序字段(字符串,可选)order:排序顺序(字符串,可选)page:页码(数字,可选)perPage:每页结果数(数字,可选)
- create_repository
- 参数:
name:仓库名称(字符串,必填)description:仓库描述(字符串,可选)private:仓库是否私有(布尔值,可选)autoInit:是否自动初始化带有 README(布尔值,可选)
- get_file_contents
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)path:文件或目录路径(字符串,必填)ref:Git 引用(字符串,可选)
- fork_repository
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)organization:目标组织名称(字符串,可选)
- create_branch
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)branch:新分支名称(字符串,必填)sha:创建分支的 SHA(字符串,必填)
- list_commits
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)sha:分支名称、标签或提交 SHA(字符串,可选)path:仅包含此文件路径的提交(字符串,可选)page:页码(数字,可选)perPage:每页结果数(数字,可选)
(五)Search 相关
- search_code
- 参数:
query:搜索查询(字符串,必填)sort:排序字段(字符串,可选)order:排序顺序(字符串,可选)page:页码(数字,可选)perPage:每页结果数(数字,可选)
- search_users
- 参数:
query:搜索查询(字符串,必填)sort:排序字段(字符串,可选)order:排序顺序(字符串,可选)page:页码(数字,可选)perPage:每页结果数(数字,可选)
(六)代码扫描相关
- get_code_scanning_alert
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)alertNumber:警报编号(数字,必填)
- list_code_scanning_alerts
- 参数:
owner:仓库所有者(字符串,必填)repo:仓库名称(字符串,必填)ref:Git 引用(字符串,可选)state:警报状态(字符串,可选)severity:警报严重性(字符串,可选)
六、资源
- Repository Content
- Get Repository Content:检索仓库在特定路径的内容。模板:
repo://{owner}/{repo}/contents{/path*},参数包括owner、repo、path。 - Get Repository Content for a Specific Branch:检索仓库在特定分支的特定路径的内容。模板:
repo://{owner}/{repo}/refs/heads/{branch}/contents{/path*},参数包括owner、repo、branch、path。 - Get Repository Content for a Specific Commit:检索仓库在特定提交的特定路径的内容。模板:
repo://{owner}/{repo}/sha/{sha}/contents{/path*},参数包括owner、repo、sha、path。 - Get Repository Content for a Specific Tag:检索仓库在特定标签的特定路径的内容。模板:
repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*},参数包括owner、repo、tag、path。 - Get Repository Content for a Specific Pull Request:检索仓库在特定拉取请求的特定路径的内容。模板:
repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*},参数包括owner、repo、prNumber、path。
七、License
该项目遵循 MIT 开源许可证,完整条款请参考 MIT 许可证。
- Author:二师兄
- URL:https://cloudesx.com/article/github-mcp-server
- Copyright:All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!






