Cpp

Agent frameworks and SDKs

Lightweight C++ MCP (Model Context Protocol) SDK.

Your AI app calls the Cpp MCP server, which does the agent frameworks and SDKs work and sends the result back to the chat.

About Cpp

Cpp is a community MCP server from hkr04, filed in our directory under agent frameworks and sdks. Lightweight C++ MCP (Model Context Protocol) SDK.

Cpp runs on your own machine: your AI app starts it with the command npx -y @modelcontextprotocol/server-everything and talks to it over standard input and output.

At a glance

Publisher
hkr04 (community)
Runs
Locally on your machine
Install from
Node.js package on npm: @modelcontextprotocol/server-everything
Written in
C++
License
MIT
GitHub stars
353

How to set up Cpp

  1. Install Node.js on the machine that runs your AI app, because Cpp starts with npx and downloads its package on first run.
  2. Check the Cpp README for keys or settings; the registry lists none that Cpp requires.
  3. Add Cpp to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Cpp tools to confirm the connection.
  5. Run one read-only task with Cpp first, and keep your app asking before each tool call until the results look right.

Cpp compared with similar servers

  • SynapseOrch by synapseorch-ai has fewer GitHub stars than Cpp (344 against 353); both are community servers, and SynapseOrch runs as a remote server and Cpp runs on your own machine.
  • macOS Use by mediar-ai has more GitHub stars than Cpp (361 against 353); both are community servers, and both run locally.
  • Charles by heizaheiza has fewer GitHub stars than Cpp (334 against 353); both are community servers, and both run locally.

Before you connect Cpp

  • Give Cpp its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Cpp tool call until you trust what it does with them.
  • Treat text that Cpp fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Cpp on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Cpp

How marketing and sales teams put Cpp to work, by company size. Pick the size closest to yours and start Cpp on one use case.

Small business

  • A small business with a developer can use Cpp to build one focused agent, such as lead follow-up, without a big platform.
  • Technical founders can prototype marketing agents with Cpp and keep what works as a small, owned tool.
  • Cpp runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Growth engineering teams can use Cpp to build agents that combine CRM, analytics and content tools behind one workflow.
  • Marketing ops can standardize on Cpp so every agent they ship has the same logging, approvals and error handling.
  • Start Cpp on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises can build on Cpp with their own identity, policy and evaluation layers, so agents meet the same bar as other software.
  • Platform teams can use Cpp to give business units a governed way to ship agents without each one starting from scratch.
  • Cpp is a community server, so have security review the code and pin a version before Cpp touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Cpp README

From hkr04/cpp-mcp on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

MCP Protocol Framework

Model Context Protocol (MCP) is an open protocol that provides a standardized way for AI models and agents to interact with various resources, tools, and services. This framework implements the core functionality of the MCP protocol, conforming to the 2025-03-26 basic protocol specification.

Core Features

  • JSON-RPC 2.0 Communication: Request/response communication based on JSON-RPC 2.0 standard
  • Resource Abstraction: Standard interfaces for resources such as files, APIs, etc.
  • Tool Registration: Register and call tools with structured parameters
  • Prompt Templates: Register and expose prompt templates to clients for AI workflows
  • Extensible Architecture: Easy to extend with new resource types and tools
  • Multi-Transport Support: Supports HTTP and standard input/output (stdio) communication methods

How to Build

Example of building with CMake:

cmake -B build
cmake --build build --config Release

Build with tests:

git submodule update --init --recursive # Get GoogleTest

cmake -B build -DMCP_BUILD_TESTS=ON
cmake --build build --config Release

Build with SSL support:

git submodule update --init --recursive # Get GoogleTest

cmake -B build -DMCP_SSL=ON
cmake --build build --config Release

Adopters

Here are some open-source projects that are using this repository.
If you're using it too, feel free to submit a PR to be featured here!

  • humanus.cpp: Lightweight C++ LLM agent framework
  • ...waiting for your contribution...

Components

The MCP C++ library includes the following main components:

Core Components
Client Interface (mcp_client.h)

Defines the abstract interface for MCP clients, which all concrete client implementations inherit from.

SSE Client (mcp_sse_client.h, mcp_sse_client.cpp)

