mcp-cpp

This repository provides a C++ SDK for the Model Context Protocol (MCP), enabling the creation of MCP servers and clients with features like JSON-RPC, multiple transport options, and comprehensive error handling.

38
1

mcp-cpp

A C++ SDK for the Model Context Protocol (MCP), providing a framework for building MCP servers and clients using modern C++17 practices.

Features

  • JSON-RPC 2.0 based messaging for structured communication.
  • Flexible transport mechanisms, currently STDIO, with HTTP/SSE planned for future support.
  • Support for key MCP capabilities: Tools, Resources, and Prompts.
  • Thread-safe and memory-safe design achieved through RAII and smart pointers.
  • Robust error handling capabilities.

Building the Library

The library utilizes CMake for building:

# Configure the build
cmake -B build

# Build the library
cmake --build build

# Run tests
cd build && ctest

Examples

Echo Server/Client

A simple echo server and client example demonstrates basic library usage.

To run the echo server:

./build/examples/simple_server/echo_server

To run the echo client:

./build/examples/simple_client/echo_client

The client sends a request and notification on startup, then echoes user-entered messages from the server.

Development Status

The project is under active development, with core types, JSON serialization, error handling, transport interface, STDIO transport, and logging utilities already implemented. Upcoming features include session management, HTTP/SSE transport, and server/client implementations.

License

See the LICENSE file for details.

Repository

NE
Neumann-Labs

Neumann-Labs/mcp-cpp

Created

March 4, 2025

Updated

March 25, 2025

Language

C++

Category

Developer Tools