Tutorials
Build servers, add HTTP, auth, typed tools, async tasks.
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.
Tools, prompts, resources, sampling, tasks, progress, cancellation
448/448 client conformance against the official runner
C++17 public API. HTTP and OpenSSL are opt-in flags
PKCE, DPoP, JWKS, bearer tokens — optional auth target
A complete MCP server in under 15 lines of C++.
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();
}
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://..."};
})
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();
Install via your preferred method.
Guides, references, and recipes for every use case.
Build servers, add HTTP, auth, typed tools, async tasks.
Peer/Service architecture, transports, capability negotiation.
Copy-paste code snippets for common tasks.
stdio, process stdio, Streamable HTTP reference.
Bearer tokens, OAuth 2.1, DPoP, OpenSSL.
API mapping from TypeScript, Python, and Rust SDKs.
Common build errors and runtime issues.
Current focus and longer-term goals.
Vulnerability reporting and design decisions.