Repo2graph logo

Repo2graph

Builds a tree-sitter repository graph and returns cited, token-bounded code context for agent and CI queries.

Install Repo2graph

Pick your client, then add it in one click or paste the config.

STDIOPython
~/Library/Application Support/Claude/claude_desktop_config.json
claude_desktop_config.json
{
  "mcpServers": {
    "repo2graph": {
      "command": "uvx",
      "args": [
        "repo2graph"
      ]
    }
  }
}

Settings → Developer → Edit Config, merge this into mcpServers, then fully quit and reopen Claude Desktop.

Install not yet sandbox-tested— we haven't run this command through our automated sandbox yet. Not a red flag; we're working through the catalog.

Overview

repo2graph MCP server indexes a repository into a tree-sitter graph of definitions, imports, calls, and Git co-change relationships. It combines BM25 retrieval with graph traversal, then returns source blocks cited by file path and line range under a token ceiling. Use it for cross-file structural questions, dependency exploration, and bounded context packs when grep alone is insufficient. It runs locally without a model, API key, language server, or database, with optional network access for GitHub cloning and embedding downloads.

Use cases

  • Answer cross-file questions about a repository
  • Trace callers, callees, and reverse dependencies
  • Build cited context packs for coding agents
  • Inspect a symbol's structural relationships in VS Code
  • Run bounded code retrieval in CI

Key features

  • Tree-sitter repository graph
  • Cited source excerpts with file and line ranges
  • BM25 retrieval with graph expansion
  • Token-bounded MCP responses
  • Caller, callee, base-class, and blast-radius queries
  • Optional dense-vector retrieval

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

13/13 checks healthy over the last 56d

Supply-chain signal

No high-severity advisories surfaced by our automated scan.

Critical 0High 0Medium 0Low 0

Scanned 16d ago via OSV.dev · repo2graph (PyPI)

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars9Stargazers on the source repository.
Last commit6d agoMost recent push to the default branch.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How Repo2graph works

What repo2graph does

repo2graph turns a codebase into a searchable structural map for coding agents and CI workflows. Its index records relationships such as callers, callees, imports, base classes, and files that change together in Git. Queries return source excerpts with citations in the form of a path and line range, making the retrieved evidence traceable.

The server is aimed especially at questions whose answers cross file or module boundaries. It can identify related symbols, follow dependency links, and produce a context pack constrained by a token budget. For purely lexical questions contained in one file, ordinary text search may be a better fit.

How it works

A tree-sitter pass parses the repository and builds the graph. Retrieval begins with BM25 matches, then expands through recorded relationships to find supporting code. The returned pack is measured, capped, and measured again before delivery; the MCP limit is 12,000 tokens.

Relationships exposed by the index carry confidence information. When a name could refer to multiple definitions, the relationship is marked ambiguous and its contribution is reduced rather than selecting a definition without qualification. Reverse dependency traversal can calculate a symbol's blast radius within a hop and visit limit.

Building, querying, and serving the MCP interface are local operations. GitHub targets require cloning, and the optional vector path downloads an embedding model on first use. The standard parser package includes its grammars in the installed wheel.

Setup and configuration

The package can be run through uvx. To try the bundled example, run:

bash
uvx repo2graph demo

To index a local repository into .r2g, use:

bash
uvx repo2graph build . -o .r2g

A cited, budget-limited context pack can be generated with:

bash
uvx repo2graph rag "how does routing work" -o .r2g

Register the MCP interface with Claude Code using:

Terminal
claude mcp add repo2graph -- uvx --from "repo2graph[mcp]" repo2graph-mcp .

Cursor, Claude Desktop, and other MCP clients use the same server through client-specific configuration. An optional dense-retrieval installation is available with repo2graph[rag]; a lighter static backend is available with repo2graph[rag-static]. The backend used for embedding and querying must match. After an embedding model is cached, HF_HUB_OFFLINE=1 prevents later Hugging Face requests.

Tools and capabilities

  • Answer repository questions with cited source blocks.
  • Build a repository index from a local codebase.
  • Retrieve context with BM25 ranking and graph expansion.
  • Inspect a symbol's callers, callees, base classes, and defining file through repo_neighbours.
  • Traverse reverse dependencies with repo_blast_radius.
  • Enforce a token ceiling on returned MCP context.
  • Clone GitHub repositories when given a supported GitHub target.
  • Use the MCP server from Claude Code, Cursor, Claude Desktop, and other compatible clients.
  • Provide caller, callee, base-class, and co-change information to the preview VS Code extension.

Limitations and notes

Graph retrieval is not a replacement for grep. Benchmarks in the project show stronger results on cross-file structural questions and weaker results on single-file lexical questions. Dense retrieval is optional and requires downloading a model; the default BM25 path avoids that dependency.

The rag embedding backend can install PyTorch and, on Linux, NVIDIA CUDA packages. The static backend uses a different model and produces different retrieval behavior. GitHub operations and embedding downloads are the main network-requiring paths; normal indexing, querying, and MCP serving do not make network calls.

There is no interactive desktop UI comparable to Sourcetrail. The project instead exposes repository structure through its CLI, MCP server, and the preview VS Code extension.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Repo2graph

repo2graph is an MCP server that connects coding agents to a repository's parsed source and Git relationships. Its main tools include repo_neighbours for callers, callees, base classes, and definitions, and repo_blast_radius for reverse dependency traversal, with cited results constrained by a token budget.

Run it with uvx, for example `claude mcp add repo2graph -- uvx --from "repo2graph[mcp]" repo2graph-mcp .`. The command registers the local repository as an MCP target for Claude Code.

Yes, repo2graph works with Cursor through its MCP configuration. The project also documents use with Claude Desktop and provides a preview VS Code extension built around the same MCP server.

Yes, it can index a local repository with `uvx repo2graph build . -o .r2g` and retrieve cited context from that index. Its graph is most useful for questions spanning files or module relationships.

No, the default build, query, and MCP workflows require neither an API key nor a language server. They also do not require a model or database; optional vector retrieval downloads an embedding model on first use.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewRepo2graph AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/repo2graph?style=directory)](https://allmcps.com/mcp/repo2graph)
HTML Embed
<a href="https://allmcps.com/mcp/repo2graph"><img src="https://allmcps.com/api/badge/repo2graph?style=directory" alt="Repo2graph on AllMCPs" /></a>