CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

GitHub MCP Server

$ github-mcp-server 官方出品 中风险
GitHub · Agent 桥接与元工具 · MIT · macos / linux / windows

基于 Go 编写的官方 GitHub Model Context Protocol 服务器,通过 MCP(stdio 或 tool-search)暴露仓库、Issue、Pull Request、代码安全与 Actions 能力。支持细粒度范围控制参数(--toolsets、--tools、--features=<list>)、--read-only / GITHUB_READ_ONLY=1 只读安全强制、面向企业版的 --gh-host <url>、--insiders 及 --export-translations。

FCRS-1.0 综合评分
89 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install github-mcp-server
CLI vs MCP 选型建议 CLI + MCP 搭配

在 IDE 或托管 MCP 客户端中推荐使用 github-mcp-server(配合 --read-only 与 tool-search 或受限的 --toolsets/--features);而在本地 Shell 编码 Agent 中,gh CLI 的 Token 开销更低。

Agent 友好度体检单

✓ 原生 JSON 输出
✓ 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
✓ 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 22 / 25

专为 Agent 设计的 JSON-RPC MCP 桥接器,支持 stdio、tool-search 动态发现、--features=<list> / --toolsets 范围控制、--export-translations、--insiders 与 --gh-host。

  • stdio and tool-search subcommands with --features, --toolsets, and --tools scoping
  • --export-translations and --gh-host <url> support
安全与权限边界 21 / 25

提供硬性 --read-only(GITHUB_READ_ONLY=1)限制、防御公开仓库非受信任内容的锁定模式,以及基于作用域的 GITHUB_PERSONAL_ACCESS_TOKEN 环境变量鉴权。

  • --read-only / GITHUB_READ_ONLY=1 strips mutating tools
  • Relies on user-scoped GITHUB_PERSONAL_ACCESS_TOKEN
安装与运行摩擦 14 / 15

静态 Go 单二进制,可通过 brew install github-mcp-server、GitHub Release 或官方 Docker 镜像在 macOS、Linux 与 Windows 运行。

  • brew install github-mcp-server and official Docker/binary builds
能力覆盖与边际价值 13 / 15

tool-search 与 --toolsets/--tools 过滤缓解了传统 MCP 的 Schema 膨胀问题,但在 Shell Agent 中 gh --json --jq 仍更精简。

  • On-demand tool-search and toolset filtering reduce context bloat
维护与来源背书 10 / 10

由 GitHub 官方(github/github-mcp-server)积极维护的 MIT 开源项目。

  • Official github/github-mcp-server repository
文档与可验证性 9 / 10

官方 README 详尽说明了 stdio、tool-search、--read-only、--export-translations 与企业版 --gh-host 配置。

  • Official docs in github/github-mcp-server README

安全边界、鉴权与放权指南

鉴权方式
环境变量密钥 本地配置文件
凭证存储位置

从环境变量读取 GITHUB_PERSONAL_ACCESS_TOKEN 或由 MCP 客户端宿主配置注入;支持 --gh-host 指定企业版端点。

潜在副作用
只读查询 本地写入 远端写入 破坏性删除
费用与配额提示

遵循 MIT 开源协议免费使用;受限于标准 GitHub API 速率限制。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# GitHub MCP Server Agent Rules
- Prefer `--read-only` (or `GITHUB_READ_ONLY=1`) and narrow `--toolsets`/`--tools` unless GitHub write actions are explicitly requested.
- Use `tool-search` or scoped `--features=<list>` to keep MCP context overhead small; never hardcode `GITHUB_PERSONAL_ACCESS_TOKEN` in committed config files.

Agent 高频安全命令配方

只读查询(安全推荐)

导出可自定义的 MCP 工具描述 JSON
github-mcp-server --export-translations

将工具描述的 JSON 翻译/配置映射打印到标准输出并退出,不连接 GitHub。

以只读锁定模式启动 stdio MCP 服务器
GITHUB_PERSONAL_ACCESS_TOKEN="$GITHUB_TOKEN" github-mcp-server stdio --read-only --toolsets=repos,issues,pull_requests

启用 --read-only 启动 stdio JSON-RPC MCP 服务器,排除所有变更类 GitHub 工具。

受控写入与预演

使用显式特性开关运行受限范围的 MCP 服务器
GITHUB_PERSONAL_ACCESS_TOKEN="$GITHUB_TOKEN" github-mcp-server stdio --toolsets=repos,pull_requests --features=issues

通过 stdio 暴露受限范围的 GitHub 读写工具,避免无关工具集 Schema 膨胀。

核心优势

  • + 官方 Go MCP 服务器,具备 --read-only 强制只读与安全锁定模式。
  • + tool-search、--toolsets、--tools 与 --features=<list> 有效控制上下文 Schema 膨胀。
  • + 支持通过 --gh-host <url> 连接 GitHub Enterprise Server,并提供 --insiders 与 --export-translations。

注意事项与踩坑点

  • ! stdio 为面向 MCP 宿主的 JSON-RPC 服务协议,不适合人工在终端直接交互。
  • ! 若未搭配 --toolsets 或 tool-search,加载全量 GitHub 工具相比 gh CLI 会消耗大量 LLM 上下文。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI