Skip to content

pooriayousefi/cpp-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

C++ MCP SDK

License: MIT C++23 Header-Only

A modern, header-only C++ implementation of the Model Context Protocol (MCP).

Note: This SDK is currently in early development. It aims to become the official C++ SDK for MCP through community collaboration.

What is MCP?

The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. Whether you're building an AI-powered IDE, enhancing a chat interface, or creating custom AI workflows, MCP provides a standardized way to connect LLMs with the context they need.

Why C++ MCP SDK?

  • ๐Ÿš€ Performance: Native C++ performance for latency-critical applications
  • ๐ŸŽฎ Native Integration: Perfect for game engines, CAD software, scientific computing
  • ๐Ÿ”ง System-Level Control: Fine-grained control over memory, threading, and I/O
  • ๐Ÿ“ฆ Header-Only: Minimal dependencies, easy integration
  • ๐ŸŒ Cross-Platform: Works on Linux, macOS, Windows, and embedded systems
  • โšก Modern C++23: Leverages coroutines, ranges, and modules

Features

Current Status (v0.1.0-alpha)

  • Project structure and build system
  • Core utilities (async ops, RAII wrappers, string formatting)
  • Pythonic naming conventions
  • MCP Protocol Types (JSON-RPC 2.0)
  • Transport Layer (stdio, HTTP/SSE)
  • Client Implementation
  • Server Implementation
  • Resource Management
  • Tool/Prompt Support

Planned Features

  • WebSocket transport
  • Sampling support
  • Comprehensive examples
  • Full test coverage
  • Documentation site

Quick Start

Prerequisites

  • Compiler: GCC 13+, Clang 16+, or MSVC 19.34+ (C++23 support)
  • Platform: Linux, macOS, or Windows
  • Dependencies: See DEPENDENCIES.md

Installation

# Clone the repository
git clone https://github.com/pooriayousefi/cpp-sdk.git
cd cpp-sdk

# Initialize dependencies (git submodules)
git submodule update --init --recursive

# Build the project
g++ -std=c++23 builder.cpp -o builder
./builder --release --executable

Basic Usage (Coming Soon)

#include <pooriayousefi/mcp/server.hpp>
#include <pooriayousefi/mcp/transport/stdio.hpp>

using namespace pooriayousefi::mcp;

int main() {
    // Create MCP server
    auto server = Server::builder()
        .name("my-cpp-server")
        .version("1.0.0")
        .build();
    
    // Add a tool
    server.add_tool("greet", [](const json& args) {
        return json{{"message", "Hello, " + args["name"].get<std::string>()}};
    });
    
    // Run over stdio
    server.run(transport::Stdio{});
    
    return 0;
}

Project Structure

cpp-sdk/
โ”œโ”€โ”€ include/
โ”‚   โ”œโ”€โ”€ pooriayousefi/
โ”‚   โ”‚   โ””โ”€โ”€ mcp/
โ”‚   โ”‚       โ”œโ”€โ”€ client.hpp          # MCP client
โ”‚   โ”‚       โ”œโ”€โ”€ server.hpp          # MCP server
โ”‚   โ”‚       โ”œโ”€โ”€ protocol.hpp        # Protocol types
โ”‚   โ”‚       โ”œโ”€โ”€ transport/          # Transport implementations
โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ stdio.hpp       # Stdio transport
โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ sse.hpp         # HTTP/SSE transport
โ”‚   โ”‚       โ””โ”€โ”€ types.hpp           # Core MCP types
โ”‚   โ””โ”€โ”€ core/                       # Utility headers
โ”‚       โ”œโ”€โ”€ asyncops.hpp            # Async operations & coroutines
โ”‚       โ”œโ”€โ”€ raiiiofsw.hpp           # RAII filesystem wrappers
โ”‚       โ”œโ”€โ”€ stringformers.hpp       # String formatting
โ”‚       โ””โ”€โ”€ utilities.hpp           # General utilities
โ”œโ”€โ”€ examples/                       # Example implementations
โ”œโ”€โ”€ tests/                          # Unit tests
โ”œโ”€โ”€ external/                       # External dependencies (submodules)
โ”œโ”€โ”€ docs/                           # Documentation
โ”œโ”€โ”€ AUTHORS                         # Project contributors
โ”œโ”€โ”€ LICENSE                         # MIT License
โ”œโ”€โ”€ DEPENDENCIES.md                 # Dependency information
โ””โ”€โ”€ README.md                       # This file

Design Philosophy

Namespace Structure

All code is organized under the pooriayousefi namespace:

pooriayousefi::mcp::core      // Core protocol types
pooriayousefi::mcp::transport // Transport implementations  
pooriayousefi::mcp::client    // Client implementation
pooriayousefi::mcp::server    // Server implementation
pooriayousefi::core           // General utilities

Coding Conventions

  • Classes/Structs: PascalCase (e.g., McpServer)
  • Functions/Variables: snake_case (e.g., add_tool())
  • Constants: UPPER_SNAKE_CASE (e.g., MAX_BUFFER_SIZE)
  • Namespaces: lowercase (e.g., pooriayousefi::mcp)
  • Indentation: Allman style (braces on new lines)

Dependencies Strategy

  • Header-only libraries only: No linking complexity
  • Minimal dependencies: Only nlohmann/json, asio, cpp-httplib
  • Zero Boost: Using standalone alternatives
  • See DEPENDENCIES.md for details

Contributing

We welcome contributions! This project aims to become the official C++ SDK for MCP.

How to Contribute

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

See CONTRIBUTING.md for detailed guidelines (coming soon).

Roadmap to Official SDK

  1. Phase 1 (Current): Core implementation and architecture
  2. Phase 2: Community adoption and feedback
  3. Phase 3: Proposal to modelcontextprotocol organization
  4. Phase 4: Official SDK status with potential corporate partnership

Related Projects

Community

License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (c) 2025 The C++ MCP SDK Authors

Acknowledgements

  • Created and maintained by Pooria Yousefi
  • Inspired by the official Go and Rust MCP SDKs
  • Built with support from the MCP community

Status: Early Development | Version: 0.1.0-alpha | Last Updated: October 2025

About

Modern C++23 implementation of the Model Context Protocol (MCP)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors