GitHub CLI MCP服务器
通过GithubCLI的MCP服务器允许您访问私有仓库
GitHub CLI MCP 服务器使用指南
快速开始
安装前提
-
安装 GitHub CLI
# MacOS brew install gh # Ubuntu/Debian apt install gh
-
完成 GitHub 认证
gh auth login
基本使用
本服务提供了通过 MCP 协议访问 GitHub 功能的简单接口,包括仓库、Issue、PR 和 Gist 管理。
常用操作示例
# 查看仓库
repo_info = repo_view("microsoft/vscode")
# 查看 PR 差异(支持完整输出,不会截断)
diff = pr_diff(2543, "qianshouapp/kyc")
# 创建 Issue
issue_create("owner/repo", "Issue标题", "这是issue的内容")
# 创建 PR
pr_create("owner/repo", "PR标题", "PR描述", "main")
参数类型说明
- PR/Issue 编号必须使用整数类型:
pr_view(123, "owner/repo")
- 仓库名称、分支名使用字符串类型:
pr_create("owner/repo", "标题", "内容", "main")
可用功能
仓库操作
repo_list()
- 列出仓库repo_view(repo)
- 查看仓库详情repo_create(name, description, private)
- 创建仓库
Issue 操作
issue_list(repo, state)
- 列出 Issueissue_view(issue, repo)
- 查看 Issueissue_create(repo, title, body)
- 创建 Issue
PR 操作
pr_list(repo, state)
- 列出 PRpr_view(pr, repo)
- 查看 PRpr_diff(pr, repo)
- 查看 PR 差异pr_create(repo, title, body, base)
- 创建 PR
Gist 操作
gist_list()
- 列出 Gistgist_create(files, description, public)
- 创建 Gist
故障排除
如遇问题,请确认:
- GitHub CLI 已正确安装 (
gh --version
) - 已完成身份验证 (
gh auth login
) - 有权限访问相关资源
- 参数类型正确(PR/Issue 编号为整数)