mcp-repo-graph
Extracts entities and relationships from Rust codebases using Actix web framework, including routes, structs, traits, and functions for graph-based code navigation.
Analyzes Angular applications to extract components, services, guards, dependency injection, HTTP calls, and feature flows for structural understanding and navigation.
Detects HTTP calls made with Axios in React applications for mapping API interactions and data flows within the codebase graph.
Analyzes C/C++ codebases using CMake, Makefile, or Meson build systems to extract sources, headers, classes, structs, enums, namespaces, and include relationships.
Extracts HTTP routes from Go codebases using the Chi router framework for mapping API endpoints and their relationships.
Detects and analyzes C/C++ projects using CMake build systems to extract structural information about sources, headers, and dependencies.
Identifies PHP projects and extracts namespaces, classes, interfaces, and routes from Laravel or Symfony frameworks for structural analysis.
Extracts packages, modules, classes, functions, and routes from Python Django web applications for graph-based code navigation.
Analyzes Python FastAPI applications to extract routes, dependencies, and API endpoints for structural understanding and flow tracing.
Extracts packages, modules, classes, functions, and routes from Python Flask web applications for graph-based code analysis.
Extracts HTTP routes from Go codebases using the Gin web framework for mapping API endpoints and their relationships.
Provides git state information and supports integration with git hooks for automatic graph regeneration to maintain up-to-date codebase maps.
Detects Java/Kotlin projects using Gradle build systems and extracts packages, classes, and routes from Spring or JAX-RS frameworks.
Extracts entities and relationships from Hono JavaScript/TypeScript web applications for structural analysis and flow mapping.
Analyzes Kotlin codebases to extract packages, classes, and routes from Spring or JAX-RS frameworks for structural understanding.
Extracts namespaces, classes, interfaces, and routes from PHP Laravel applications for structural analysis and dependency mapping.
Analyzes NestJS applications to extract modules, controllers, services, and dependencies for structural understanding and flow tracing.
Analyzes C#/.NET projects to extract namespaces, classes, and routes from ASP.NET or Minimal API applications for structural navigation.
Detects PHP projects and extracts structural information including namespaces, classes, interfaces, and framework routes for analysis.
Supports integration with git pre-commit hooks for automatic graph regeneration to maintain current codebase maps without manual intervention.
Analyzes Python codebases to extract packages, modules, classes, functions, and web framework routes for structural understanding and navigation.
Extracts React components, hooks, context providers, and React Router routes for structural analysis and dependency mapping.
Detects and analyzes React Router routes within React applications for mapping navigation flows and component relationships.
Extracts entities and relationships from Rust codebases using Rocket web framework, including routes and structural elements for graph navigation.
Analyzes Ruby codebases to extract files, classes, modules, and Rails routes for structural understanding and dependency mapping.
Extracts crates, modules, structs, traits, functions, and web framework routes from Rust projects for structural analysis.
Extracts packages, classes, and routes from Java/Kotlin Spring framework applications for structural understanding and flow tracing.
Analyzes Swift codebases to extract files, types (class/struct/enum/protocol/actor), and Vapor routes for structural navigation.
Extracts namespaces, classes, interfaces, and routes from PHP Symfony applications for structural analysis and dependency mapping.
Uses pyproject.toml for Python project detection and Cargo.toml for Rust project detection as configuration markers for analyzer activation.
Analyzes TypeScript codebases to extract modules, classes, functions, and import relationships for structural understanding and navigation.
Extracts routes and structural elements from Swift Vapor web applications for graph-based code analysis and flow tracing.
Uses YAML format for storing named feature flows with ordered step sequences in the generated graph data for flow analysis.
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.
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
Flows: end-to-end paths from entry point to data layer
Then it exposes 12 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 |
Python |
| Packages, modules, classes, functions, routes (Flask/FastAPI/Django) |
Java/Kotlin |
| Packages, classes, routes (Spring/JAX-RS) |
C#/.NET |
| Namespaces, classes, routes (ASP.NET/Minimal API) |
Ruby |
| Files, classes, modules, routes (Rails) |
PHP |
| Namespaces, classes, interfaces, routes (Laravel/Symfony) |
Swift |
| Files, types (class/struct/enum/protocol/actor), routes (Vapor) |
C/C++ |
| Sources, headers, classes, structs, enums, namespaces, includes |
SCSS |
| File-level bloat analysis (selector blocks, sizes) |
Multiple analyzers 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-graphRequires Python 3.11+. Only runtime dependency: mcp[cli].
Quick start
1. Generate the graph
repo-graph-generate --repo /path/to/your/projectThis scans the codebase and writes graph data to .ai/repo-graph/ inside the target repo.
2. Connect to your AI assistant
Add to your MCP configuration:
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 12 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 repo-graph-generate 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-generate --repo .
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 |
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
Detect —
scan_project_dirs()finds project roots (including monorepo layouts likepackages/*,apps/*,services/*,src/*). Each analyzer checks for its marker files.Scan — matching analyzers extract entities and relationships using regex heuristics. No AST parsing, no external toolchains, no build step required.
Merge — all analyzer results merge into a single graph. Nodes deduplicate by ID, edges by (from, to, type).
Serve — the MCP server loads the graph into memory and exposes BFS-based traversal tools.
Graph data format
Generated files live in .ai/repo-graph/ inside the target repo:
nodes.json—[{id, type, name, file_path}, ...]edges.json—[{from, to, type}, ...]flows/*.yaml— named feature flows with ordered step sequencesstate.md— human-readable snapshot for quick orientation
Edge types: imports, defines, contains, uses, calls, handles, handled_by, exports, includes.
Adding a new analyzer
Create repo_graph/analyzers/<language>.py:
from .base import AnalysisResult, Edge, LanguageAnalyzer, Node, scan_project_dirs, rel_path, read_safe
class MyLangAnalyzer(LanguageAnalyzer):
@staticmethod
def detect(repo_root):
# Check for language marker files
return any(
(d / "my-marker").exists()
for d in scan_project_dirs(repo_root)
)
def scan(self):
nodes, edges = [], []
# ... scan files, extract entities, build relationships ...
return AnalysisResult(
nodes=nodes,
edges=edges,
state_sections={"MyLang": f"{len(nodes)} entities\n"},
)
# Optional: file-level analysis for bloat_report / split_plan
def supported_extensions(self):
return {".mylang"}
def analyze_file(self, file_path):
# Return dict with function/method sizes, class counts, etc.
pass
def format_bloat_report(self, analysis):
# Format the analysis dict into a human-readable string
passRegister it in analyzers/__init__.py by adding it to _analyzer_classes().
License
MIT
Support
If repo-graph saved you time, consider buying me a coffee.
Latest Blog Posts
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/James-Chahwan/repo-graph'
If you have feedback or need assistance with the MCP directory API, please join our Discord server