# How the MCP Server in Code-Review-Graph Integrates with Claude Code and Cursor

> Discover how the MCP server in code-review-graph integrates with Claude Code and Cursor. Learn about FastMCP wrapper and graph-analysis tools for seamless AI coding.

- Repository: [Tirth Kanani/code-review-graph](https://github.com/tirth8205/code-review-graph)
- Tags: how-to-guide
- Published: 2026-07-26

---

**The MCP server in code-review-graph acts as a FastMCP wrapper that exposes graph-analysis tools via JSON-RPC, with platform-specific skill files enabling direct integration with Claude Code and Cursor through stdio or HTTP transport.**

The `tirth8205/code-review-graph` repository implements a **Model Context Protocol (MCP) server** that bridges AI coding assistants with repository-level code analysis. By wrapping FastMCP functionality in [`code_review_graph/main.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py), the system exposes graph traversal, diff analysis, and search capabilities through a standardized JSON-RPC interface that Claude Code and Cursor consume via auto-generated configuration files.

## MCP Server Architecture

The integration centers on **FastMCP**, a Python implementation of the MCP specification that handles tool registration and request dispatching. In [`code_review_graph/main.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py), the server initializes with a pluggable transport layer supporting both **stdio** (for local tool communication) and **HTTP** (for remote instances).

```python

# File: code_review_graph/main.py

from fastmcp import FastMCP

def main(repo_root: str | None = None, transport: str = "stdio"):
    mcp = FastMCP()
    # Register graph tools (search, diff, etc.)

    mcp.register_tool("graph.search", search_tool)
    # Run the server – stdio for Claude/Cursor, HTTP for remote access

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

```

The server registers tools defined in `code_review_graph/tools/*` that perform actual graph analysis, then listens for JSON-RPC requests from connected AI clients.

## Claude Code Integration

Claude Code integration relies on **skill descriptors** generated by [`code_review_graph/skills.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/skills.py). When running `crg install-skills`, the `generate_claude_code_skills()` function (lines 684-720) creates two artifacts in the repository's `.claude/skills/` directory:

- **SKILL.md**: Documentation describing available graph-analysis capabilities
- **.mcp.json**: Configuration pointing to `crg serve --transport stdio` as the entry point

```python

# File: code_review_graph/skills.py

def generate_claude_code_skills(repo_root: str) -> Mapping[str, str]:
    # Write SKILL.md with description

    # Write .mcp.json pointing to the MCP server

    mcp_config = {
        "command": ["python", "-m", "code_review_graph.main", 
                   "--transport", "stdio", "--repo-root", repo_root]
    }
    # Returns mapping of file paths to content

    return {".claude/skills/graph/.mcp.json": json.dumps(mcp_config), ...}

```

When Claude Code launches, it discovers the [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json) descriptor, starts the MCP server in stdio mode, and issues requests like `graph.search` or `graph.diff` directly against the live repository graph.

## Cursor Integration

For Cursor, the integration uses **hook files** installed in the user's home directory. The `generate_cursor_hooks()` function (lines 1387-1453) in [`skills.py`](https://github.com/tirth8205/code-review-graph/blob/main/skills.py) produces a `~/.cursor/mcp.json` configuration and accompanying shell scripts that conform to Cursor's hooks protocol.

```python

# File: code_review_graph/skills.py

def generate_cursor_hooks(repo_root: str) -> Mapping[str, str]:
    hooks_json = {
        "version": 1,
        "command": ["python", "-m", "code_review_graph.main", 
                   "--transport", "stdio"]
    }
    # Shell script wrapper for Cursor's stdin/stdout expectations

    script = "#!/bin/sh\nexec python -m code_review_graph.main --transport stdio"
    return {"mcp.json": json.dumps(hooks_json), "hook.sh": script}

```

The CLI command `crg install-cursor` (implemented in [`code_review_graph/cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/cli.py), lines 329-335) writes these files to `~/.cursor/`. When Cursor opens a project, it launches the MCP server, sends JSON context via stdin, and receives analysis results through stdout.

## Installation Workflow

Setting up the **MCP server** for either tool follows a three-step pattern:

1. **Install the package**: `pip install -e .` or equivalent to make `crg` available
2. **Generate platform files**: 
   - **Claude Code**: Run `crg install-skills` to create `.claude/skills/` descriptors
   - **Cursor**: Run `crg install-cursor` to populate `~/.cursor/mcp.json`
3. **Launch AI tool**: Claude Code or Cursor auto-detects the configuration and starts the server via `python -m code_review_graph.main`

Both integrations use the **same core server implementation**; only the surrounding configuration files differ to match each tool's discovery mechanism.

## Code Example: Complete Integration Setup

```python

# Starting the MCP server manually (used by both platforms)

# Terminal command:

# python -m code_review_graph.main --transport stdio

# Or via CLI wrapper:

# crg serve --transport stdio

# Programmatic skill generation for Claude Code:

from code_review_graph.skills import generate_claude_code_skills
skills = generate_claude_code_skills("/path/to/repo")

# Writes .claude/skills/graph-analysis/SKILL.md

# Writes .claude/skills/graph-analysis/.mcp.json

# Cursor hook installation:

from code_review_graph.cli import install_cursor_hooks
install_cursor_hooks()  # Writes ~/.cursor/mcp.json

```

## Summary

- The **MCP server** in [`code_review_graph/main.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py) wraps FastMCP to provide JSON-RPC access to repository graph analysis.
- **Claude Code** integration uses `.claude/skills/` directories containing [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json) descriptors generated by `generate_claude_code_skills()`.
- **Cursor** integration relies on `~/.cursor/mcp.json` and shell scripts created by `generate_cursor_hooks()` and installed via [`cli.py`](https://github.com/tirth8205/code-review-graph/blob/main/cli.py).
- Both platforms communicate via **stdio transport**, allowing the AI tools to spawn the server process and exchange JSON-RPC messages directly.
- The CLI commands `crg install-skills` and `crg install-cursor` automate the creation of platform-specific configuration files.

## Frequently Asked Questions

### What transport protocols does the MCP server support?

The server supports **stdio** for direct integration with Claude Code and Cursor, and **HTTP** for remote access or web-based tools. Specify the transport via the `--transport` flag when launching [`code_review_graph/main.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py) or using the `crg serve` command.

### How do I install the Claude Code integration?

Run `crg install-skills` from your repository root. This executes `generate_claude_code_skills()` which creates [`.claude/skills/graph-analysis/SKILL.md`](https://github.com/tirth8205/code-review-graph/blob/main/.claude/skills/graph-analysis/SKILL.md) and [`.mcp.json`](https://github.com/tirth8205/code-review-graph/blob/main/.mcp.json) files. Claude Code automatically discovers these files when indexing the repository and starts the MCP server via `python -m code_review_graph.main --transport stdio`.

### Can I use the MCP server with other AI tools?

Yes. Any AI assistant supporting the MCP over stdio or HTTP can connect to the server. You would need to generate the appropriate configuration files (similar to those created for Claude Code or Cursor) that point to `python -m code_review_graph.main` as the command entry point.

### What is the difference between the Claude Code and Cursor integrations?

**Claude Code** uses repository-local `.claude/skills/` directories with Markdown documentation and JSON descriptors, while **Cursor** uses global configuration in `~/.cursor/mcp.json`. Both ultimately launch the same FastMCP server in [`code_review_graph/main.py`](https://github.com/tirth8205/code-review-graph/blob/main/code_review_graph/main.py), but Claude Code expects skill-specific metadata whereas Cursor uses a centralized hook protocol.