An MCP server that fronts a dedicated clangd instance, exposing semantic
C/C++ queries to Claude Code: workspace_symbol, find_references,
definition. Index-backed, scope- and overload-aware — not textual grep.
Runs its own clangd subprocess pointed at your project's
compile_commands.json, so it's fully separate from CLion Nova or any
editor-hosted LSP. Point clangd's cache dir at the shared one and it reuses
the on-disk index instead of re-indexing.
npm install
npm run build
claude mcp add clangd \
-e PROJECT_ROOT=/path/to/babbage \
-e CLANGD=clangd-22 \
-- node /path/to/clangd-mcp/dist/index.js
PROJECT_ROOT is the directory containing compile_commands.json.
CLANGD defaults to clangd on PATH; set it to your self-compiled 22.x.
workspace_symbol(query)— resolve a name to its symbols (kind + def location). Use first; no seed position needed.find_references(file, line, column, include_declaration?)— every resolved reference. 1-based line/column as printed byworkspace_symbol.definition(file, line, column)— definition location(s).
- LSP positions are 0-based internally; the tools present and accept 1-based line/column to match editor/grep conventions.
- First query after startup may return partial results while the background
index warms; the server issues
initializeon boot to get ahead of it. - Per-request 20s timeout guards against a wedged clangd.
- To share the index cache, launch your other clients with
--index-file/ the same.cache/clangdand they'll read the same store.
Adding a tool is one _req line in clangd.ts plus a registerTool block
in index.ts. Candidates: textDocument/typeDefinition,
textDocument/implementation, callHierarchy/incomingCalls,
textDocument/documentSymbol.