github-mcp-server
A narrow, read-only MCP server in Go that gives AI agents controlled access to GitHub repos, issues and PRs, with a bounded API surface, safe retries and no…
A small, read-only MCP server in Go that lets an AI client (Claude, ChatGPT, any MCP client) inspect GitHub repositories, open issues and open pull requests through four explicit tools. Built on the official MCP Go SDK over stdio, calling the GitHub REST API with net/http. List tools return {items, count, paging: {page, per_page, has_more}}. There is no summary tool: the agent combines issues and PRs itself. No mutation tools exist. 1. Create a fine-grained personal access token at GitHub → Settings → Developer settings.
Summary extracted from the README.
GitHub MCP Server
A small, read-only MCP server in Go that lets an AI client
(Claude, ChatGPT, any MCP client) inspect GitHub repositories, open issues and open pull requests
through four explicit tools. Built on the official MCP Go SDK
over stdio, calling the GitHub REST API with net/http.
AI client ──MCP/stdio──▶ Go MCP server ──▶ tool handlers ──▶ GitHub service ──HTTPS──▶ api.github.com
Tools
| Tool | Inputs | Returns |
|---|---|---|
list_repositories |
page, per_page, visibility (all/public/private) — all optional |
Repositories visible to the token's user |
get_repository |
owner, repo |
Description, language, stars, forks, default branch, open issue count |
list_open_issues |
owner, repo, page, per_page |
Open issues; pull requests are excluded |
get_pull_requests |
owner, repo, page, per_page |
Open PRs with draft state and head/base refs |
List tools return {items, count, paging: {page, per_page, has_more}}. There is no summary tool:
the agent combines issues and PRs itself. No mutation tools exist.
Setup
Requires Go 1.25+.
- Create a fine-grained personal access token at GitHub → Settings → Developer settings. Select the repositories you want visible and grant read-only: Metadata, Issues, Pull requests. Nothing else.
- Build:
go build -o bin/github-mcp ./cmd/github-mcp - Configure your MCP client to launch the binary with the token in its environment, e.g. Claude Desktop:
{
"mcpServers": {
"github": {
"command": "C:\\path\\to\\bin\\github-mcp.exe",
"env": { "GITHUB_TOKEN": "<your token>" }
}
}
}
Claude Code: claude mcp add github --env GITHUB_TOKEN=<token> -- /path/to/bin/github-mcp
The token is read from the environment only. It is never a tool argument, and it never appears in schemas, results, errors or logs.
Configuration (environment)
| Variable | Default | Meaning |
|---|---|---|
GITHUB_TOKEN |
— (required) | Fine-grained read-only PAT |
GITHUB_API_URL |
https://api.github.com |
Override for GitHub Enterprise |
GITHUB_MCP_MAX_PER_PAGE |
50 |
Server cap on per_page (1–100) |
GITHUB_MCP_MAX_PAGE |
5 |
Highest page a caller may request |
GITHUB_MCP_TIMEOUT |
10s |
Per-request timeout |
GITHUB_MCP_MAX_RETRIES |
3 |
Retries for timeouts/429/5xx only |
GITHUB_MCP_LOG_LEVEL |
info |
debug, info, warn, error |
With the defaults, one listing is capped at 5 pages × 50 items. When has_more is true the agent
must say coverage is partial.
Safety properties
owner/repoare validated as plain name segments before any request; URLs and../are rejected.- Retries are bounded with exponential backoff and never apply to 401/403/404.
- Provider response bodies are never returned or logged; errors are fixed, actionable messages.
- Logs (JSON on stderr) hold only tool, outcome, duration, error class, HTTP status class and retries.
Test
go test ./...
Tests use a mock GitHub server and an in-memory MCP client. They are mapped to the QA workbook case
IDs (TC-GH-001, TC-NFR-006, …) in comments. Run against live GitHub manually with an MCP client
for the E2E scenarios (TC-E2E-*).
Troubleshooting
| Symptom | Cause / fix |
|---|---|
configuration error: GITHUB_TOKEN is not set |
Pass the token in the client's env block |
authentication: ... invalid or expired |
Regenerate the token |
not found: ... cannot access it |
Wrong name, or the token's repository selection excludes it |
access denied |
Token lacks Issues/Pull requests read permission |
rate limit reached |
Wait; reduce calls. Retries are already bounded |
Layout
cmd/github-mcp/ entrypoint (stdio)
internal/config/ env configuration
internal/mcpserver/ server construction
internal/tools/ four tool handlers
internal/github/ REST client: auth, pagination, retries, error mapping, validation
internal/observability structured, secret-free logging
tests/ unit + MCP integration tests
Phase 2 ideas
Streamable HTTP transport, GitHub App auth, more read-only tools, ETag caching.