
GitHub (read-only)
io.github.AbdulMuhaiminKhanv1.2.0更新於 Oct 8, 2026
Read-only GitHub repos, issues, PRs and commits, with tool descriptions tuned on a benchmark.
概覽
為助理提供唯讀的 GitHub 存取:列出儲存庫、檢視儲存庫資訊、瀏覽未關閉議題、搜尋議題、列出提取要求與查看最近提交。
- 功能
- 一個本機 stdio MCP 伺服器,提供六個唯讀 GitHub 工具:list_repositories、get_repository、list_open_issues、search_issues、list_pull_requests 與 get_recent_commits。它傳回帶精確總數的精簡 JSON,處理分頁、重試、速率限制與 ETag 快取,並調整了工具描述,讓模型能選對工具與參數。它也附帶用於評估工具選擇的基準測試工具。
- 適用情境
- 當助理需要在不具寫入權限的情況下回答關於你的 GitHub 儲存庫、議題、提取要求與提交的問題時使用。適合唯讀瀏覽與查詢,不適合建立、編輯或合併任何內容。
- 執行需求
- 透過 stdio 在本機執行,通常使用 uvx 從 PyPI 套件 github-mcp-readonly 或 Git 儲存庫啟動;直接安裝需要 Python 3.10+。需要一個精細的 GitHub 權杖,具有對 Metadata、Contents、Issues 與 Pull requests 的唯讀權限,透過環境變數 GITHUB_TOKEN 提供。需要存取 GitHub REST API 的網路連線。GITHUB_MCP_TOOLSET 可選,用於選擇工具描述版本。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 GitHub (read-only),將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
GitHub MCP Server: Teaching an AI to Pick the Right Tool
[test] [python] [mcp] [cost] [license]
A read-only Model Context Protocol server that lets Claude (or any MCP client) answer questions about my GitHub repos, issues, pull requests and commits. It comes with a benchmark that measures how often the model picks the right tool with the right arguments.
Rewriting the tool descriptions took a local 7B model from 63% to 95% correct, and from 60% to 90% on held-out questions it was never tuned on. An ablation shows where those 32 points came from, and most of them were not the prose:
Every miss left in v2 is the model asking for something the API doesn't offer: merged PRs, sorting by stars, or closed issues from the open-issues tool. Better wording can't fix those. The next step is to support them in the schema.
Explore every question in the results dashboard →
[Outcome shares per configuration]
What I built
- MCP server (Python,
mcpSDK 2.x) with 6 read-only tools over stdio:list_repositories,get_repository,list_open_issues,search_issues,list_pull_requests,get_recent_commits. - Least-privilege access: a fine-grained, read-only GitHub token and
readOnlyHintannotations. The token stays in the server process and never reaches the model. - Production behaviour: schema-validated inputs, retries with backoff and jitter, primary and secondary rate-limit handling, ETag caching (304s don't count against the rate limit), exact totals for list tools, and error messages that tell the model how to recover.
- A benchmark with known answers: a seed script creates two repos with 15 issues, 5 pull requests and commits from two authors. A fake GitHub API serves the same data offline, so the benchmark also runs in CI with no token.
- Three evaluations: tool selection with argument grading (60 questions), a held-out set (20), and multi-step agent runs whose final answers are checked against the seeded facts (13).
- An ablation (
v1 → v1b → v2) that separates input handling from description wording. - An automatic description optimizer that rewrites descriptions from failures and keeps a change only if held-out accuracy doesn't drop.
- A harness that benchmarks any MCP server, not just this one (examples/).
- A results dashboard (docs/) with every question, call and error from the runs.
- Tests and CI on Python 3.10–3.13 (ruff, mypy, pytest, and an oracle check that the harness scores 100% when the right call is made).
Architecture
Evaluation
Method. Each question goes to the model with the server's own tool list, exactly what Claude Desktop sends. The harness executes the chosen call through MCP and grades it:
- ✅ Correct: expected tool, call succeeded, arguments match (e.g. "last 3 days" →
since_days=3) - 🟡 Wrong Arguments: right tool, call succeeded, but an argument is wrong or missing
- ⚠️ Wrong Tool: a different tool, or no tool
- ❌ Tool Failed: right tool, but the call returned an error
There are 60 questions (10 per tool, a third of them in deliberate overlap zones between tools), plus 20 held-out questions written after v2 was frozen and never used for tuning. The data is the seeded benchmark repos on real GitHub, and the model runs locally with Ollama at temperature 0, 3 runs per configuration, medians reported. The three runs differed by at most 2 points on the main set and 5 on held-out.
The offline run against the fake GitHub gave the same picture (65% / 82% / 95%).
A second model, llama3.1:8b, same questions and settings:
Llama picked the right tool 88% of the time even on v1. It failed on arguments: it asked for
limit=100 on tools capped at 50 again and again, and passed owner/repo where a bare name was
expected. The fixes that helped qwen (bare names, the stated limit range) helped llama even more, so the
lesson carries across models: spell out argument constraints, not just what the tool does.
Agent mode (13 multi-step questions, answers checked against the seeded data): v1 62%, v2 69%. With 13 questions one answer is 8 points, so that difference is within noise (offline it went the other way).
Cost of better descriptions: v2 adds about 920 input tokens to every request (614 → 1533).
Raw results, one JSON row per question per run: eval/results/.
Benchmark your own MCP server
The harness isn't tied to this server. Give it the command that starts any stdio MCP server and a JSONL file of questions:
examples/ has a small notes server with 10 questions and the question format.
Decision File
1. Why the model picked the wrong tool
Every wrong-tool pick from the v1b run (3 of 3 runs each), and what v2 did about it:
2. What the ablation showed
With an oracle that always picks the right tool, v1 scores 83%: all 10 bare-name questions fail because v1
requires owner/name. So part of any v1 → v2 gain was always going to be input handling. v1b (v1 text +
bare names) separates the two:
- v1 → v1b: +17 points. All 10 bare-name questions went from ❌ to ✅. The wording didn't change at all.
- v1b → v2: +15 points, from 9 questions:
- 5 were one parameter sentence. v1's
limitsaid "How many." The model asked for 100, the schema allows 50, and the call failed. v2 says "(1-50)" and those 5 questions pass. - 4 were the tool wording: the first four rows of the table above.
- 5 were one parameter sentence. v1's
The model rarely picked the wrong tool even with vague descriptions (92% right tool on v1). Most of the failures came from calls the server rejected.
3. What I changed
- Each description states what it returns, when to use it, and when NOT to use it, naming the
alternative, e.g.
list_open_issues: "Do NOT use for closed issues, keyword search, or issues across all repos (use search_issues), or for pull requests (use list_pull_requests)." - Boundaries are mutually exclusive along one axis each: open vs closed, one repo vs all repos, keyword vs none, metadata vs history, issues vs PRs.
- Every parameter documents its format and range with an example. This turned out to matter more than the tool text.
- Behaviour fixes, reported separately: bare repo names resolve to the user's repo, and list tools return exact totals instead of a page-sized count.
- Error messages carry a next step ("Call list_repositories to check the exact name").
4. The automatic optimizer overfit, and the guard caught it
eval/optimize.py shows a model its training failures, asks it to rewrite the descriptions, and keeps a
candidate only if training accuracy rises and held-out accuracy doesn't drop. Starting from v1, with
qwen2.5:7b rewriting its own tools (offline data, 4 iterations):
Every rewrite raised training accuracy and lowered held-out accuracy, so the guard rejected all of them. The 7B model wrote descriptions that fit the questions it had just seen, not the tools. Without the held-out check, iteration 3 would have looked like a 7-point win. The hand-written v2 is what generalized.
5. What's left, and trade-offs
- The 3 remaining v2 misses all ask for something the API doesn't have:
state: "merged"for pull requests,sort: "stars"for repos, andstate: "closed"on the open-issues tool. I didn't reword around them, because that would tune to these exact questions. The right fix is in the schema: acceptmerged(filter onmerged_at), sort by stars client-side, and let the issues tool take a state. - Longer descriptions cost about 920 tokens per request. That's worth it at 6 tools. With dozens of tools I'd move to tool search and deferred loading.
- Agent mode needs more questions before its numbers mean anything (13 is too few).
- Pagination stops at 500 items per list (5 pages); totals beyond that are reported as lower bounds.
Use it
From Claude Desktop, add this to claude_desktop_config.json (or point command at a local install, as in
this example):
Or with Docker: docker build -t github-mcp ., then
claude_desktop_config.docker.example.json.
GUIDE.md covers token permissions, the seed script and the full eval workflow
(WINDOWS.md for PowerShell).
Run the benchmark yourself
Tech
Python 3.10+ · MCP Python SDK 2.x · httpx · pydantic · GitHub REST API · pytest · ruff · mypy · GitHub Actions · Ollama / Anthropic API for evaluation · matplotlib · vanilla JS dashboard
來源:README.md,提交 d8a6e74
工具
0版本歷史
1- v1.2.0最新Oct 8, 2026


