CGRAPH
MCP Integration
cgraph-mcp exposes the graph to coding agents over the Model Context Protocol
(MCP). Its tool calls route through the same daemon operation handler as the thin
client, so an agent gets exactly the semantics the CLI does.
The protocol
cgraph-mcp speaks newline-delimited JSON-RPC 2.0 over stdio, protocol
version 2024-11-05. It implements the standard handshake and tool methods:
JSON-RPC 2.0 over stdio (protocol 2024-11-05)
| Method | Purpose |
|---|---|
initialize | Handshake and capability exchange. |
notifications/initialized | Client signals it's ready. |
tools/list | Enumerate the available tools. |
tools/call | Invoke a tool. |
Invalid JSON receives a JSON-RPC parse error response rather than crashing the server.
The request flow
agent ── JSON-RPC (stdio) ──> cgraph-mcp ──> daemon operation handler ──> graph
^ |
└──────────────────── JSON result ──────────────────────────────────────┘The eight tools
graph_query
Find nodes matching a query.
graph_explain
Explain a node and its role.
graph_impact
The transitive blast radius of a change.
graph_path
The shortest path between two symbols.
graph_context
A packed, budgeted neighborhood for the agent.
graph_update
Fold in changes / trigger a rescan.
graph_status
Daemon and graph health.
graph_shutdown
Stop the daemon.
How it finds the project and the daemon
cgraph-mcp resolves the project root in priority order:
--root flag > CLAUDE_PROJECT_DIR env var > working directoryand discovers the daemon in priority order:
--daemon <path> > CGRAPH_DAEMON_PATH env var > graphd next to the binary > build-tree layoutThis is why cgraph-mcp works from an agent with minimal configuration: an agent
that sets CLAUDE_PROJECT_DIR (like Claude Code) and ships graphd next to the
binary needs no flags at all.
Where to go next
- AI Agent Integration — registering CGraph with Claude Code, Codex, and Cursor.