Community C++ MCP SDK

# Build MCP clients and servers in C++.

A production-ready C++17 SDK with full protocol coverage across all MCP spec versions (2024-11-05 through DRAFT-2026-v1), cross-SDK conformance validation, and zero required runtime dependencies.

Get Started GitHub Conformance
⚡

### Full Protocol

Tools, prompts, resources, sampling, tasks, progress, cancellation

✅

### 109/110 Server

448/448 client conformance against the official runner

📦

### Zero Dependencies

C++17 public API. HTTP and OpenSSL are opt-in flags

🔒

### OAuth 2.1

PKCE, DPoP, JWKS, bearer tokens — optional auth target

109/110
Server Tests Passed
448/448
Client Tests Passed
99%
Server Conformance

## Easy to get started

A complete MCP server in under 15 lines of C++.

## Builder Pattern

Chain `.name()`, `.version()`, `.stdio()` and register typed handlers. The builder compiles to a single `.run()` call — no boilerplate, no runtime dependency.

    #include <cxxmcp/peer.hpp>
    #include <cxxmcp/run.hpp>

    int main() {
        return mcp::ServerPeer::builder()
            .name("demo").version("1.0.0").stdio()
            .tool<mcp::protocol::Json, mcp::protocol::Json>(
                "echo", [](const mcp::protocol::Json& in) {
                    return mcp::protocol::Json{{"echo", in}};
                })
            .run();
    }

## Typed DTOs with Reflection

Use `CXXMCP_REFLECT` to define request/response types. Zero-boilerplate serialization — the macro generates everything at compile time.

    struct SearchArgs {
        std::string query;
        int limit = 10;
        CXXMCP_REFLECT(SearchArgs, query, limit)
    };

    struct SearchResult {
        std::string title;
        std::string url;
        CXXMCP_REFLECT(SearchResult, title, url)
    };

    // Register a typed tool
    .tool<SearchArgs, SearchResult>("search",
        [](const SearchArgs& args) {
            return SearchResult{"Found", "https://..."};
        })

## Streamable HTTP Transport

Enable HTTP with a single CMake flag. The server supports SSE streaming, session management, and bearer token auth out of the box.

    # Build with HTTP transport
    cmake -S . -B build -DCXXMCP_ENABLE_HTTP=ON
    cmake --build build

    // Server — listen on HTTP
    ServerPeer::builder()
        .name("api").version("1.0.0")
        .streamable_http("0.0.0.0", 8080, "/mcp")
        .tool<Json, Json>("ping",
            [](const Json&) { return Json{{"ok", true}}; })
        .run();

## Get cxxmcp

Install via your preferred method.

### CMake FetchContent

Drop into any CMake project — no pre-install needed.

`include(FetchContent)`

### vcpkg

Overlay port available in the repository.

`vcpkg install cxxmcp-sdk --overlay-ports=ports/`

### System Install

Build, install, then `find_package`.

`cmake --install build`

### Git Clone

Clone the repo and build directly.

`git clone https://github.com/caomengxuan666/cxxmcp`

## Learn cxxmcp

Guides, references, and recipes for every use case.

## Tutorials

Build servers, add HTTP, auth, typed tools, async tasks.

## Concepts

Peer/Service architecture, transports, capability negotiation.

## Cookbook

Copy-paste code snippets for common tasks.

## Transports

stdio, process stdio, Streamable HTTP reference.

## Auth

Bearer tokens, OAuth 2.1, DPoP, OpenSSL.

## Migration

API mapping from TypeScript, Python, and Rust SDKs.

## Troubleshooting

Common build errors and runtime issues.

## Roadmap

Current focus and longer-term goals.

## Security

Vulnerability reporting and design decisions.