Clangd MCP

v1.0.0Developer Toolsstable

Experimental implementation of a MCP for Claude Code that lets it connect to a language server like clangd.

clangdmcpai-integration
Share:
33
Stars
0
Downloads
0
Weekly
0/5

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

Connect Claude Code to clangd language server.
Enable C/C++ code intelligence in AI editors.
Provide type checking and code completion.
felipeerias

Maintainer

LicenseMPL-2.0
Languagetypescript
Versionv1.0.0
UpdatedMay 16, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx clangd

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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 link
2

Generate 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/Default
3

Configure 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"
      }
    }
  }
}
4

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-server
5

Verify 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.

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.

Quick Config Preview

{ "mcpServers": { "clangd": { "command": "npx", "args": ["-y", "clangd"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides