Skip to main content
Glama
clangd-mcp

clangd-mcp

by ibuildrun

clangd-mcp

MCP server for C/C++ code analysis using clangd and clang tools. Provides diagnostics, symbol search, include analysis, function listing, and code formatting.

Features

  • check_file — run clangd diagnostics on a C/C++ file (errors, warnings)

  • find_symbol — search for symbol definitions across source files (regex)

  • get_includes — list and analyze #include directives

  • list_functions — extract function/method declarations from a file

  • clang_format — format code using clang-format (dry-run or in-place)

Falls back to compiler syntax checking (clang++, g++, MSVC) if clangd is not available.

Related MCP server: C++ MCP Server

Requirements

  • Python 3.10+

  • Optional: clangd, clang-format, ctags (for full functionality)

  • Works with fallback even without clang tools installed

Installation

pip install clangd-mcp

Or from source:

git clone https://github.com/ibuildrun/clangd-mcp.git
cd clangd-mcp
pip install -e .

MCP Configuration

Add to your .kiro/settings/mcp.json:

{
  "mcpServers": {
    "clangd": {
      "command": "clangd-mcp",
      "disabled": false
    }
  }
}

Or with uvx:

{
  "mcpServers": {
    "clangd": {
      "command": "uvx",
      "args": ["clangd-mcp"],
      "disabled": false
    }
  }
}

Usage Examples

> check_file "src/game/client/components/menus.cpp" "build"
> find_symbol "RenderBackground" "src"
> get_includes "src/game/client/ui.h"
> list_functions "src/game/client/components/menus.cpp"
> clang_format "src/game/client/ui.cpp" "file" true

License

MIT

Available Tools

4 tools
clang_formatA

Format a C/C++ file using clang-format.

Args: file_path: Path to the C/C++ source file. style: Formatting style (file, llvm, google, chromium, mozilla, webkit). dry_run: If True, show diff without modifying file. If False, format in place.

Inputs: file_path (required), style, dry_run. Returns: result

find_symbolA

Search for a symbol (function, class, variable) definition across C/C++ files.

Args: symbol: Symbol name to search for (supports regex). directory: Directory to search in. extensions: Comma-separated file extensions to search.

Inputs: symbol (required), directory, extensions. Returns: result

get_includesB

List all #include directives in a C/C++ file and check if they resolve.

Args: file_path: Path to the C/C++ source file.

Inputs: file_path (required). Returns: result

list_functionsB

Extract function/method declarations and definitions from a C/C++ file.

Args: file_path: Path to the C/C++ source file.

Inputs: file_path (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: symbol search, include resolution, function listing, and formatting. There is no overlap or ambiguity.

    Naming Consistency4/5

    Most tools follow verb_noun pattern (find_symbol, get_includes, list_functions), but clang_format deviates slightly by starting with a noun. Overall, names are clear and predictable.

    Tool Count4/5

    Four tools is a small but reasonable set for a focused C/C++ analysis server. It covers essential tasks without being overly thin.

    Completeness3/5

    The tool surface covers basic code analysis and formatting, but lacks expected features like diagnostics, code completion, or refactoring. There are notable gaps for a clangd-based server.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP server that provides semantic understanding of C++ codebases using libclang, allowing Claude to instantly find classes, functions, and their relationships without having to grep through thousands of files.
      34
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      An MCP server for C++ development that currently provides a server_status diagnostic tool. It validates a workspace directory and is designed to expand into build, test, and debugging capabilities.
      72
      MIT