About GitHub CLI MCP服务器
A GitHub CLI-backed MCP server for accessing GitHub repositories, issues, pull requests, and Gists. It supports viewing and creating these objects, including complete pull request diffs, and requires GitHub CLI authentication.
Key features
- 01List and view repositories
- 02Create repositories
- 03List, view, and create issues
- 04View, create, and inspect pull requests
- 05List and create Gists
- 06Expose repository and user resources
Use cases
- 01Review repository details and participation
- 02Create or inspect issues
- 03Review complete pull request diffs
- 04Manage Gists through GitHub CLI
MCP support
Exposes GitHub CLI operations as MCP tools and provides repository and user resources. Access uses an installed and authenticated `gh` CLI.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEGitHub CLI MCP服务器
这个MCP服务器为GitHub CLI提供了简单友好的接口,让你可以通过MCP协议访问GitHub的功能。
功能特点
- 仓库管理:查看、创建仓库
- Issue管理:查看、创建issue
- PR管理:查看、创建、查看差异
- Gist管理:查看、创建gist
安装要求
-
安装GitHub CLI (gh)
# MacOS brew install gh # Ubuntu/Debian apt install gh # 其他系统请参考GitHub CLI官方文档 -
通过
gh auth login完成GitHub认证
参数类型说明
本服务对参数类型有以下要求:
- PR编号必须使用整数类型:
pr_view(123, "owner/repo") - Issue编号必须使用整数类型:
issue_view(456, "owner/repo") - PR基础分支名称使用字符串类型:
pr_create("owner/repo", "标题", "内容", "main")
所有整数参数在内部都会被自动转换为字符串,确保命令正确执行。
使用示例
# 查看PR差异
diff = pr_diff(2543, "qianshouapp/kyc")
# 查看仓库
repo_info = repo_view("microsoft/vscode")
# 创建issue
issue_create("owner/repo", "标题", "这是issue的内容")
PR差异查看
PR差异查看功能支持完整输出所有差异内容,不会进行截断,确保您可以查看到完整的代码变更。
使用示例:
diff = pr_diff(2543, "qianshouapp/kyc")
print(diff) # 显示完整差异
开发说明
如果需要扩展功能,可以修改main.py文件,添加新的工具函数并注册到MCP服务器。
可用工具
仓库操作
repo_list()- 列出你拥有或参与的GitHub仓库repo_view(repo)- 查看仓库详细信息repo_create(name, description, private)- 创建新仓库
Issue操作
issue_list(repo, state)- 列出仓库中的issueissue_view(issue, repo)- 查看特定issue详情issue_create(repo, title, body)- 创建新issue
PR操作
pr_list(repo, state)- 列出仓库中的PRpr_view(pr, repo)- 查看特定PR详情pr_diff(pr, repo)- 查看特定PR的代码差异pr_create(repo, title, body, base)- 创建新PR
Gist操作
gist_list()- 列出你的Gistgist_create(files, description, public)- 创建新Gist
可用资源
repo://{owner}/{name}- 获取仓库信息user://{username}- 获取用户信息
故障排除
如果遇到问题:
- 确保GitHub CLI已正确安装,可通过运行
gh --version验证 - 确保已通过
gh auth login进行身份验证 - 检查是否有权限访问相应的仓库或资源
- 如果使用JSON格式输出有问题,尝试使用标准输出格式
示例
查看PR:
from main import pr_view
result = pr_view(pr="123", repo="owner/repo")
print(result)
查看PR代码差异:
from main import pr_diff
result = pr_diff(pr="123", repo="owner/repo")
print(result)
创建Issue:
from main import issue_create
result = issue_create(
repo="owner/repo",
title="测试Issue",
body="这是通过MCP创建的测试Issue"
)
print(result)
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.