关于 mcp-github-cli
mcp-github-cli 是通过 GitHub CLI 和 GitHub GraphQL、REST API 操作 GitHub 的 MCP 服务,面向需要在客户端中查询或维护仓库的用户。它涵盖用户资料、仓库、议题、拉取请求及自定义 API 请求。
主要功能
- 01查询已认证用户信息
- 02获取仓库、用户与贡献者资料
- 03查询议题和拉取请求
- 04搜索仓库并读取文件内容
- 05创建议题和拉取请求
- 06执行自定义 GraphQL 与 REST 请求
适用场景
- 01查看仓库信息、分支和提交
- 02检索议题与拉取请求状态
- 03从 MCP 客户端创建议题或拉取请求
MCP 相关
该 MCP 服务通过 GitHub CLI 提供 GitHub GraphQL 和 REST API 工具,供 MCP 客户端使用。运行前需安装 `gh` 并完成 GitHub 身份验证。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
mcp-github-cli
提供专注于 GraphQL 和 REST API 工具的 MCP 服务,用于与 GitHub 交互。该服务提供一组精简而强大的工具,利用 GitHub 的 API 提供丰富的数据和功能。
用法
uvx mcp-github-cli
将从 PyPI 运行。可在 goose 或 claude 中使用。
前提条件
-
如果尚未安装 GitHub CLI(
gh),请先安装:- macOS:
brew install gh - Linux:
sudo apt install gh - Windows:
winget install GitHub.cli
- macOS:
-
使用 GitHub 进行身份验证:
gh auth login
测试
uv run python main.py --test
这将运行一套全面的测试,用于验证:
- GitHub 身份验证状态
- 用户信息获取(gh_get_me)
- GraphQL 查询功能(查看者信息)
- REST API 仓库搜索
- GraphQL 仓库信息获取
- REST API 分支列表
测试输出很好地展示了不同工具的功能。
从源代码运行
从命令行运行(用于 Goose,或进行试用)
uv --directory /path/to/mcp-github-cli run python main.py
功能
此 MCP 服务专注于提供强大的工具,充分利用 GitHub 的 GraphQL 和 REST API:
用户信息
gh_get_me():获取已通过身份验证的用户的详细信息
GraphQL 工具
GraphQL 工具可通过单次请求提供丰富的嵌套数据:
gh_graphql_repo_info(owner_repo):获取全面的仓库信息gh_graphql_user_profile(username):获取详细的用户个人资料数据gh_graphql_pull_requests(owner_repo, limit, state):获取包含审核者和状态的拉取请求gh_graphql_issues(owner_repo, limit, state, labels):获取包含评论和标签的问题gh_graphql_repo_contributors(owner_repo, limit):获取仓库贡献者及其提交记录gh_custom_graphql(query, variables):执行自定义 GraphQL 查询
REST API 工具
REST 工具为常见操作提供特定功能:
gh_rest_search_repos(query, limit):搜索仓库gh_rest_repo_contents(owner_repo, path, ref):获取仓库内容gh_rest_create_issue(owner_repo, title, body, labels):创建问题gh_rest_create_pr(owner_repo, title, body, head, base, draft):创建拉取请求gh_rest_branches(owner_repo):列出仓库分支gh_rest_commits(owner_repo, branch, limit):列出仓库提交记录gh_rest_api(endpoint, method, data, query_params):执行自定义 REST API 请求
示例
以下是使用这些工具的示例:
用户信息
# Get authenticated user information
gh_get_me()
GraphQL 示例
# Get repository information
gh_graphql_repo_info("block/goose")
# Get user profile
gh_graphql_user_profile("octocat")
# Get open pull requests
gh_graphql_pull_requests("block/goose", 5, "OPEN")
# Get issues with specific labels
gh_graphql_issues("block/goose", 10, "OPEN", ["bug", "help wanted"])
# Custom GraphQL query
gh_custom_graphql("""
query {
viewer {
login
name
}
}
""")
REST API 示例
# Search for repositories
gh_rest_search_repos("language:python stars:>1000", 5)
# Get file contents
gh_rest_repo_contents("block/goose", "README.md")
# Create an issue
gh_rest_create_issue("your-username/your-repo", "Bug report", "There's a bug", ["bug"])
# List branches
gh_rest_branches("block/goose")
# Custom REST API request
gh_rest_api("repos/block/goose", "GET", query_params={"sort": "updated"})
构建和发布
- 在
pyproject.toml中更新版本:
[project]
version = "x.y.z" # Update this
- 构建软件包:
# Clean previous builds
rm -rf dist/*
# Or build in a clean environment using uv
uv venv .venv
source .venv/bin/activate
uv pip install build
python -m build
- 发布到 PyPI:
# Install twine if needed
uv pip install twine
# Upload to PyPI
python -m twine upload dist/*
许可证
MIT
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。