MCP Integration

MCP Integration#

claude-review supports the Model Context Protocol (MCP) for connecting external tools to the review flow. MCP servers expose tools that the LLM can invoke during a review, enabling capabilities like filesystem access, database queries, or custom analysis.

How It Works#

  1. At startup (or when a review begins), claude-review connects to all configured MCP servers.

  2. It calls initialize and then tools/list to discover available tools.

  3. Tool definitions are converted to the LLM’s tool format and included in the review prompt.

  4. When the LLM calls a tool, the request is routed to the appropriate MCP server via tools/call.

  5. The tool result is returned to the LLM for the next iteration of the review loop.

Tool names are prefixed with mcp_{server_name}_ to avoid collisions between servers.

The agentic loop runs for up to 10 turns by default. Each turn allows the LLM to call tools and receive results before producing its next response.

Transport Types#

stdio#

Launches a subprocess and communicates via JSON-RPC 2.0 over stdin/stdout.

toml
[[mcp.servers]]
name = "filesystem"
type = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
enabled = true

[mcp.servers.env]
NODE_ENV = "production"
Field
Type
Description
commandstringExecutable to launch
argsstring[]Command-line arguments
envmapEnvironment variables for the subprocess

http#

Sends JSON-RPC 2.0 requests over HTTP POST.

toml
[[mcp.servers]]
name = "analysis"
type = "http"
url = "https://mcp.internal/jsonrpc"
enabled = true

[mcp.servers.headers]
Authorization = "Bearer tok_..."
Field
Type
Description
urlstringHTTP endpoint URL
headersmapExtra HTTP headers on every request

sse#

Connects to a Server-Sent Events endpoint, reads the endpoint event to discover the POST URL, then sends JSON-RPC 2.0 requests over HTTP POST.

toml
[[mcp.servers]]
name = "realtime"
type = "sse"
url = "https://mcp.internal/sse"
enabled = true

[mcp.servers.headers]
Authorization = "Bearer tok_..."
Field
Type
Description
urlstringSSE endpoint URL
headersmapExtra HTTP headers

The SSE stream must emit an event with event: endpoint whose data is the URL (absolute or relative) to send JSON-RPC POST requests to.

websocket#

Communicates over a persistent WebSocket connection.

toml
[[mcp.servers]]
name = "ws-tools"
type = "websocket"   # or "ws"
url = "wss://mcp.internal/ws"
enabled = true
Field
Type
Description
urlstringWebSocket URL (ws:// or wss://)

Responses are matched to requests by JSON-RPC id. A 60-second timeout applies per request.

Common Fields#

All transport types share these fields:

Field
Type
Default
Description
namestringUnique identifier (used as tool name prefix)
enabledbooltrueSet to false to skip this server

Configuration Example#

Multiple servers of different transport types can be configured together:

toml
[[mcp.servers]]
name = "fs"
type = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/data"]

[[mcp.servers]]
name = "search"
type = "http"
url = "https://search.internal/mcp"

[mcp.servers.headers]
X-API-Key = "key_..."

[[mcp.servers]]
name = "monitor"
type = "websocket"
url = "wss://monitor.internal/mcp"

Error Handling#

  • If a server fails to connect during initialization, the error is logged and the review proceeds without that server’s tools.

  • If a tool call fails, the error is returned to the LLM as a tool result with is_error: true. The LLM can decide how to proceed.

  • All MCP connections are closed after the review completes.