cpp
Lightweight C++ MCP (Model Context Protocol) SDK
claude mcp add --transport stdio hkr04-cpp-mcp ./hkr04-cpp-mcp-server \ --env MCP_SSL="0 or 1 (enable if SSL is built/required)" \ --env MCP_HOST="localhost" \ --env MCP_PORT="8080"
How to use
This MCP server is a C++ implementation of the MCP protocol. It provides a modular framework for exposing resources (like files and APIs) and tools via HTTP or stdio transports, following the JSON-RPC 2.0 style used by MCP. Once built, run the server binary to start listening for client connections. The server supports registering tools and resources, and can communicate with clients and other MCP components through HTTP, SSE, or stdio transports depending on how you configure the client. Typical usage includes creating and registering tools (e.g., time, calculator, echo) and exposing resources that clients can read or interact with via the MCP protocol.
How to install
Prerequisites:
- A C++17 (or newer) compiler
- CMake (>= 3.15)
- Git
Install and build:
-
Clone the repository with submodules: git clone --recurse-submodules <repository-url> cd <repo-name>
-
Create a build directory and configure with CMake: mkdir -p build cd build cmake .. -DCMAKE_BUILD_TYPE=Release
-
Build the project: cmake --build . --config Release
-
(Optional) Run tests if you built with tests enabled: cmake -DMCP_BUILD_TESTS=ON .. cmake --build . --config Release
-
Run the server (example binary name used in configuration): ./hkr04-cpp-mcp-server
Notes:
- If SSL is required, rebuild with -DMCP_SSL=ON and ensure any certificates are available to the runtime.
- The repository provides examples for HTTP server usage, SSE client, and Stdio client to demonstrate interaction with the MCP server.
Additional notes
Tips and common issues:
- Ensure the binary name matches the one referenced in your mcp_config when deploying.
- If you use stdio transport, you can launch the server as a subprocess and communicate via the Stdio client as shown in the examples.
- When enabling TLS/SSL, provide proper certificates and keys at startup and compile with MCP_SSL=ON.
- If you encounter tool or resource registration errors, verify that the tool/resource registration code is executed before starting the server loop and that the JSON-RPC messages conform to the MCP specification.
- Environment variables like MCP_HOST and MCP_PORT can help tailor network exposure; adjust according to your deployment (e.g., containerized environments).
- Use the provided examples (HTTP server, SSE client, Stdio client) to validate the server behavior before integrating into larger workflows.
Related MCP Servers
xiaozhi-esp32
An MCP-based chatbot | 一个基于MCP的聊天机器人
unreal
Enable AI assistant clients like Cursor, Windsurf and Claude Desktop to control Unreal Engine through natural language using the Model Context Protocol (MCP).
deeppowers
DEEPPOWERS is a Fully Homomorphic Encryption (FHE) framework built for MCP (Model Context Protocol), aiming to provide end-to-end privacy protection and high-efficiency computation for the upstream and downstream ecosystem of the MCP protocol.
x64dbgMCP
Model Context Protocol for x64dbg & x32dbg
mcp-cpp
A C++ SDK for the Model Context Protocol (MCP). The SDK will provide a framework for creating MCP servers and clients in C++.
processhacker
your ai debugger, vibe hacking tool