Get the FREE Ultimate OpenClaw Setup Guide →

cplusplus_mcp

An MCP (Model Context Protocol) server for analyzing C++ codebases using libclang.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio kandrwmrtn-cplusplus_mcp python -m mcp_server.cpp_mcp_server \
  --env PYTHONPATH="YOUR_INSTALLATION_PATH_HERE"

How to use

This MCP server provides a C++ semantic analyzer powered by libclang. It exposes capabilities to search for classes and functions by name patterns, retrieve detailed class information (methods, members, and inheritance), inspect function signatures, and analyze call graphs (callers, callees, and specific call paths). It also supports file-scoped symbol searches, and can reveal complete inheritance hierarchies and derived classes. With this, Claude can navigate large C++ codebases more like an IDE, giving you precise context about code structure and relationships without scanning files manually.

To use it with Claude or Codex CLI, first ensure the server is running via the configuration in Claude/Codex, then index your project directory. After indexing, you can issue prompts like: find all classes containing 'Actor', show me the Component class details, or what is the signature of BeginPlay. The server caches results for faster subsequent queries, but initial indexing may take several minutes for very large projects. You can adjust indexing behavior using the provided cpp-analyzer-config.json to exclude certain directories, patterns, and to tune performance. When working with Codex CLI, create a .mcp.json that points to this Python module and set PYTHONPATH accordingly, then reload the Codex CLI so it discovers the server.

How to install

Prerequisites

  • Python 3.9 or higher
  • pip (Python package manager)
  • Git (for cloning)
  • LLVM's libclang (the setup scripts can download a portable build)

Installation steps

  1. Clone the repository:
git clone <repository-url>
cd CPlusPlus-MCP-Server
  1. Run the setup script for your platform (this creates a virtual environment, installs dependencies, and fetches libclang if possible):
  • Windows
server_setup.bat
  • Linux/macOS
./server_setup.sh
  1. Test the installation (recommended):
# Activate the virtual environment first
# Windows
mcp_env\Scripts\activate

# Linux/macOS
source mcp_env/bin/activate
python -m mcp_server.test_installation
  1. If you need to verify libclang is available, ensure the installation test passes and consult Troubleshooting if you encounter the libclang not found issue.

Additional notes

Tips and common issues:

  • libclang availability is common trouble; use the provided setup script to auto-download or manually place libclang as described in Troubleshooting.
  • If Claude or Codex does not recognize the server, ensure absolute paths are used in configuration (CLAUDE.json or .mcp.json) and restart the client.
  • The server supports configuration via cpp-analyzer-config.json to exclude directories, specify dependency handling, and limit file sizes when scanning large projects.
  • In the Claude configuration example, replace YOUR_INSTALLATION_PATH_HERE with the actual installation path of the repository on your machine.
  • Initial indexing may take minutes for large codebases; you can prompt Claude to proceed with indexing explicitly and monitor progress.

Related MCP Servers

Sponsor this space

Reach thousands of developers