Client implementation that communicates with MCP servers using HTTP and Server-Sent Events (SSE).

Stdio Client (mcp_stdio_client.h, mcp_stdio_client.cpp)

Client implementation that communicates with MCP servers using standard input/output, capable of launching subprocesses and communicating with them.

Message Processing (mcp_message.h, mcp_message.cpp)

Handles serialization and deserialization of JSON-RPC messages.

Tool Management (mcp_tool.h, mcp_tool.cpp)

Manages and invokes MCP tools.

Resource Management (mcp_resource.h, mcp_resource.cpp)

Manages MCP resources.

Server (mcp_server.h, mcp_server.cpp)

Implements MCP server functionality.

Examples

HTTP Server Example (examples/server_example.cpp)

Example MCP server implementation over HTTP/SSE with custom tools:

  • Time tool: Get the current time
  • Calculator tool: Perform mathematical operations
  • Echo tool: Echo input with optional transformations (to uppercase, reverse)
  • Greeting tool: Returns Hello, + input name + !, defaults to Hello, World!
Stdio Server Example (examples/stdio_server_example.cpp)

Example MCP server implementation over standard input/output (stdio), which is the default transport method for MCP clients like Claude Desktop, Cursor, and OpenCode. It implements the same core tools but uses server.start_stdio() to communicate via pipes instead of opening an HTTP port.

HTTP Client Example (examples/client_example.cpp)

Example MCP client connecting to a server:

  • Get server information
  • List available tools and prompts
  • Call tools with parameters
  • Access resources
Stdio Client Example (examples/stdio_client_example.cpp)

Demonstrates how to use the stdio client to communicate with a local server:

  • Launch a local server process
  • Access filesystem resources
  • Call server tools
