用于与GitHub交互的MCP服务器,提供专注于GraphQL和REST API工具。此服务器提供了一套强大的工具,利用GitHub的API来提供丰富的数据和功能。
uvx mcp-github-cli
可以从PyPI运行。这可以在goose或claude中使用。
如果尚未安装,请安装GitHub CLI (gh):
brew install ghsudo apt install ghwinget install GitHub.cli使用GitHub进行身份验证:
gh auth login
uv run python main.py --test
这将运行一个全面的测试套件,验证以下内容:
测试输出很好地展示了不同工具的能力。
uv --directory /path/to/mcp-github-cli run python main.py
此MCP服务器专注于提供强大的、集中的工具,利用GitHub的GraphQL和REST API:
gh_get_me(): 获取已认证用户的详细信息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工具为常见的操作提供特定的功能:
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请求这里是一些使用这些工具的例子:
# 获取已认证用户的信息
gh_get_me()
# 获取仓库信息
gh_graphql_repo_info("block/goose")
# 获取用户资料
gh_graphql_user_profile("octocat")
# 获取打开的拉取请求
gh_graphql_pull_requests("block/goose", 5, "OPEN")
# 获取具有特定标签的问题
gh_graphql_issues("block/goose", 10, "OPEN", ["bug", "help wanted"])
# 自定义GraphQL查询
gh_custom_graphql("""
query {
viewer {
login
name
}
}
""")
# 搜索仓库
gh_rest_search_repos("language:python stars:>1000", 5)
# 获取文件内容
gh_rest_repo_contents("block/goose", "README.md")
# 创建一个问题
gh_rest_create_issue("your-username/your-repo", "Bug report", "There's a bug", ["bug"])
# 列出分支
gh_rest_branches("block/goose")
# 自定义REST API请求
gh_rest_api("repos/block/goose", "GET", query_params={"sort": "updated"})
pyproject.toml中的版本:[project]
version = "x.y.z" # 更新此版本
# 清除之前的构建
rm -rf dist/*
# 或在干净环境中使用uv构建
uv venv .venv
source .venv/bin/activate
uv pip install build
python -m build
# 如果需要,安装twine
uv pip install twine
# 上传到PyPI
python -m twine upload dist/*
MIT