clangd-mcp
Provides MCP tools for querying clangd/LLVM C/C++ code intelligence, including symbol search, hover, definitions, references, call hierarchies, diagnostics, and AST inspection. Supports local index files or LLVM's public remote index (clangd-index.llvm.org) for code navigation and analysis.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@clangd-mcpfind all references to ASTContext in /home/me/llvm"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
clangd-mcp
Containerized MCP server: a thin interface from agents to
clangd. The image ships clangd,
clangd-indexer, and clangd-index-server (the same remote-index stack
as clangd-index.llvm.org).
Use it to build a static index, optionally host that index over
gRPC, and serve clangd queries over MCP — either from a local
--index-file or from a remote server (ours or LLVM's).
v1 keeps host paths as-is: bind-mount the workspace at the same absolute path inside the container.
This package does not implement review or diff workflows. Those belong in the caller.
Commands
clangd-mcp serve --workspace <dir> --index-file <file>
clangd-mcp serve --workspace <dir> --remote-index <host:port>
clangd-mcp index --compile-commands <file> --output <file>
clangd-mcp host --index-file <file> --project-root <dir> [--port 50051]serve requires exactly one of --index-file or --remote-index.
--mount-point defaults to --workspace. Remote-index is passed to
clangd as --remote-index-address and --project-root (GitHub clangd
builds). Index build and hosting are container commands, not MCP tools.
Related MCP server: clangd-mcp-server
Docker
docker build -t clangd-mcp .
# Build an index (same absolute paths as the host).
docker run --rm \
-v /home/me/proj:/home/me/proj \
clangd-mcp index \
--compile-commands /home/me/proj/build/compile_commands.json \
--output /home/me/proj/.clangd-mcp/index.idx
# Optional: share that index over gRPC.
docker run --rm -p 50051:50051 \
-v /home/me/proj:/home/me/proj \
clangd-mcp host \
--index-file /home/me/proj/.clangd-mcp/index.idx \
--project-root /home/me/proj
# MCP over stdio (local file).
docker run -i --rm \
-v /home/me/proj:/home/me/proj \
clangd-mcp serve \
--workspace /home/me/proj \
--index-file /home/me/proj/.clangd-mcp/index.idx
# Or attach clangd to LLVM's public remote index.
docker run -i --rm \
-v /home/me/llvm:/home/me/llvm \
clangd-mcp serve \
--workspace /home/me/llvm \
--remote-index clangd-index.llvm.org:5900Cursor / Claude Code (stdio):
{
"mcpServers": {
"clangd": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-v", "/home/me/proj:/home/me/proj",
"clangd-mcp", "serve",
"--workspace", "/home/me/proj",
"--index-file", "/home/me/proj/.clangd-mcp/index.idx"
]
}
}
}Without Docker, npm run build && node dist/src/main.js serve ... if
clangd is on PATH.
MCP tools
search_symbols, get_symbol_info, get_hover, get_definition,
get_declaration, get_type_definition, find_references,
find_implementations, get_callers, get_callees,
get_type_hierarchy, get_file_symbols, get_diagnostics,
switch_source_header, get_ast, clangd_status.
Paths in tool arguments are absolute workspace paths (the same paths stored in the index). Positions are 0-based UTF-8.
CI
GitHub Actions (.github/workflows/ci.yml) runs unit tests, builds the
image, indexes test/fixture inside that image, then drives every MCP
tool over docker run -i … serve. A second pass hosts the index with
clangd-index-server and repeats the tool checks through
--remote-index.
See PLAN.md for the design.
This server cannot be deployed
Maintenance
Related MCP Connectors
Lean 4 MCP server: compile, prove theorems, and formalize math with Mathlib.
Hosted code graph over MCP: exact callers, dependencies, and cross-repo blast radius for AI agents.
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Agent-driven search: build, import, tune, search, and score result quality — all over MCP.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI clients to perform local code search, indexing, and analysis across Java, JavaScript/TypeScript, .NET/C#, and Python projects through the MCP protocol.1Apache 2.0
- AlicenseAqualityFmaintenanceProvides C++ code intelligence tools for AI agents via the Model Context Protocol, enabling symbol navigation, type information, and diagnostics.949Mozilla Public 2.0
- AlicenseAqualityDmaintenanceMCP server for C/C++ code analysis using clangd and clang tools, providing diagnostics, symbol search, include analysis, function listing, and code formatting.5MIT
- AlicenseAqualityCmaintenanceProvides CodeQL language intelligence to AI agents via MCP, enabling completions, hover, definitions, references, diagnostics, formatting, and in-memory file updates for QL code.7MIT