Agent Example (examples/agent_example.cpp)
Option Description
--base-url LLM base URL (e.g. https://openrouter.ai)
--endpoint LLM endpoint (default to /v1/chat/completions/)
--api-key LLM API key
--model Model name (e.g. gpt-3.5-turbo)
--system-prompt System prompt
--max-tokens Maximum number of tokens to generate (default to 2048)
--temperature Temperature (default to 0.0)
--max-steps Maximum steps calling tools without user input (default to 3)

Example usage:

./build/examples/agent_example --base-url <base_url> --endpoint <endpoint> --api-key <api_key> --model <model_name>

Note: Remember to compile with -DMCP_SSL=ON when connecting to an https base URL.

How to Use

Setting up an HTTP Server
// Create and configure the server
mcp::server::configuration srv_conf;
srv_conf.host = "localhost";
srv_conf.port = 8888;

mcp::server server(srv_conf);
server.set_server_info("MCP Example Server", "0.1.0"); // Name and version

// Register tools
mcp::json hello_handler(const mcp::json& params, const std::string /* session_id */) {
    std::string name = params.contains("name") ? params["name"].get<std::string>() : "World";

    // Server will catch exceptions and return error contents
    // For example, you can use `throw mcp::mcp_exception(mcp::error_code::invalid_params, "Invalid name");` to report an error

    // Content should be a JSON array, see: https://modelcontextprotocol.io/specification/2024-11-05/server/tools#tool-result
    return {
        {
            {"type", "text"},
            {"text", "Hello, " + name + "!"}
        }
    };
}

mcp::tool hello_tool = mcp::tool_builder("hello")
        .with_description("Say hello")
        .with_string_param("name", "Name to say hello to", "World")
        .build();

server.register_tool(hello_tool, hello_handler);

// Register resources
auto file_resource = std::make_shared<mcp::file_resource>("<file_path>");
server.register_resource("file://<file_path>", file_resource);

// Register prompts
mcp::prompt draft_prompt = mcp::prompt_builder("draft_article")
        .with_description("Draft a new article")
        .with_argument("topic", "The main topic to write about", true)
        .build();

server.register_prompt(draft_prompt, [](const mcp::json& args, const std::string /* session_id */) -> mcp::json {
    std::string topic = args.value("topic", "Unknown");
    std::string instruction = "Please write an article about " + topic;
    
    // Return messages array as specified in the MCP protocol
    return mcp::json::array({{
        {"role", "user"},
        {"content", {
            {"type", "text"},
            {"text", instruction}
        }}
    }});
});

// Start the server
server.start(true);  // Blocking mode
Creating an HTTP Client
// Connect to the server
mcp::sse_client client("http://localhost:8080");

// Initialize the connection
client.initialize("My Client", "1.0.0");

// Call a tool
mcp::json params = {
    {"name", "Client"}
};

mcp::json result = client.call_tool("hello", params);
Using the SSE Client

The SSE client uses HTTP and Server-Sent Events (SSE) to communicate with MCP servers. This is a communication method based on Web standards, suitable for communicating with servers that support HTTP/SSE.

#include "mcp_sse_client.h"

// Create a client, specifying the server address and port
mcp::sse_client client("http://localhost:8080");

// Set an authentication token (if needed)
client.set_auth_token("your_auth_token");

// Set custom request headers (if needed)
client.set_header("X-Custom-Header", "value");

// Initialize the client
if (!client.initialize("My Client", "1.0.0")) {
    // Handle initialization failure
}

// Call a tool
json result = client.call_tool("tool_name", {
    {"param1", "value1"},
    {"param2", 42}
});
Using the Stdio Client

The Stdio client can communicate with any MCP server that supports stdio transport, such as:

  • @modelcontextprotocol/server-everything - Example server
  • @modelcontextprotocol/server-filesystem - Filesystem server
  • Other MCP servers that support stdio transport
#include "mcp_stdio_client.h"

// Create a client, specifying the server command
mcp::stdio_client client("npx -y @modelcontextprotocol/server-everything");
// mcp::stdio_client client("npx -y @modelcontextprotocol/server-filesystem /path/to/directory");

// Initialize the client
if (!client.initialize("My Client", "1.0.0")) {
    // Handle initialization failure
}

// Access resources
json resources = client.list_resources();
json content = client.read_resource("resource://uri");

// Call a tool
json result = client.call_tool("tool_name", {
    {"param1", "value1"},
    {"param2", "value2"}
});

Using TLS clients and servers

Creating test certificates on Linux
  1. Generate Certificate Authority (CA) private key
    openssl genrsa -out ca.key.pem 2048
    
  2. Generate CA certificate
    openssl req -x509 -new -nodes -key ca.key.pem -sha256 -days 1 -out ca.cert.pem -subj "/CN=Test CA"
    
  3. Generate server private key
    openssl genrsa -out server.key.pem 2048
    
  4. Generate Certificate Signing Request (CSR)
    openssl req -new -key server.key.pem -out server.csr.pem -subj "/O=TestServer/OU=Dev/CN=localhost"
    
  5. Generate server certificate signed by CA
    openssl x509 -req -in server.csr.pem -CA ca.cert.pem -CAkey ca.key.pem -CAcreateserial -out server.cert.pem -days 1 -sha256
    
Setting up an HTTPs server
mcp::server::configuration srv_conf;
srv_conf.host = "localhost";
srv_conf.port = 8888;
srv_conf.ssl.server_cert_path = "./server.cert.pem";
srv_conf.ssl.server_private_key_path = "./server.key.pem";
Setting up an SSE client with TLS
 mcp::sse_client client("https://localhost:8888");

License

This framework is provided under the MIT license. For details, please see the LICENSE file.

Questions about Cpp

What is the Cpp MCP server?

Lightweight C++ MCP (Model Context Protocol) SDK. Cpp is maintained by hkr04 on GitHub at hkr04/cpp-mcp, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Cpp MCP server?

Add Cpp to your AI app's MCP config with the command npx -y @modelcontextprotocol/server-everything. In Claude Code, run claude mcp add --transport stdio cpp -- npx -y @modelcontextprotocol/server-everything. To run Cpp this way you need Node.js installed.

Does Cpp need an API key?

The registry lists no required keys for Cpp. Check the Cpp README for optional settings, and expect a remote server to ask you to sign in the first time you connect.

Is Cpp an official MCP server?

No. Cpp is a community server maintained by hkr04. Community servers can be excellent; read the code and the open issues before you give Cpp access to company data.

What license is Cpp under?

Cpp is released under the MIT license, according to its GitHub repository. The license covers the code of Cpp; the service it connects to has its own terms.