GitHub Code MCP
Provides read access to GitHub repositories, enabling code search, file and line-range retrieval, Java symbol and fragment extraction, directory browsing, and repository metadata, readme, branch, and commit listing.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@GitHub Code MCPshow me the getReport method in ReportService.java"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
GitHub Code MCP
An MCP server that gives the Rapid7 SI Triage agent read access to source code
on GitHub — by default, anands-bounteous/nexpose.
It fills the gap the other two servers don't cover: jira-confluence-mcp owns
tickets/KB, log-intelligence-mcp owns log retrieval, but a Phase 2
investigation also needs to pull the actual Java source that produced a stack
trace or defect. This server hits the real GitHub REST + Search APIs directly
(no mocking, no local cloning) and is scoped specifically to reading code
and returning fragments of it — issue/PR management stays out of scope.
owner/repo are optional per-call overrides on every tool, on top of the
GITHUB_OWNER/GITHUB_REPO defaults, so the server can be pointed at another
repo without a restart.
Tools
Tool | Purpose |
| The core "fetch fragments for input text" tool — GitHub code search with highlighted match fragments showing exactly where the query hit. Requires |
| Fetch a file, or just a 1-indexed inclusive line range of it. |
| Enumerate the classes/interfaces/enums/records/methods/constructors declared in a Java file, with line ranges — use this to find a symbol name for |
| Java-aware extraction of one method/class/constructor body by name. Falls back to a plain text context window if the symbol isn't a recognisable declaration. |
| Browse the repo tree. |
| Description, default branch, language, topics, stars. |
| Project overview as plain text. |
| Branch names + latest commit sha. |
| Recent history, optionally scoped to one file. |
Related MCP server: mcp-server-github
Java-aware fragment extraction
get_code_fragment/list_symbols are backed by a pluggable FRAGMENT_BACKEND:
tree-sitter(AST-accurate) — parses withtree-sitter+tree-sitter-java. Correctly handles generics (Map<String, List<Foo>>), annotations, records, nested/anonymous classes, and text blocks — anything a hand-rolled brace-counter gets wrong on real Java. Optional dependency:pip install -e ".[java]".regex(dependency-free fallback) — matches Java declaration syntax to find a symbol's header line, then a string/char/comment-aware balanced-brace scanner (aware of",',//,/* */, and Java 15+"""text blocks, so a{/}inside a literal or comment can't throw off the count) finds the matching close.auto(default) — triestree-sitterfirst; if the optional dependency isn't installed, logs a warning and degrades toregex. Explicit choices (tree-sitter/regex) raise instead of silently degrading.
If a requested symbol isn't a recognisable Java declaration (e.g. it's a field
name, or doesn't exist), both backends fall back to a plain
±FRAGMENT_CONTEXT_LINES text window around its first literal occurrence, with
match_type="context_window" in the response so the caller can tell it's a
lower-confidence result rather than an exact definition.
Auth & configuration
Copy .env.example to .env:
GITHUB_TOKEN=<create at github.com/settings/tokens>
GITHUB_API_BASE_URL=https://api.github.com
GITHUB_OWNER=anands-bounteous
GITHUB_REPO=nexpose
GITHUB_DEFAULT_REF=
MAX_FILE_KB=500
FRAGMENT_CONTEXT_LINES=20
FRAGMENT_BACKEND=auto
HTTP_TIMEOUT=30
HTTP_MAX_RETRIES=4
MCP_HTTP_HOST=127.0.0.1
MCP_HTTP_PORT=8082GITHUB_TOKEN is a GitHub personal access token
(github.com/settings/tokens). It's optional for reading public repos — but
required for search_code (GitHub's code search API rejects unauthenticated
requests outright) and strongly recommended for everything else (5,000
requests/hour authenticated vs. 60/hour anonymous). A fine-grained PAT with
read-only "Contents" access is enough; no repo write scope is needed since
this server never writes to GitHub.
GITHUB_API_BASE_URL is overridable for GitHub Enterprise Server. It's
normalised to just the scheme+host, same as any pasted API URL.
The HTTP client retries 429/5xx with exponential backoff (honouring
Retry-After), and additionally watches GitHub's primary rate-limit signal
(X-RateLimit-Remaining: 0 + X-RateLimit-Reset) to sleep until the limit
resets rather than blindly backing off — controlled by HTTP_MAX_RETRIES and
HTTP_TIMEOUT.
Install & run
cd github-mcp
python -m venv .venv && source .venv/bin/activate # .venv\Scripts\Activate.ps1 on Windows
pip install -e . # base install: mcp, httpx, uvicorn
pip install -e ".[java]" # + tree-sitter/tree-sitter-java for AST-accurate fragments
cp .env.example .env # fill in GITHUB_TOKEN
# stdio:
python -m github_mcp --transport stdio
# HTTP (streamable-http at http://127.0.0.1:8082/mcp):
python -m github_mcp --transport httpRegister with an MCP client (stdio example)
{
"mcpServers": {
"github": {
"command": "python",
"args": ["-m", "github_mcp", "--transport", "stdio"],
"env": {
"GITHUB_TOKEN": "…",
"GITHUB_OWNER": "anands-bounteous",
"GITHUB_REPO": "nexpose"
}
}
}
}Ports
This server's HTTP transport defaults to 8082 — jira-confluence-mcp uses
8080 and log-intelligence-mcp uses 8081, so all three can run simultaneously.
Tests
pytest # in an environment with pytest installed
python tests/_runner.py # offline harness when pytest isn't installedCovers base-URL normalisation, content decoding, line-slicing, directory/repo/
branch/commit normalisation, search-query building and result normalisation,
and — via a stub HTTP transport (FakeClient, no network needed) — file
fetch with the MAX_FILE_KB size guard, directory listing, repo info/readme/
branches/commits, the search_code no-token guard, and the fragment-backend
factory. The Java regex backend is exercised directly against a realistic
fixture source file (tests/fixtures/Sample.java) covering nested classes, an
interface, a generic method, an annotated method, and a string literal
containing {/} to prove brace-in-string masking works. 30 tests, all
offline — none need GITHUB_TOKEN or network access.
If
tree-sitter-javaisn't installed, tests targetRegexJavaBackendexplicitly rather than relying onFRAGMENT_BACKEND=autoresolution, so the suite stays runnable regardless of what's pip-installed.
Live GitHub API calls (a real
search_code/get_file_contentsagainstanands-bounteous/nexpose) need a realGITHUB_TOKENand network access, which the automated test suite doesn't exercise — see "Install & run" above to try them manually.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceEnables access to GitHub repositories and data through the GitHub API. Supports retrieving repositories, issues, pull requests, and searching code across GitHub with authentication via personal access tokens.Last updated
- AlicenseAqualityCmaintenanceEnables interaction with GitHub repositories, issues, pull requests, code search, branches, and GitHub Actions workflows.Last updated8533MIT
- AlicenseAqualityDmaintenanceEnables code search across indexed repositories using regex patterns, with pagination, repository listing, and file context retrieval via Hound integration.Last updated33MIT
- Alicense-qualityDmaintenanceEnables querying GitHub repositories for pull requests, commits, and comparisons to understand code changes.Last updated17Apache 2.0
Related MCP Connectors
Screens public GitHub repos and PRs to generate risk maps, findings, and merge-readiness signals.
Enterprise code intelligence for M&A, security audits, and tech debt. Hosted server with 200k free.
An MCP server that gives your AI access to the source code and docs of all public github repos
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hareeshbounteous/github-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server