GitHub API 的 MCP 服务器,支持文件操作、仓库管理、搜索功能等。
create_or_update_file
owner(字符串):仓库所有者(用户名或组织)repo(字符串):仓库名称path(字符串):创建或更新文件的路径content(字符串):文件内容message(字符串):提交信息branch(字符串):要创建或更新文件的分支sha(可选字符串):被替换文件的 SHA(用于更新)push_files
owner(字符串):仓库所有者repo(字符串):仓库名称branch(字符串):要推送的分支files(数组):要推送的文件,每个文件包含 path 和 contentmessage(字符串):提交信息search_repositories
query(字符串):搜索查询page(可选数字):分页的页面编号perPage(可选数字):每页结果数(最大 100)create_repository
name(字符串):仓库名称description(可选字符串):仓库描述private(可选布尔值):是否为私有仓库autoInit(可选布尔值):初始化时包含 READMEget_file_contents
owner(字符串):仓库所有者repo(字符串):仓库名称path(字符串):文件/目录路径branch(可选字符串):获取内容的分支create_issue
owner(字符串):仓库所有者repo(字符串):仓库名称title(字符串):问题标题body(可选字符串):问题描述assignees(可选字符串数组):分配给的用户名labels(可选字符串数组):添加的标签milestone(可选数字):里程碑编号create_pull_request
owner(字符串):仓库所有者repo(字符串):仓库名称title(字符串):拉取请求标题body(可选字符串):拉取请求描述head(字符串):包含更改的分支base(字符串):要合并到的分支draft(可选布尔值):作为草稿拉取请求创建maintainer_can_modify(可选布尔值):允许维护者编辑fork_repository
owner(字符串):仓库所有者repo(字符串):仓库名称organization(可选字符串):分叉到的组织create_branch
owner(字符串):仓库所有者repo(字符串):仓库名称branch(字符串):新分支名称from_branch(可选字符串):源分支(默认为仓库默认分支)list_issues
owner(字符串):仓库所有者repo(字符串):仓库名称state(可选字符串):按状态过滤('open', 'closed', 'all')labels(可选字符串数组):按标签过滤sort(可选字符串):排序字段('created', 'updated', 'comments')direction(可选字符串):排序方向('asc', 'desc')since(可选字符串):按日期过滤(ISO 8601 时间戳)page(可选数字):页面编号per_page(可选数字):每页结果数update_issue
owner(字符串):仓库所有者repo(字符串):仓库名称issue_number(数字):要更新的问题编号title(可选字符串):新标题body(可选字符串):新描述state(可选字符串):新状态('open' 或 'closed')labels(可选字符串数组):新标签assignees(可选字符串数组):新分配人milestone(可选数字):新里程碑编号add_issue_comment
owner(字符串):仓库所有者repo(字符串):仓库名称issue_number(数字):要评论的问题编号body(字符串):评论文本search_code
q(字符串):使用 GitHub 代码搜索语法的搜索查询sort(可选字符串):排序字段(仅 'indexed')order(可选字符串):排序顺序('asc' 或 'desc')per_page(可选数字):每页结果数(最大 100)page(可选数字):页面编号search_issues
q(字符串):使用 GitHub 问题搜索语法的搜索查询sort(可选字符串):排序字段(comments, reactions, created 等)order(可选字符串):排序顺序('asc' 或 'desc')per_page(可选数字):每页结果数(最大 100)page(可选数字):页面编号search_users
q(字符串):使用 GitHub 用户搜索语法的搜索查询sort(可选字符串):排序字段(followers, repositories, joined)order(可选字符串):排序顺序('asc' 或 'desc')per_page(可选数字):每页结果数(最大 100)page(可选数字):页面编号list_commits
owner(字符串):仓库所有者repo(字符串):仓库名称page(可选字符串):页面编号per_page(可选字符串):每页记录数sha(可选字符串):分支名称get_issueowner(字符串):仓库所有者repo(字符串):仓库名称issue_number(数字):要检索的问题编号get_pull_requestowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号list_pull_requestsowner(字符串):仓库所有者repo(字符串):仓库名称state(可选字符串):按状态过滤('open', 'closed', 'all')head(可选字符串):按头用户/组织和分支过滤base(可选字符串):按基础分支过滤sort(可选字符串):排序字段('created', 'updated', 'popularity', 'long-running')direction(可选字符串):排序方向('asc', 'desc')per_page(可选数字):每页结果数(最大 100)page(可选数字):页面编号create_pull_request_reviewowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号body(字符串):审核评论文本event(字符串):审核动作('APPROVE', 'REQUEST_CHANGES', 'COMMENT')commit_id(可选字符串):要审核的提交的 SHAcomments(可选数组):行特定评论,每个评论包含:
path(字符串):文件路径position(数字):差异中的行位置body(字符串):评论文本merge_pull_requestowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号commit_title(可选字符串):合并提交的标题commit_message(可选字符串):合并提交的额外细节merge_method(可选字符串):合并方法('merge', 'squash', 'rebase')get_pull_request_filesowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号get_pull_request_statusowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号update_pull_request_branchowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号expected_head_sha(可选字符串):拉取请求 HEAD 引用的预期 SHAget_pull_request_commentsowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号get_pull_request_reviewsowner(字符串):仓库所有者repo(字符串):仓库名称pull_number(数字):拉取请求编号language:javascript:按编程语言搜索repo:owner/name:在特定仓库中搜索path:app/src:在特定路径中搜索extension:js:按文件扩展名搜索q: "import express" language:typescript path:src/is:issue 或 is:pr:按类型过滤is:open 或 is:closed:按状态过滤label:bug:按标签搜索author:username:按作者搜索q: "memory leak" is:issue is:open label:bugtype:user 或 type:org:按账户类型过滤followers:>1000:按关注者数量过滤location:London:按地点搜索q: "fullstack developer" location:London followers:>100关于详细的搜索语法,请参阅 GitHub 的搜索文档。
创建一个 GitHub 个人访问令牌,具有适当的权限:
repo 范围的令牌(“完全控制私有仓库”)
public_repo 范围要在 Claude Desktop 中使用此工具,请在您的 claude_desktop_config.json 中添加以下内容:
{
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_TOKEN",
"mcp/github"
],
"env": {
"GITHUB_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
{
"mcpServers": {
"github": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-github"
],
"env": {
"GITHUB_TOKEN": "<YOUR_TOKEN>"
}
}
}
}
Docker 构建:
docker build -t mcp/github -f src/github/Dockerfile .
此 MCP 服务器根据 MIT 许可证发布。这意味着您可以自由地使用、修改和分发该软件,但需遵守 MIT 许可证的条款和条件。更多详情,请参阅项目存储库中的 LICENSE 文件。