mcp-cpp
by: Neumann-Labs
A C++ SDK for the Model Context Protocol (MCP). The SDK will provide a framework for creating MCP servers and clients in C++.
📌Overview
Purpose: To provide a robust C++ SDK for developing compliant Model Context Protocol (MCP) servers and clients, leveraging modern C++ standards for better performance and safety.
Overview: The MCP C++ SDK facilitates the development of applications using the Model Context Protocol by offering a streamlined framework that allows for straightforward implementation of messaging and resource management functionalities in C++. It adheres to best practices from C++17, ensuring that developers can create reliable and efficient software solutions.
Key Features:
-
JSON-RPC 2.0 based messaging: Supports structured communication between client and server, enhancing interoperability and efficiency.
-
Multiple transport mechanisms: Allows the use of different transport methods (e.g., STDIO, with plans for HTTP/SSE), providing flexibility in deployment scenarios.
-
Support for MCP capabilities: Implements essential MCP features such as Tools, Resources, and Prompts, allowing for comprehensive functionality within the protocol.
-
Thread-safe design: Ensures safe concurrent operations, which is crucial for multi-threaded applications.
-
Memory-safe implementation: Utilizes RAII (Resource Acquisition Is Initialization) and smart pointers to manage memory effectively and prevent leaks.
-
Comprehensive error handling: Provides robust error management mechanisms to enhance reliability and fault tolerance in applications.
mcp-cpp
A C++ SDK for the Model Context Protocol (MCP). The SDK provides a framework for creating MCP servers and clients in C++ following modern C++17 best practices.
Features
- JSON-RPC 2.0 based messaging
- Multiple transport mechanisms (STDIO, HTTP/SSE planned)
- Support for MCP capabilities: Tools, Resources, and Prompts
- Thread-safe design
- Memory-safe implementation using RAII and smart pointers
- Comprehensive error handling
Building the Library
The library uses CMake for building:
# Configure the build
cmake -B build
# Build the library
cmake --build build
# Run tests
cd build && ctest
Examples
Echo Server/Client
The repository includes a simple echo server and client example that demonstrates the basic usage of the library.
To run the echo server:
./build/examples/simple_server/echo_server
To run the echo client in a different terminal:
./build/examples/simple_client/echo_client
The client sends a test request and notification on startup and then allows you to enter messages that will be echoed back by the server.
Development Status
The project is currently in development with the following components implemented:
- Core types and JSON serialization
- Error handling utilities
- Transport interface
- STDIO transport implementation
- Logging utilities
Upcoming features:
- Session management
- HTTP/SSE transport
- Server implementation
- Client implementation
License
See the LICENSE file for details.