CPP
- python
23
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"kandrwmrtn-cplusplus_mcp": {
"command": "python",
"args": [
"-m",
"mcp_server.cpp_mcp_server"
],
"env": {
"PYTHONPATH": "YOUR_INSTALLATION_PATH_HERE"
}
}
}
}You can install and run a C++ MCP Server to analyze C++ codebases with libclang, giving you fast, semantic insight into classes, functions, hierarchies, and call relationships that help you navigate large projects more efficiently.
How to use
Use the C++ MCP Server with an MCP client to index your project and query semantic information. Start indexing your C++ project, then ask for class and function information, inheritance details, call graphs, and symbol locations. The server caches results to speed up repeated queries and supports incremental analysis as your codebase grows.
How to install
Prerequisites: Python 3.9 or higher, pip, Git, and LLVM’s libclang (the setup process will attempt to obtain a portable build). Ensure you have a working Python environment and a compatible compiler toolchain.
# 1) Clone the C++ MCP Server repository
git clone <repository-url>
cd CPlusPlus-MCP-Server
# 2) Run the platform-specific setup to install dependencies and fetch libclang
# Windows
server_setup.bat
# Linux/macOS
./server_setup.sh
Optionally verify the installation with a test to ensure all components are properly installed.
# Activate the virtual environment (Windows example)
mcp_env\Scripts\activate
# Run the installation test
python scripts\test_installation.py
Additional configuration and usage notes
The server uses libclang for parsing C++ code and caches parsed AST data to improve performance. You can adjust how the server scans your project and what it analyzes by configuring the cpp-analyzer-config.json file.
{
"exclude_directories": [".git", ".svn", "node_modules", "build", "Build"],
"exclude_patterns": ["*.generated.h", "*.generated.cpp", "*_test.cpp"],
"dependency_directories": ["vcpkg_installed", "third_party", "external"],
"include_dependencies": true,
"max_file_size_mb": 10
}
Troubleshooting
Common issues and fixes include libclang not found, server startup problems, and ensuring clients recognize the MCP server. Follow these steps to resolve typical scenarios.
-
libclang not found: run the platform setup script to download a portable libclang. If automatic download fails, manually obtain the correct libclang package for your OS and place it in the expected libclang location.
-
Server fails to start: confirm Python 3.9+ is installed and all dependencies are installed. Run the installation test to identify issues.
-
Clients don’t recognize the server: ensure absolute paths are used in client configuration files and restart the client after changes.
-
For C++ specific prompts: instruct clients to use the cpp-analyzer for C++ symbol searches and code navigation to ensure fast, accurate results.
Available tools
search_classes
Find classes by name pattern across the codebase.
search_functions
Find functions by name pattern across the codebase.
get_class_info
Get detailed information about a class, including methods, members, and inheritance.
get_function_signature
Retrieve function signatures with parameter types and names.
find_in_file
Search for symbols within a specific file.
get_class_hierarchy
Obtain the complete inheritance hierarchy for a class.
get_derived_classes
Find all classes that derive from a base class.
find_callers
List all functions that call a particular function.
find_callees
List all functions called by a particular function.
get_call_path
Find call paths from one function to another.