Clangd MCP
Experimental implementation of a MCP for Claude Code that lets it connect to a language server like clangd.
What is Clangd MCP?
Clangd MCP is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to experimental implementation of a mcp for claude code that lets it connect to a language server like clangd.
Experimental implementation of a MCP for Claude Code that lets it connect to a language server like clangd.
This server falls under the Developer Tools and Coding Agents categories on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- Experimental implementation of a MCP for Claude Code that le
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx clangdConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Clangd MCP
The Clangd MCP Server bridges Claude Code to the clangd language server, exposing rich C and C++ code-intelligence capabilities directly inside your AI workflow. It provides nine distinct tools covering symbol lookups, reference finding, type queries, workspace-wide search, call graph analysis, and compiler diagnostics — all driven by the project's compile_commands.json. Developers working on large C/C++ codebases can use this server to get accurate semantic answers from the real compiler toolchain rather than relying on AI inference alone.
Prerequisites
- Node.js 18 or later installed
- clangd binary available on your PATH (install via your OS package manager or LLVM releases)
- A C or C++ project with a compile_commands.json file (generated by CMake or GN)
- An MCP-compatible client such as Claude Code or Claude Desktop
Clone and build the server
Clone the repository, install Node dependencies, compile the TypeScript source, and link the binary globally so it is available as clangd-mcp-server on your PATH.
git clone https://github.com/felipeerias/clangd-mcp-server.git
cd clangd-mcp-server
npm install && npm run build && npm linkGenerate compile_commands.json for your project
clangd needs a compilation database to resolve includes and symbols. For CMake projects pass the export flag at configure time; for GN projects use gn gen with the export flag.
# CMake
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /path/to/source
# GN
gn gen out/Default && gn gen --export-compile-commands out/DefaultConfigure Claude Code to use the server
Add the server to your Claude Code MCP configuration file. Set PROJECT_ROOT to the directory containing compile_commands.json. Optionally set CLANGD_PATH if clangd is not on your default PATH.
{
"mcpServers": {
"clangd": {
"command": "clangd-mcp-server",
"env": {
"PROJECT_ROOT": "/path/to/your/cpp/project",
"CLANGD_PATH": "/usr/bin/clangd",
"LOG_LEVEL": "info"
}
}
}
}Or add via Claude Code CLI
You can register the server directly from the terminal using the claude mcp add command instead of editing the JSON file manually.
claude mcp add clangd-mcp-server clangd-mcp-serverVerify the server starts correctly
Restart your MCP client and confirm that the clangd server appears in the list of connected MCP servers. You should see nine tools available: definition lookup, reference finding, type info, workspace symbol search, virtual method discovery, file outline, diagnostics, call hierarchy, and class hierarchy.
Clangd MCP Examples
Client configuration (claude_desktop_config.json)
Full configuration block for Claude Desktop or Claude Code with the clangd MCP server pointing at a CMake project.
{
"mcpServers": {
"clangd": {
"command": "clangd-mcp-server",
"env": {
"PROJECT_ROOT": "/home/user/projects/myapp",
"CLANGD_PATH": "/usr/bin/clangd",
"CLANGD_ARGS": "--background-index",
"LOG_LEVEL": "warn"
}
}
}
}Prompts to try
Example prompts that exercise the server's code-intelligence tools against your C/C++ codebase.
- "Find all references to the ConnectionManager class in this project"
- "What is the type of the 'config' parameter in the parseOptions function?"
- "Show me the call hierarchy for the main() function"
- "List all compiler diagnostics (errors and warnings) in network.cpp"
- "Search the workspace for symbols matching 'Socket'"
- "Show the class hierarchy rooted at BaseHandler"Troubleshooting Clangd MCP
Server starts but returns 'no compile_commands.json found' errors
Ensure PROJECT_ROOT points to the directory that contains compile_commands.json, not the build directory. For CMake builds, copy or symlink compile_commands.json from the build directory to the source root, or set PROJECT_ROOT to the build directory.
clangd-mcp-server command not found after npm link
Make sure your global npm bin directory is on your PATH. Run `npm config get prefix` to find the prefix, then add `<prefix>/bin` to your PATH. Alternatively, run the server with its full path: `node /path/to/clangd-mcp-server/dist/index.js`.
Symbol lookups return no results for system headers
Pass additional clangd resource directory flags via CLANGD_ARGS, for example `--resource-dir=/usr/lib/llvm-15/lib/clang/15`. Also ensure your compile_commands.json includes the correct -I and -isystem flags that your build system uses.
Frequently Asked Questions about Clangd MCP
What is Clangd MCP?
Clangd MCP is a Model Context Protocol (MCP) server that experimental implementation of a mcp for claude code that lets it connect to a language server like clangd. It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Clangd MCP?
Follow the installation instructions on the Clangd MCP GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Clangd MCP?
Clangd MCP works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Clangd MCP free to use?
Yes, Clangd MCP is open source and available under the MPL-2.0 license. You can use it freely in both personal and commercial projects.
Clangd MCP Alternatives — Similar Developer Tools Servers
Looking for alternatives to Clangd MCP? Here are other popular developer tools servers you can use with Claude, Cursor, and VS Code.
Ecc
★ 188.2kThe agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
Javaguide
★ 155.8kJava 面试 & 后端通用面试指南,覆盖计算机基础、数据库、分布式、高并发、系统设计与 AI 应用开发
Gemini CLI
★ 104.5kA secure MCP server that wraps the Google Gemini CLI, allowing clients to query Gemini models using local OAuth sessions without requiring an API key. It provides tools for model interaction and diagnostics with built-in protection against command in
Awesome MCP Servers
★ 87.3k⭐ Curated list of Model Context Protocol (MCP) servers - tools that extend Claude Desktop, Cursor, Windsurf, and other MCP clients with custom capabilities.
MCP Servers
★ 86.0kModel Context Protocol Servers
CC Switch
★ 77.5kA cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Gemini CLI & Hermes Agent. Only official website: ccswitch.io
Browse More Developer Tools MCP Servers
Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Clangd MCP in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Clangd MCP?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.