code-review-graph: Local-First AI Context for MCP Clients
code-review-graph: Local-First AI Context for MCP Clients
The code-review-graph MCP Client provides a local-first code intelligence graph designed to optimize AI coding tools. It constructs a persistent map of your codebase, ensuring that AI models — particularly during code reviews and large-repository workflows — read only the most relevant information. This approach has demonstrated benchmarked context reductions, making AI interactions more efficient and focused.
Building and Updating Your Codebase Graph
At its core, code-review-graph builds a comprehensive map of your project. It supports a wide array of languages and notebook formats, including Python, JavaScript/TypeScript, Go, Rust, Java, C/C++, C#, Ruby, Kotlin, Swift, PHP, Scala, Solidity, Dart, R, Perl, Lua/Luau, Objective-C, shell scripts, Elixir, Zig, PowerShell, Julia, ReScript, GDScript, Nix, Verilog/SystemVerilog, SQL, Vue/Svelte SFCs, Astro files, Jupyter/Databricks (.ipynb), and Perl XS (.xs).
Once the initial graph is built, subsequent updates are incremental, re-parsing only changed files. This allows updates to complete in under two seconds, maintaining an up-to-date codebase representation with minimal overhead. For continuous integration, code-review-graph offers auto-update hooks and a watch mode, enabling the graph to refresh automatically on file saves or supported commit hooks.
Leveraging the Intelligence Graph for AI Workflows
The persistent graph enables several advanced analysis capabilities that directly benefit AI coding tools:
- Blast-radius analysis: Identify functions, classes, and files likely affected by a specific change.
- Hub & bridge detection: Pinpoint highly connected nodes and architectural chokepoints using betweenness centrality.
- Surprise scoring: Detect unexpected coupling, such as cross-community, cross-language, or peripheral-to-hub edges.
- Knowledge gap analysis: Uncover isolated nodes, untested hotspots, thin communities, and structural weaknesses within the codebase.
For enhanced semantic understanding, code-review-graph can integrate optional vector embeddings. These embeddings can be generated via sentence-transformers, Google Gemini, MiniMax, or any OpenAI-compatible endpoint, including real OpenAI, Azure, new-api, LiteLLM, vLLM, or LocalAI.
Developers can also interact with the graph directly through an interactive D3.js force-directed visualization. This interface includes search functionality, community legend toggles, and degree-scaled nodes for visual exploration.
Configuring with MCP Clients like Claude Code
When integrating code-review-graph with an MCP Client such as Claude Code, specific configuration is necessary, especially for Windows users. If you encounter Invalid JSON: EOF while parsing or MCP error -32000: Connection closed, ensure fastmcp is updated to at least 3.2.4+.
The issue often stems from the cmd /c wrapper on Windows. Instead, configure your ~/.claude.json to execute the .exe directly and pass the PYTHONUTF8 environment variable:
"code-review-graph": {
"command": "C:\\path\\to\\your\\venv\\Scripts\\code-review-graph.exe",
"args": ["serve", "--repo", "C:\\path\\to\\your\\project"],
"env": { "PYTHONUTF8": "1" }
}This configuration ensures the MCP client can properly communicate with code-review-graph, enabling your AI tools to leverage its context reduction and code intelligence capabilities effectively.