mcp-repo-graph
repo-graph
Structural graph memory for AI coding assistants. Map your codebase. Navigate by structure. Read only what matters.
repo-graph gives LLMs a map of your codebase — entities, relationships, and flows — so they can navigate to the right files without reading everything first.
Instead of flooding an LLM's context window with your entire codebase (or hoping it guesses right), repo-graph builds a lightweight graph of what exists, how things connect, and where the entry points are. The LLM queries the graph, finds the minimal set of files it needs, and reads only those.
Demo
https://github.com/user-attachments/assets/a1e4171b-b225-40d4-9210-39453e14b76a
https://github.com/user-attachments/assets/fc3191e5-fc35-4bd7-8372-72af55995883
Same bug, same model, same prompt — the only difference is whether repo-graph is installed.
The task: fix a reversed comparison operator in a Go + Angular monorepo (566 nodes, 620 edges).
Without repo-graph | With repo-graph | |
Tokens used | 75,308 | 29,838 |
Time to fix | 4m 36s | ~30s |
Files explored | ~15 (grep, read, grep, read...) | 2 (flow lookup + handler file) |
Outcome | Found and fixed the bug | Found and fixed the bug |
2.5x fewer tokens. ~9x faster. Same correct fix.
How the test was run
Both runs used identical conditions to keep the comparison fair:
Same model: Claude Opus, 100% (no Haiku routing)
Same prompt: "Groups that were created recently are showing as closed, and old groups show as open. This is backwards — new groups should be open for members to join. Find and fix the bug."
Fresh context: each run started from
/clearwith no prior conversationNo other tools: CLAUDE.md, plugins, hooks, and all other MCP servers were removed for both runs — the only variable was whether repo-graph was installed
No hints: the prompt describes the symptom, not the location — Claude has to find
group_controller.go:57on its own
Without repo-graph, Claude greps for keywords, reads files, greps again, reads more files, and eventually narrows down to the bug. With repo-graph, Claude calls flow("groups"), gets back the exact handler function and file, reads it, and fixes it.
Browse pre-generated examples for FastAPI, Gin, Hono, and NestJS — real graph output you can inspect without installing anything.
Related MCP server: Serena
The problem
LLMs working on code waste most of their context on orientation:
Reading files that turn out to be irrelevant
Missing connections between components in different languages
Not knowing where a feature starts or what it touches
Loading 50 files when 5 would do
This is expensive, slow, and gets worse as codebases grow.
How repo-graph solves it
repo-graph scans your codebase once and builds a graph of:
Entities: modules, packages, classes, functions, routes, services, components
Relationships: imports, calls, handles, defines, contains, cross-stack HTTP
Flows: end-to-end paths from entry point to data layer
Then it exposes 13 MCP tools that let the LLM:
Orient — "What languages are in this repo? What are the main features?"
Navigate — "Trace the login flow from route to database" / "What's the shortest path between UserService and the payments API?"
Scope — "How many lines would I need to read to understand this feature?" / "Give me just the files I need for this bug fix"
Assess — "What's the blast radius of changing this function?" / "Which files are the biggest maintenance risks?"
The LLM gets structural context in a few hundred tokens instead of reading thousands of lines.
Supported languages
Language | Detection | What it extracts |
Go |
| Packages, functions, HTTP routes (gin/echo/chi/stdlib), imports |
Rust |
| Crates, modules, structs, traits, functions, routes (Actix/Rocket/Axum) |
TypeScript |
| Modules, classes, functions, import relationships |
React |
| Components, hooks, context providers, React Router routes, fetch/axios calls, flows |
Angular |
| Components, services, guards, DI injection, HTTP calls, feature flows |
Vue |
| SFCs, composables, Vue Router routes, fetch/axios calls |
Python |
| Packages, modules, classes, functions, routes (Flask/FastAPI/Django) |
Java/Kotlin |
| Packages, classes, routes (Spring/JAX-RS/Ktor/WebFlux/Micronaut) |
Scala |
| Packages, objects/classes/traits, routes (Play/Akka HTTP/http4s) |
Clojure |
| Namespaces, defn/defprotocol/defrecord, routes (Compojure/Reitit) |
C#/.NET |
| Namespaces, classes, routes (ASP.NET/Minimal API) |
Ruby |
| Files, classes, modules, Rails routes |
PHP |
| Namespaces, classes, interfaces, routes (Laravel/Symfony) |
Swift |
| Files, types (class/struct/enum/protocol/actor), Vapor routes |
C/C++ |
| Sources, headers, classes, structs, enums, namespaces, includes |
Dart/Flutter |
| Modules, classes, widgets, go_router/shelf routes |
Elixir/Phoenix |
| Modules, functions, Phoenix router scopes + routes |
Solidity |
| Contracts, interfaces, libraries, events, inheritance |
Terraform |
| Modules, resources, variables, outputs, module sources |
SCSS |
| File-level bloat analysis |
Cross-cutting extractors (work across all languages):
Data sources — DB/cache/queue/blob/search/email client detection
CLI entrypoints — Python click, JS commander/yargs, Go cobra, Rust clap
gRPC — service/method definitions from
.protofilesQueue consumers — Celery, Dramatiq, BullMQ, Sidekiq, Oban, NATS
Cross-stack HTTP — frontend
fetch/axioscalls linked to backend routes
Multiple languages can match one repo (e.g., Go backend + Angular frontend + SCSS). Each contributes its nodes and edges into a single unified graph.
Install
pip install mcp-repo-graphPython 3.11+. Installs two packages: mcp-repo-graph (the MCP server) and repo-graph-py (the Rust engine, as a prebuilt wheel).
Quick start
1. Initialise the target repo
repo-graph-init --repo /path/to/your/projectThis generates the graph, writes .mcp.json and CLAUDE.md instructions, and gets your AI assistant ready to use repo-graph.
2. Connect to your AI assistant
If you skipped repo-graph-init, add this to your MCP configuration manually:
Claude Code (~/.claude/claude_code_config.json or project .mcp.json):
{
"mcpServers": {
"repo-graph": {
"command": "repo-graph",
"args": ["--repo", "/path/to/your/project"]
}
}
}With environment variable:
{
"mcpServers": {
"repo-graph": {
"command": "repo-graph",
"env": { "REPO_GRAPH_REPO": "/path/to/your/project" }
}
}
}3. Use it
The AI assistant now has access to all 13 tools. Example queries it can answer:
"What does this codebase do?" →
statustool"Trace the checkout flow" →
flowtool"What would break if I change UserService?" →
impacttool"What files do I need for this bug?" →
minimal_readtool"This file is too big, how should I split it?" →
split_plantool"Show me the auth flow visually" →
graph_viewtool
4. Keep it fresh with a git hook (recommended)
Add a call to generate via your MCP client to a pre-commit hook so the graph stays up to date automatically — no LLM context spent on regeneration:
# .git/hooks/pre-commit (or add to your existing hook)
#!/bin/sh
repo-graph --repo . --regenerate
git add .ai/repo-graph/chmod +x .git/hooks/pre-commitEvery commit keeps the graph current. The LLM always has a fresh map without wasting a single token on generate.
Tip: If you don't want graph data in version control, add
.ai/repo-graph/to.gitignoreand skip thegit addline — the graph will just live locally.
MCP tools reference
Generation
Tool | Parameters | Description |
| (none) | Scan the codebase from scratch, rebuild the graph, and reload |
| (none) | Reload graph data from disk (after external regeneration) |
Navigation
Tool | Parameters | Description |
| (none) | Repo overview: git state, detected languages, entity counts, available flows |
|
| End-to-end flow for a feature — from entry point through service layer to data |
|
| Shortest path between any two nodes in the graph |
|
| Fan out from a node to see what it affects or depends on |
|
| All direct connections to and from a node |
Context budgeting
Tool | Parameters | Description |
|
| Total line count for all files in a feature's flow |
|
| Files ranked by |
|
| Smallest file set needed for a specific task within a feature |
Health analysis
Tool | Parameters | Description |
|
| Internal structure of a file: functions/methods ranked by size, type counts |
|
| Concrete suggestions for splitting an oversized file, grouped by responsibility |
|
| Visual ASCII map of a feature flow, node neighbourhood, or full graph overview |
How it works
mcp-repo-graph is a thin Python MCP server that wraps glia, a Rust engine.
Parse — per-language tree-sitter parsers extract raw nodes and unresolved references
Extract — cross-cutting extractors layer on HTTP routes, data sources, CLI entrypoints, gRPC services, queue consumers
Resolve — graph builder resolves intra-repo references; cross-graph resolvers link stacks (frontend HTTP calls → backend routes, etc.)
Store — merged graph lands in
.ai/repo-graph/as a zero-copy.gmap(rkyv + mmap) plus JSON projections for portabilityServe — the MCP server loads the graph into memory and exposes the 13 tools
The Rust engine will split into its own glia repo post-v0.4.12. mcp-repo-graph will remain the MCP-facing thin wrapper.
Config (optional escape hatch)
If auto-detection misses a weird layout, drop .ai/repo-graph/config.yaml in the target repo:
skip:
- legacy # directory basenames excluded from the walk
- scratch
roots: # explicit roots heuristics miss — added on top of auto-detection
- path: apps/weird-layout
kind: python
- path: services/custom
kind: gokind values: go, rust, python, typescript, react, vue, angular, java, scala, clojure, csharp, ruby, php, swift, c_cpp, dart, elixir, solidity, terraform. config.json works too if you prefer.
Graph data format
Generated files live in .ai/repo-graph/ inside the target repo:
nodes.json—[{id, type, name, file_path, confidence, ...}, ...]edges.json—[{from, to, type}, ...]flows/*.yaml— named feature flows with ordered step sequences andkind(http/page/cli/grpc/queue)state.md— human-readable snapshot for quick orientation
Common edge types: imports, defines, contains, uses, calls, handles, handled_by, exports, includes, tests, cross-stack HTTP links.
License
MIT
Support
If repo-graph saved you time, consider buying me a coffee.
Available Tools
6 toolsfindARead-only
Turn any text into the ranked nodes that matter — the on-ramp to the graph. A symbol or keyword returns matching nodes; a pasted stacktrace / failing-test id / diff is resolved to the code it implicates and ranked by relevance. Set expand=true to fan out to the surrounding neighbourhood (spreading activation). Every row carries path:line, so read the top hits directly — no grep.
Inputs: query (required), kind, top_k, budget, +1 more. Returns: result
impactARead-only
Blast radius in one call: fan out from one or more nodes to everything they affect (forward) or depend on / are used by (backward), returned as a deduped, ranked, located closure. Ranking is co-change first where the repo has git history synced, then Personalized PageRank. Each row carries path:line, the edge via reason it's in scope, and a ⊘ when the engine finds it unreachable from any entry point (likely dead). Structural import/containment fan-out is excluded, so there's no noise. A large radius comes back as the top rows plus the areas and files the rest fall in; page with offset, drill in with scope. Depth-1 in both directions is a node's immediate neighbours. Pass several comma-separated nodes to assess a whole diff at once.
Inputs: nodes (required), full, depth, scope, +5 more. Returns: result
orientARead-only
Get the lay of the land — ALWAYS the first call on a codebase. With no arguments: a counts + entry-points overview plus a blind spots note flagging which (language, edge-kind) extractions are partial so you know where to fall back to grep. With seed=<node>: the dense structural map scoped to that node's neighbourhood. With full=true: the whole-repo dense map (the full context dump). Orient first, then find to jump to nodes, impact for blast radius, trace for flows.
Inputs: full, seed, budget. Returns: result
readARead-only
Return the source code for one or more nodes, sliced from their files by the graph's line spans. Use after find/impact to read the exact code without grepping — comma-separate several node names to read the whole ranked set in a single call. Each node is a code block headed by its qname and path:start-end, plus a context: footer with structural facts the source alone doesn't show: HTTP method, cross-stack callers (or, on a WS / gRPC / GraphQL / tRPC client, the host it dials), covering tests, and intent/decision/constraint cells when present.
Inputs: node (required), budget, context_lines. Returns: result
refreshA
(Re)build the structural graph with tree-sitter AST parsing across 20 languages, running the cross-stack resolvers (HTTP, gRPC, GraphQL, WebSocket, queues, events, CLI). Incremental by default — only changed files re-parse — so it's cheap to call after edits; set full=true to force a clean reparse. Accepts a local path or a git URL (cloned on demand). Call after a major refactor; routine edits are picked up automatically by the file watcher.
Inputs: full, repo_path. Returns: result
traceARead-only
Follow the code across boundaries. One argument: trace a feature end-to-end — the ordered path from entry through the stack, each hop labelled with its mechanism (call / HTTP / queue / event / data), crossing service boundaries (frontend→backend). Two arguments: the shortest path between two specific nodes, hop by hop. This is where the graph beats reading many files — it knows the cross-stack links grep can't see.
Inputs: from_node (required), depth, budget, to_node. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool maps to a distinct operation: orient (overview/map), find (text→nodes), impact (ranked fan-out), read (source retrieval), trace (path following), refresh (build). The main blurred boundary is between `find` with `expand=true` and `impact`, and between `orient seed=` and `impact` depth-1 — both fan out over the neighborhood, and only the descriptions disambiguate them.
All six tools use short, lowercase, single-verb names with no prefixes or mixed conventions (impact, find, orient, read, refresh, trace). The pattern is predictable and readable throughout.
Six tools is tightly scoped for a code-graph engine, and each one covers a genuinely different phase of the workflow (orient → find → read/impact/trace, with refresh for maintenance). No tool feels redundant or missing from the count perspective.
The surface covers the full read-only analysis lifecycle: map the repo, locate nodes, read source, measure blast radius, trace cross-stack flows, and rebuild the graph incrementally. Minor gaps exist — no explicit node/edge inspection or metadata/stats query beyond orient's overview, and no diff-scoped entry point apart from passing multiple nodes to impact.
Maintenance
Related MCP Connectors
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Codebase intelligence for AI coding agents: graph, git history, docs, decisions, code health.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Related MCP Servers
- AlicenseAqualityCmaintenanceA Model Context Protocol (MCP) server that helps large language models index, search, and analyze code repositories with minimal setup22142,766 PyPI1,005MIT
- AlicenseAqualityBmaintenanceA fully featured coding agent that uses symbolic operations (enabled by language servers) and works well even in large code bases. Essentially a free to use alternative to Cursor and Windsurf Agents, Cline, Roo Code and others.2931,315GPL 3.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server that transforms codebases into knowledge graphs using Neo4J, enabling AI assistants to understand code structure, relationships, and metrics for more context-aware assistance.28MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to understand and navigate codebases through structural analysis. Provides code mapping, symbol search, and impact analysis using ast-grep for accurate parsing of Python, JavaScript, TypeScript, and Go projects.452MIT