Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

clangd-mcp

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.

Build

npm install
npm run build

Register with Claude Code

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.

Tools

  • 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 by workspace_symbol.
  • definition(file, line, column) — definition location(s).

Notes

  • 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 initialize on 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/clangd and they'll read the same store.

Extending

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages