Logo vun C++ MCP Server

C++ MCP Server

Communautéit
mpsm

MCP server tailored to work with large C/C++ codebases

Editeurmpsm
Repositorymcp-cpp
SproochRust
Forks
28
Stären
109
Disponibel Tools
0
Transporttypstdio
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    C++ MCP Server stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    109 Stären an 28 Forks aus dem verlinkte Repository.

C++ MCP Server

CI License Rust Crates.io

A Model Context Protocol (MCP) server that provides C++ code analysis capabilities through clangd LSP integration. Enables AI agents to work with C++ codebases using semantic understanding similar to modern IDEs.

Why This MCP Server?

Modern C++ development relies heavily on advanced tooling to navigate complex codebases with preprocessor macros, template instantiations, and intricate inheritance hierarchies. While humans use IntelliSense-powered IDEs to understand these complexities, most AI agents rely on text-only browsing.

This MCP server bridges that gap by providing AI agents with semantic analysis capabilities similar to what developers experience in modern IDEs. Unlike generic LSP MCP implementations, this server focuses specifically on C++ workflows.

The server can handle multiple C++ projects simultaneously, which is particularly useful for complex scenarios like embedded Linux development where understanding interactions between individual components is crucial. It supports both CMake and Meson build systems with automatic build directory detection and switching.

Advanced indexing monitoring tracks both clangd's index state and logs to ensure complete symbol coverage, while intelligent filtering distinguishes between project code and external dependencies.

Features

The server provides three core analysis tools for C++ development. The get_project_details tool performs dynamic CMake and Meson build environment discovery and enables configuration switching. For symbol exploration, search_symbols offers C++ symbol search with project boundary detection and intelligent filtering. When deeper analysis is needed, analyze_symbol_context provides symbol analysis with inheritance and call hierarchy support.

The implementation works with both CMake and Meson projects, handling projects with multiple libraries and executables simultaneously. Advanced indexing monitors clangd's index state and logs to ensure complete symbol coverage, while intelligent filtering distinguishes between project code and external dependencies. The server automatically discovers and switches between build configurations, and includes a Python CLI tool for quick symbol exploration.

Component Discovery

The MCP server automatically looks for components in the current working directory, scanning 2 levels below by default. This scan depth can be changed using tool options. When an AI agent requests analysis using a build directory outside the project, the MCP server will use that hint path and create a component from it, allowing flexible project analysis beyond the default scanning scope.

Dependencies

The server requires clangd 11 or later for C++ semantic analysis (clangd 20+ recommended), and Rust 2024 edition for building. Your project must use CMake or Meson to generate compilation databases (compile_commands.json).

You can optionally set the CLANGD_PATH environment variable to specify a custom clangd binary location.

Installation

Install from Crates.io (Recommended)

bash
# Install directly from the registry
cargo install mcp-cpp-server

# The binary will be available in your cargo bin directory
# (usually ~/.cargo/bin/mcp-cpp-server)

Install from Source

bash
# Clone the repository
git clone https://github.com/mpsm/mcp-cpp.git
cd mcp-cpp

# Install from source
cargo install --path .

# The binary will be available in your cargo bin directory
# (usually ~/.cargo/bin/mcp-cpp-server)

Docker Installation

bash
# Build the Docker image
docker build -t mcp-cpp-server .

# Run with your C++ project mounted
docker run -i --rm -v /path/to/your/cpp-project:/workspace mcp-cpp-server

The Docker image includes:

  • mcp-cpp-server binary
  • clangd-20 for C++ semantic analysis
  • Minimal Ubuntu-based runtime

Usage

Claude CLI Integration (Tested)

For Claude CLI, create or update your MCP configuration file (~/.config/claude-cli/mcp_servers.json):

json
{
  "mcpServers": {
    "cpp-tools": {
      "command": "mcp-cpp-server",
      "env": {
        "CLANGD_PATH": "/usr/bin/clangd-20"
      }
    }
  }
}

Amazon Q Developer CLI Integration (Tested)

For Amazon Q Developer CLI, add to your MCP configuration:

json
{
  "mcpServers": {
    "cpp-tools": {
      "command": "mcp-cpp-server",
      "env": {
        "CLANGD_PATH": "/usr/bin/clangd-20"
      }
    }
  }
}

Claude Desktop Integration

Add to your Claude Desktop configuration file (~/.claude_desktop_config.json):

json
{
  "mcpServers": {
    "cpp-tools": {
      "command": "mcp-cpp-server",
      "env": {
        "CLANGD_PATH": "/usr/bin/clangd-20"
      }
    }
  }
}

Claude Code Integration (VS Code Extension)

Claude Code uses a different configuration file location and requires explicit permissions. Add to your Claude Code configuration file (~/.claude.json):

json
{
  "mcpServers": {
    "cpp": {
      "type": "stdio",
      "command": "~/.cargo/bin/mcp-cpp-server",
      "args": [],
      "env": {
        "CLANGD_PATH": "/opt/homebrew/opt/llvm/bin/clangd"
      }
    }
  },
  "permissions": {
    "allow": [
      "mcp__cpp__search_symbols",
      "mcp__cpp__analyze_symbol_context",
      "mcp__cpp__get_project_details"
    ]
  }
}

Notes:

  • Claude Code reads ~/.claude.json, not ~/.claude/mcp_servers.json
  • The permissions section is required to enable the MCP tools
  • Adjust the command path to match your cargo installation (use which mcp-cpp-server to find it)
  • Adjust CLANGD_PATH to your clangd installation (use which clangd to find it, or omit if clangd is in your PATH)
  • Tools are prefixed with mcp__cpp__ in Claude Code (e.g., mcp__cpp__search_symbols)

Docker Usage with MCP Clients

Claude Desktop/CLI:

json
{
  "mcpServers": {
    "cpp-tools": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-v", "/path/to/cpp-project:/workspace",
        "mcp-cpp-server",
        "--root", "/workspace"
      ]
    }
  }
}

Note: Arguments after the image name are passed to mcp-cpp-server. Use -e RUST_LOG=debug for verbose logging.

Platform Support

Tested on:

  • Windows with WSL2 Ubuntu
  • Ubuntu (native)
  • macOS

Configuration

CLI Options

The server supports the following command-line options:

bash
mcp-cpp-server --help

# Options:
--root <DIR>             Project root directory to scan for build configurations (defaults to current directory)
--clangd-path <PATH>     Path to clangd executable (overrides CLANGD_PATH env var)
--log-level <LEVEL>      Log level (overrides RUST_LOG env var) 
--log-file <FILE>        Log file path (overrides MCP_LOG_FILE env var)

Environment Variables

  • CLANGD_PATH: Path to clangd executable (default: "clangd")
  • RUST_LOG: Log level - trace, debug, info, warn, error (default: "info")
  • MCP_LOG_FILE: Path to log file (default: logs to stderr only)
  • MCP_LOG_UNIQUE: Set to "true" to append process ID to log filename

Python CLI for Debugging

The Python CLI helps you understand what your AI agent sees from the MCP server, making it useful for debugging interactions. Note that this tool is not included in the distributed package and must be used directly from the repository:

bash
# Clone the repository if you haven't already
git clone https://github.com/mpsm/mcp-cpp.git
cd mcp-cpp

# Install CLI dependencies
pip install -r tools/requirements.txt

# Search for symbols (see what the agent would see)
python3 tools/mcp-cli.py search-symbols "MyClass"

# Get complete API overview of a header file
python3 tools/mcp-cli.py search-symbols "" --files include/api.h

# Analyze a symbol with examples
python3 tools/mcp-cli.py analyze-symbol "MyClass::process"

# Get project overview
python3 tools/mcp-cli.py get-project-details

Basic Workflow

  1. Get Project Details

    json
    { "name": "get_project_details" }

    With custom scan parameters:

    json
    {
      "name": "get_project_details",
      "arguments": {
        "path": "/path/to/project",
        "depth": 5
      }
    }
  2. Search C++ Symbols

    json
    {
      "name": "search_symbols",
      "arguments": { "query": "std::vector", "include_external": true }
    }

    File-specific search with custom build directory:

    json
    {
      "name": "search_symbols",
      "arguments": {
        "query": "MyClass",
        "files": ["include/MyClass.hpp"],
        "build_directory": "build-debug",
        "wait_timeout": 30
      }
    }
  3. Analyze Symbol Context

    json
    {
      "name": "analyze_symbol_context",
      "arguments": {
        "symbol": "MyClass::process",
        "max_examples": 5
      }
    }

    With location hint for disambiguation:

    json
    {
      "name": "analyze_symbol_context",
      "arguments": {
        "symbol": "factorial",
        "build_directory": "/path/to/build",
        "location_hint": "/path/to/file.cpp:42:15",
        "wait_timeout": 0
      }
    }

Use Cases

The server excels at code exploration and navigation, helping you find functions, classes, and variables across large codebases. It can analyze relationships between code components and navigate system libraries and third-party dependencies to understand how different parts of your project interact.

For code analysis and review, the server provides detailed symbol context including usage patterns, inheritance relationships, and call hierarchies. This helps you explore class hierarchies and call patterns, making it easier to understand unfamiliar code or prepare for refactoring by identifying all usages and dependencies.

The server also assists with development workflows by enabling switching between Debug, Release, and custom build configurations. It provides clear separation between project symbols and external library symbols, making navigation through large C++ codebases more efficient. The cross-reference generation helps you find all references, implementations, and related symbols quickly.

Tool Reference

C++ Analysis Tools

get_project_details

Purpose: Multi-provider build system analysis and project workspace discovery

Options:

  • path (optional): Project root path to scan. If different from server default, triggers fresh scan
  • depth (optional): Scan depth for component discovery (0-10 levels, default: 2). Controls how many directory levels below the current working directory to search for CMake/Meson components

Output: Complete project analysis including build configurations, components, compilation database status, and multi-provider discovery (CMake, Meson, etc.)

Component Discovery: By default, scans 2 levels below the current working directory for components. When AI agents specify build directories outside this scope, the server creates components from those hint paths automatically.

search_symbols

Purpose: Find C++ symbols across your codebase or get complete API overviews

Key Capabilities:

  • Symbol Discovery: Find functions, classes, variables by name or pattern
  • Complete File Overview: Use empty query ("") with file parameter to list all symbols in any file
  • API Exploration: Perfect for understanding unfamiliar headers or source files
  • Smart Filtering: Filter by symbol types (Class, Function, Method, etc.) and exclude external libraries

Common Use Cases:

bash
# Find all vector-related symbols
search_symbols {"query": "vector"}

# Get complete overview of a header file
search_symbols {"query": "", "files": ["include/api.h"]}

# Find only classes and structs
search_symbols {"query": "Process", "kinds": ["Class", "Struct"]}

analyze_symbol_context

Purpose: Deep dive analysis of any C++ symbol with comprehensive context

What You Get:

  • Symbol Definition: Complete type information, location, documentation
  • Usage Examples: Real code showing how the symbol is used
  • Class Members: All methods, fields, constructors (for classes)
  • Inheritance Tree: Base classes and derived classes (for classes)
  • Call Relationships: What calls this function and what it calls (for functions)

Perfect For:

  • Understanding unfamiliar code
  • Finding all usages before refactoring
  • Exploring class hierarchies and relationships
  • Learning how to use a function or class
bash
# Analyze a class and its members
analyze_symbol_context {"symbol": "MyClass"}

# Deep dive into a specific method
analyze_symbol_context {"symbol": "MyClass::process", "max_examples": 3}

Limitations

  • Requires CMake or Meson projects that generate compile_commands.json
  • First-time indexing can take time on large projects (configurable timeout, default 20s)

Installatioun

TypingMind
Viraussetzungen:

Node.js 18+

{
  "mcpServers": {
    "mpsm-mcp-cpp": {
      "command": "",
      "args": []
    }
  }
}

C++ MCP Server MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal C++ MCP Server verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

C++ MCP Server als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu C++ MCP Server an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "mpsm-mcp-cpp": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-cpp"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu C++ MCP Server. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu C++ MCP Server.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat C++ MCP Server?
C++ MCP Server
Jo. Ech hunn et gelies.
Dat hunn ech mat C++ MCP Server fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server C++ MCP Server benotzt?

C++ MCP Server ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech C++ MCP Server MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir C++ MCP Server mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat C++ MCP Server MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann C++ MCP Server verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech C++ MCP Server MCP mat TypingMind?

C++ MCP Server leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt C++ MCP Server MCP an TypingMind zur Verfügung?

C++ MCP Server stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir C++ MCP Server MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann C++ MCP Server eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