CodeGraph MCP
Provides framework-aware route discovery for Django applications, enabling discovery of Django routes, handlers, and related evidence.
Provides framework-aware route discovery for Express.js applications, enabling discovery of Express routes, handlers, and related evidence.
Provides framework-aware route discovery for FastAPI applications, enabling AI agents to list and inspect FastAPI routes, handlers, and related evidence.
Provides framework-aware route discovery for Flask applications, enabling discovery of Flask routes, handlers, and related evidence.
Provides Git diff and blast-radius impact analysis, identifying changed files, modified symbols, and affected callers, callees, and routes across Git revisions.
Click on "Deploy 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., "@CodeGraph MCPfind all callers of the authenticate function"
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.
CodeGraph MCP
The AI understands the developer. CodeGraph interrogates the repository.
The claim comes from the AI; the proof comes from CodeGraph.
CodeGraph MCP is an open-source, deterministic codebase intelligence server built on the Model Context Protocol (MCP). It is not a conversational AI, a natural-language interpreter, a vector database, or an autonomous agent.
Your AI coding tools and agents (such as Claude Code, Cursor, Codex, and Claude Desktop) handle natural-language reasoning, intent interpretation, and answer synthesis. CodeGraph interrogates the local repository to deliver deterministic, evidence-backed AST facts, call and import graphs, verified line citations, architecture structure, and Git impact.
Quick Start
pip install "codegraph-engine[mcp]"
cd your-repository
codegraph init
codegraph index
codegraph statusRelated MCP server: codegraph-mcp
Architectural Separation of Responsibilities
USER
│
│ natural-language request ("how does authentication work in my app?")
▼
AI AGENT / IDE (Claude Code, Cursor, Codex)
│
├── understands intent and context
├── corrects spelling and informal language
├── identifies candidate code targets
├── resolves conceptual ambiguity
├── decomposes complex queries into precise tool invocations
└── decides which MCP tools to call
│
│ precise, deterministic MCP request (e.g., list_routes(), resolve_symbol("authenticate"))
▼
CODEGRAPH MCP
│
├── deterministic repository retrieval
├── exact symbol and canonical ID resolution
├── graph traversal and path tracing
├── caller and callee analysis
├── route and framework discovery
├── architecture and dependency extraction
├── Git diff and blast-radius impact analysis
└── first-class evidence generation
│
▼
STRUCTURED EVIDENCE
│
├── canonical IDs (path::Symbol.method)
├── file paths and exact line ranges
├── verified relationship edges (CALLS, IMPORTS, HANDLED_BY)
├── index generation and freshness state
└── repository commit hash
│
▼
AI AGENT / IDE (Claude Code, Cursor, Codex)
│
└── synthesizes the final human-readable answer with verified source citations
▼
USERCore Invariants
Deterministic Execution: $$\text{Repository State} + \text{Index Generation} + \text{MCP Request} \Longrightarrow \text{Identical Deterministic Result}$$ Collections are deterministically sorted; results never change between identical invocations.
Zero Natural-Language Guessing: CodeGraph never guesses developer intent or infers vague concepts. If a symbol name is ambiguous across files, CodeGraph returns
status: "ambiguous"with candidate canonical IDs for the AI to choose.No Hallucinations / UNKNOWN Handling: Facts are backed by AST analysis and verified references. If a target does not exist or cannot be proven statically, CodeGraph reports
status: "not_found"orUNKNOWN.Structured Evidence: Every claim or relation is tied to
{ file, start_line, end_line, type, canonical_id }.Completely Local & Resource-Bounded: Zero LLM API calls, zero external vector databases, zero telemetry. Execution runs inside a strict resource governor with thread and memory bounds.
Minimal Orthogonal 13-Tool MCP API
CodeGraph MCP exposes 13 core interrogation tools under profile="core". Every tool returns structured data, an explicit status code ("ok", "not_found", "ambiguous", "invalid_request"), index metadata, and verified evidence.
Tool | Purpose | Key Inputs | Key Output Fields |
| Ground an exact or qualified symbol name |
|
|
| Deterministic token search over non-generated symbols |
|
|
| Retrieve authoritative AST details for a canonical symbol |
|
|
| Structural AST representation of an indexed file |
|
|
| Return verified call sites and references |
|
|
| Return functions and methods that call the target |
|
|
| Return functions and methods called by the target |
|
|
| Deterministic BFS execution path between two symbols |
|
|
| Return imports for a file or canonical symbol |
|
|
| Reverse dependency query (files/symbols depending on target) |
|
|
| Discovered framework routes (FastAPI, Flask, Django, Express) |
|
|
| High-level repository structural overview | none |
|
| Git diff blast-radius impact analysis |
|
|
Response Envelope & Evidence Format
Every response adheres to a predictable structure:
{
"status": "ok",
"symbol": {
"canonical_id": "src/auth/service.py::AuthService.authenticate",
"name": "authenticate",
"kind": "METHOD",
"file": "src/auth/service.py",
"start_line": 42,
"end_line": 68
},
"evidence": [
{
"file": "src/auth/service.py",
"start_line": 42,
"end_line": 68,
"type": "DEFINES",
"canonical_id": "src/auth/service.py::AuthService.authenticate"
}
],
"index": {
"generation": 1,
"created_at": "2026-10-01T12:00:00Z",
"freshness": "FRESH"
},
"repository": {
"commit": "a1b2c3d"
}
}Ambiguous Resolution Example
When a query matches multiple symbols across different modules, CodeGraph will never guess:
{
"status": "ambiguous",
"symbol": null,
"candidates": [
{
"canonical_id": "src/admin/views.py::duplicate_helper",
"file": "src/admin/views.py",
"line": 15
},
{
"canonical_id": "src/auth/views.py::duplicate_helper",
"file": "src/auth/views.py",
"line": 18
}
],
"message": "Multiple symbols match 'duplicate_helper'. Provide a qualified name or canonical ID."
}End-to-End Walkthrough
1. Developer asks:
"how does authentication work in my app?"
2. AI Agent (Claude Code / Cursor / Codex) decomposes the request:
Recognizes query about authentication flows and routing.
Calls
list_routes(path="auth")to locate entrypoints.Calls
resolve_symbol("authenticate")to identify the service handler.Calls
trace_path(source_symbol="src/auth/views.py::login_view", target_symbol="src/auth/service.py::AuthService.authenticate").Calls
get_callees(canonical_id="src/auth/service.py::AuthService.authenticate").
3. CodeGraph interrogates the repository:
Returns exact route definitions (
POST /api/v1/auth/loginhandled bysrc/auth/views.py::login_view).Proves BFS execution path from
login_view$\to$AuthService.authenticatewith line evidence.Lists callees (
verify_password,create_jwt_token,log_audit_event) with file citations.
4. AI Agent synthesizes the answer:
"Authentication in your application begins at the
POST /api/v1/auth/loginendpoint handled bylogin_view. It invokesAuthService.authenticate, which validates credentials viaverify_passwordand generates a JWT token viacreate_jwt_token."
Installation & Usage
pip install 'codegraph-engine[mcp]'Supported Frameworks & Languages
CodeGraph currently provides framework-aware route discovery for:
FastAPI
Flask
Django
Express.js
It indexes repositories containing Python, JavaScript, and TypeScript code with cross-platform support across Linux, macOS, and Windows.
Configure in MCP Client (Claude Code, Cursor, Codex, Claude Desktop)
{
"mcpServers": {
"codegraph": {
"command": "codegraph",
"args": ["mcp", "serve"]
}
}
}CLI Inspection
# Index repository
codegraph index ./my-repo
# Search symbols
codegraph search "authenticate" -r ./my-repo
# Trace execution path
codegraph trace "login_view" -r ./my-repo
# Benchmark verification
codegraph benchmark -r ./my-repoAI Agent Usage
AI agents querying CodeGraph MCP should follow this deterministic lifecycle:
Initialize repository if required: Execute
codegraph initor verify index status.Check freshness: Verify
index.freshness == "FRESH". If stale, executecodegraph index.Resolve symbols: Use
resolve_symbolorcodegraph resolve-symbol <name>before querying graphs.Query relationships: Use
get_callers,get_callees, ortrace_pathwith canonical IDs.Use returned evidence: Cite source file and exact line spans from
{ file, start_line, end_line, type, canonical_id }.Handle UNKNOWN explicitly: If a target is not found, report UNKNOWN rather than hallucinating facts.
Handle AMBIGUOUS explicitly: When multiple candidates match, present the candidates or request qualification. Never guess.
Never infer unsupported repository facts: Only make assertions backed by static AST evidence.
CLI Path Defaults & Invocation
All repository inspection commands support optional repository paths defaulting to the current directory (.):
codegraph <command> [PATH] [--repo PATH]Examples:
# Equivalent commands resolving to the current directory:
codegraph status
codegraph status .
codegraph status -r .
codegraph status --repo .
# Indexing:
codegraph index
codegraph index .
codegraph index /path/to/repo
# Explicit symbol commands:
codegraph get-symbol AuthService
codegraph resolve-symbol duplicate_action
codegraph trace AuthService -d 2
codegraph search "authenticate"Machine-Readable Error Contract & Stable Error Codes
Expected operational failures emit structured JSON without raw Python tracebacks. Every error includes actionable agent recovery instructions:
{
"status": "error",
"error": {
"code": "INDEX_NOT_FOUND",
"message": "No CodeGraph index exists for this repository.",
"next_action": {
"command": "codegraph init",
"reason": "Initialize the repository before querying it."
}
}
}Stable Error Codes
Code | Meaning | Agent Next Action |
| Repository has not been indexed |
|
| Repository modified after last indexing |
|
| Missing CodeGraph configuration |
|
| Non-existent or invalid directory path | Check directory path |
| Path traversal attempt blocked | Keep paths within repo root |
| Symbol does not exist in AST index |
|
| Multiple candidates match query |
|
| Missing or empty required argument | Check command syntax |
| Traversal depth outside 1..5 range | Clamped to 1..5 |
| File is protected (e.g. | Check privacy boundaries |
| File contains syntax errors | Fix syntax and re-index |
| Language parser not supported | Check |
Verification & Release Gates
All releases are verified against rigorous gates:
Ruff: 0 lint errors
Mypy: 0 issues under strict typing
Pytest: 371 unit, integration, and contract tests passing
Benchmarks: 50 tasks across 10 categories:
Unsupported Claims: 0.0%
FACT Correctness: 100.0%
UNKNOWN Correctness: 98.0%
AMBIGUITY Correctness: 100.0%
STALE Handling: Verified
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Search indexed code, trace dependencies, assess change impact, and recall repository memory.
Deterministic context layer for your codebase: change impact, blast radius, answers with receipts.
Codebase graphs, caller impact analysis, and recorded project context for AI coding agents.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables LLM agents to efficiently understand and navigate a codebase by providing semantic search over symbols and a reference graph, replacing expensive grep/glob calls with structured tools like definition lookup, caller/callee queries, and change-impact analysis.3MIT
- FlicenseNot gradedqualityAmaintenanceProvides efficient code navigation and graph-based analysis for AI agents, enabling symbol resolution, callers, implementations, and type schemas with minimal token usage.-
- AlicenseNot gradedqualityBmaintenanceIndexes a codebase into a symbol-level graph and exposes tools for finding symbols, querying relationships, and assessing impact, letting AI coding agents answer structural questions in a single call within a token budget.90 npm4Apache 2.0
- AlicenseNot gradedqualityFmaintenanceEnables local-first codebase intelligence, allowing chat, search, and audit operations on any repository with file:line citations, and supports offline deterministic modes without an LLM.27 npm2MIT