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#
At startup (or when a review begins), claude-review connects to all configured MCP servers.
It calls initialize and then tools/list to discover available tools.
Tool definitions are converted to the LLM’s tool format and included in the review prompt.
When the LLM calls a tool, the request is routed to the appropriate MCP server via tools/call.
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.
[[mcp.servers]]
name = "filesystem"
type = "stdio"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
enabled = true
[mcp.servers.env]
NODE_ENV = "production"
| command | string | Executable to launch |
| args | string[] | Command-line arguments |
| env | map | Environment variables for the subprocess |
http#
Sends JSON-RPC 2.0 requests over HTTP POST.
[[mcp.servers]]
name = "analysis"
type = "http"
url = "https://mcp.internal/jsonrpc"
enabled = true
[mcp.servers.headers]
Authorization = "Bearer tok_..."
| url | string | HTTP endpoint URL |
| headers | map | Extra 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.
[[mcp.servers]]
name = "realtime"
type = "sse"
url = "https://mcp.internal/sse"
enabled = true
[mcp.servers.headers]
Authorization = "Bearer tok_..."
| url | string | SSE endpoint URL |
| headers | map | Extra 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.
[[mcp.servers]]
name = "ws-tools"
type = "websocket" # or "ws"
url = "wss://mcp.internal/ws"
enabled = true
| url | string | WebSocket 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:
| name | string | – | Unique identifier (used as tool name prefix) |
| enabled | bool | true | Set to false to skip this server |
Configuration Example#
Multiple servers of different transport types can be configured together:
[[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.