repo2graph — Claude Code MCP server: what it does, how to install
Maps codebase relationships with Tree-sitter and returns cited code excerpts within a strict token limit. Useful for coding agents tracing cross-file calls without external API keys.
claude mcp add repo2graph -- uvx repo2graphWhat repo2graph does
repo2graph indexes source code with a single Tree-sitter pass to record import links, function invocations, and files committed together in Git history. It kicks off retrieval with BM25 keyword matching, traverses the discovered dependency edges, and returns excerpts capped by a preset token budget. Every code snippet includes precise location metadata in a [cite: path:start-end] header.
The server runs entirely offline by default, requiring no database, language server, or external API access. Precompiled grammar files are shipped directly inside the tree-sitter-language-pack distribution. Outbound network traffic happens only if you explicitly clone a GitHub repository, pass --answer to contact an LLM, or opt into embedding models through repo2graph[rag] or repo2graph[rag-static].
The tool beats basic grep on multi-file structural investigations, but ripgrep performs better on simple lexical lookups inside a single file.
What it helps with
- trace cross-file function calls and inheritance hierarchies
- retrieve code snippets bounded by a strict token limit
- get cited code references with exact line numbers
- inspect repository architecture without sending source code to third-party services
Example prompts for the agent
- Trace how HTTP requests are routed and list the functions handling them.
- Locate the base database model and show all modules importing it.
- Explain the error handling flow based on the call graph.
How to install repo2graph
Platform CLI
claude mcp add repo2graph -- uvx repo2graphuvx runs the command named after the package; if the README names another one, use uvx --from repo2graph <command>
Platform CLI
codex mcp add repo2graph -- uvx repo2graphuvx runs the command named after the package; if the README names another one, use uvx --from repo2graph <command>
Config file
{
"mcpServers": {
"repo2graph": {
"command": "uvx",
"args": [
"repo2graph"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from repo2graph <command>
Config file
{
"servers": {
"repo2graph": {
"type": "stdio",
"command": "uvx",
"args": [
"repo2graph"
]
}
}
}uvx runs the command named after the package; if the README names another one, use uvx --from repo2graph <command>
Platform CLI
gemini mcp add repo2graph uvx repo2graphuvx runs the command named after the package; if the README names another one, use uvx --from repo2graph <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about repo2graph
How do I install repo2graph in Claude Code?
Run claude mcp add repo2graph -- uvx repo2graph in your terminal. You will need uv installed on your system.
What does repo2graph do?
It creates a code graph using Tree-sitter and Git commit history to track imports and calls. When queried, it starts with BM25 matches, traverses the graph edges, and outputs relevant code blocks with line citations within a defined token budget.
Does repo2graph require an external API or database?
No, standard indexing and queries run locally without external databases, network calls, or API credentials. Network access is only triggered when cloning remote repositories or downloading optional dense vector models.