How Code-Review-Graph MCP Server Integration Works with Cursor and Claude Code

The code-review-graph MCP server leverages FastMCP to expose graph analysis capabilities via JSON-RPC, while platform-specific skill generators in skills.py create the configuration descriptors that enable Claude Code and Cursor to spawn and communicate with the server through stdio or HTTP transports.

Code-review-graph is an open-source tool that transforms code review data into a queryable knowledge graph. Its MCP server integration allows AI coding assistants to programmatically search, diff, and analyze repository history without exhausting context windows, using the Model Context Protocol (MCP) for standardized tool calling.

MCP Server Architecture and Entry Points

The integration centers on a FastMCP wrapper defined in code_review_graph/main.py. This module initializes the MCP server, registers graph analysis tools, and manages transport layers.

The server supports two transport modes:

  • stdio: Reads JSON-RPC requests from stdin and writes responses to stdout, used by Cursor and Claude Code for local integration
  • HTTP: Exposes the same functionality over network endpoints

When launched via python -m code_review_graph.main or the crg serve CLI command, the server registers tools such as graph.search and graph.diff that perform repository analysis.

Claude Code Integration via Skill Files

For Claude Code compatibility, code_review_graph/skills.py generates dedicated skill descriptors inside the repository. Specifically, lines 684-720 implement generate_claude_code_skills(), which creates two artifacts:

The .mcp.json file points to the server entry point, typically invoking crg serve --transport stdio. When Claude Code loads the repository, it discovers this descriptor, spawns the MCP server as a subprocess, and routes tool requests through JSON-RPC messages.

Cursor Integration via Hooks

Cursor integration follows a similar pattern but uses the Cursor hooks protocol. The generate_cursor_hooks() function in code_review_graph/skills.py (lines 1387-1453) produces:

  • ~/.cursor/mcp.json: Global configuration specifying the command to launch the MCP server
  • Accompanying shell scripts: Wrapper scripts that initialize the stdio communication channel

The CLI module code_review_graph/cli.py handles installation through lines 329-335, copying these artifacts into the user's ~/.cursor directory when running crg install-cursor or crg install-skills.

When Cursor opens a project configured with these hooks, it executes the specified command—usually python -m code_review_graph.main --transport stdio—and establishes a persistent JSON-RPC connection over the process's standard input and output streams.

Installation and Configuration Flow

Deploying the MCP integration requires three steps:

  1. Start the server: Run crg serve or invoke the Python module directly to verify the FastMCP instance loads correctly.
  2. Generate platform files: Execute crg install-skills to write Claude Code descriptors into .claude/skills/, or crg install-cursor to populate ~/.cursor/mcp.json.
  3. AI client handshake: Open the repository in Claude Code or Cursor; the editor reads the generated JSON descriptors, spawns the MCP client, and begins dispatching requests like graph.diff or graph.search.

Technical Implementation

The server-side tool registration and platform-specific generators work together to bridge the AI clients with the graph analysis engine:


# MCP server initialization in code_review_graph/main.py

from fastmcp import FastMCP

def main(repo_root: str | None = None, transport: str = "stdio"):
    mcp = FastMCP()
    # Register graph tools for AI consumption

    mcp.register_tool("graph.search", search_tool)
    mcp.register_tool("graph.diff", diff_tool)
    # Begin listening on stdio or HTTP

    mcp.serve(transport=transport, repo_root=repo_root)

The Claude Code skill generator constructs the necessary metadata files:


# From code_review_graph/skills.py (lines 684-720)

def generate_claude_code_skills(repo_root: str):
    # Creates .claude/skills/.../SKILL.md with tool descriptions

    # Creates .claude/skills/.../.mcp.json with server configuration

    mcp_descriptor = {
        "command": ["python", "-m", "code_review_graph.main", 
                   "--transport", "stdio", "--repo-root", repo_root]
    }
    # Files written to .claude/skills/code-review-graph/

For Cursor, the generator produces compatible JSON and shell wrappers:


# From code_review_graph/skills.py (lines 1387-1453)

def generate_cursor_hooks(repo_root: str):
    hooks_config = {
        "version": 1,
        "command": ["python", "-m", "code_review_graph.main", 
                   "--transport", "stdio"]
    }
    # Shell script handles stdin/stdout piping for Cursor protocol

    install_path = "~/.cursor/mcp.json"

The CLI installation commands automate the file placement:


# From code_review_graph/cli.py (lines 329-335)

def install_cursor_hooks():
    hooks = generate_cursor_hooks(os.getcwd())
    cursor_dir = Path.home() / ".cursor"
    cursor_dir.mkdir(exist_ok=True)
    # Writes mcp.json and hook scripts to ~/.cursor/

Summary

  • FastMCP backend: The server in code_review_graph/main.py exposes graph analysis via JSON-RPC over stdio or HTTP.
  • Claude Code support: skills.py generates .claude/skills/ descriptors including .mcp.json files that define how Claude spawns and connects to the server.
  • Cursor support: The same module generates ~/.cursor/mcp.json configurations and shell hooks following the Cursor hooks protocol.
  • Unified tools: Both AI clients access the same underlying Python tools (search, diff) through the standardized MCP interface.
  • CLI automation: crg install-skills and crg install-cursor in cli.py automate the configuration file deployment.

Frequently Asked Questions

What transport protocols does the code-review-graph MCP server support?

The server supports stdio and HTTP transports. The stdio mode is used for local AI editor integration (Cursor and Claude Code), while HTTP mode enables remote or service-based deployments. You specify the transport using the --transport flag when launching code_review_graph/main.py.

Where does the MCP integration store its configuration files?

Claude Code configurations are stored locally in the repository under .claude/skills/code-review-graph/, containing SKILL.md documentation and .mcp.json descriptors. Cursor configurations are stored globally in the user's home directory at ~/.cursor/mcp.json, installed via the CLI commands in code_review_graph/cli.py.

How does the server handle concurrent requests from AI coding tools?

FastMCP handles request dispatching asynchronously. Each JSON-RPC request from Claude Code or Cursor is routed to the appropriate tool function (e.g., search_tool or diff_tool) defined in the tools directory, with results returned as JSON responses. The server maintains state through the initialized graph connection passed via repo_root.

Can I use the MCP server with AI tools other than Claude Code and Cursor?

Yes. Because the implementation uses the FastMCP framework with standard JSON-RPC over stdio, any AI assistant or editor that supports the Model Context Protocol can connect to code_review_graph. You would need to generate the appropriate configuration descriptor for your specific tool, following the pattern established in code_review_graph/skills.py.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →