Skip to content
Back to search

gopher-mcp

C++ MCP SDK - build Model Context Protocol (MCP) servers and clients in C++ / CPP. Enterprise-grade security, observability, connectivity. Stdio, HTTP+SSE, Streamable HTTP, WebSocket, TCP transports. Bindings for Python, TypeScript, Go, Rust, Java, C#.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/GopherSecurity/gopher-mcp with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/GopherSecurity/gopher-mcp'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/gophersecurity--gopher-mcp/badge.svg)](/listings/gophersecurity--gopher-mcp)

HTML

<a href="/listings/gophersecurity--gopher-mcp"><img src="/api/listings/gophersecurity--gopher-mcp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Build and Install

# Show all available commands
make help

# Build
make

# Install (auto-prompts for sudo if needed)
make install

# Run tests
make test

Create an MCP Server

#include "mcp/server/mcp_server.h"

int main() {
    mcp::server::McpServerConfig config;
    config.server_name = "my-mcp-server";

    auto server = mcp::server::createMcpServer(config);

    // Register a tool
    mcp::Tool calculator;
    calculator.name = "add";
    calculator.description = "Add two numbers";

    server->registerTool(calculator, [](const std::string& name,
                                         const mcp::optional<mcp::Metadata>& arguments,
                                         mcp::server::SessionContext& ctx) {
        mcp::CallToolResult result;
        auto args = arguments.value();
        auto a_it = args.find("a");
        auto b_it = args.find("b");

        double a = mcp::holds_alternative<double>(a_it->second)
                       ? mcp::get<double>(a_it->second) : 0.0;
        double b = mcp::holds_alternative<double>(b_it->second)
                       ? mcp::get<double>(b_it->second) : 0.0;

        result.content.push_back(mcp::TextContent{"Result: " + std::to_string(a + b)});
        return result;
    });

    server->listen("http://0.0.0.0:3000");
    server->run();
}

Create an MCP Client

#include "mcp/client/mcp_client.h"

int main() {
    mcp::client::McpClientConfig config;
    config.client_name = "my-mcp-client";

    auto client = mcp::client::createMcpClient(config);
    client->connect("http://localhost:3000");

    // Initialize protocol
    auto init = client->initializeProtocol().get();

    // Call a tool
    auto args = mcp::make<mcp::Metadata>()
                    .add("a", 10.0)
                    .add("b", 5.0)
                    .build();

    auto result = client->callTool("add", mcp::make_optional(args)).get();
}

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 393 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # MCP C++ SDK - Model Context Protocol Implementation for C++
  2. [![C++14](https://img.shields.io/badge/C%2B%2B-14%2F17%2F20-blue.svg)](https://isocpp.org/)
  3. [![MCP](https://img.shields.io/badge/MCP-2025--06--18-green.svg)](https://modelcontextprotocol.io/)
  4. [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
  5. [![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey.svg)]()
  6. [![Multi-Language](https://img.shields.io/badge/Multi--Language-Python%20%7C%20Go%20%7C%20Rust%20%7C%20Java%20%7C%20C%23%20and%20more-orange.svg)]()
  7. **The most comprehensive C++ implementation of the Model Context Protocol (MCP)** for building AI-powered applications. Production-ready SDK with enterprise features including multi-transport support, connection pooling, and **multi-language bindings via C API (Python, TypeScript, Go, Rust, Java, C#, Ruby and more)**.
  8. ⭐ **Please give a star if you find this useful!**
  9. ## Table of Contents
  10. - [Architecture Overview](#architecture-overview)
  11. - [Cross-Language Support](#cross-language-support)
  12. - [What is MCP?](#what-is-mcp)
  13. - [Features](#features)
  14. - [Quick Start](#quick-start)
  15. - [Examples](#examples)
  16. - [Installation](#installation)
  17. - [Documentation](#documentation)
  18. - [Comparison with Other C++ MCP SDKs](#comparison-with-other-c-mcp-sdks)
  19. - [FAQ](#faq)
  20. - [Adopters](#adopters)
  21. - [Contributing](#contributing)
  22. - [License](#license)
  23. ## Architecture Overview
  24. ```
  25. ┌─────────────────────────────────────────────────────────────────────┐
  26. │ Application Layer │
  27. │ ┌────────────────────────────────────────────────────────────────┐ │
  28. │ │ MCP Server │ MCP Client │ Custom Applications │ │
  29. │ └────────────────────────────────────────────────────────────────┘ │
  30. ├─────────────────────────────────────────────────────────────────────┤
  31. │ Cross-Language Binding Layer │
  32. │ ┌────────────────────────────────────────────────────────────────┐ │
  33. │ │ Python │ TypeScript │ Go │ Rust │ Java │ C# │ Ruby │ Swift │ │
  34. │ └────────────────────────────────────────────────────────────────┘ │
  35. ├─────────────────────────────────────────────────────────────────────┤
  36. │ C API (FFI Layer) │
  37. │ ┌────────────────────────────────────────────────────────────────┐ │
  38. │ │ libgopher_mcp_c: Opaque Handles │ RAII Guards │ Type Safety │ │
  39. │ └────────────────────────────────────────────────────────────────┘ │
  40. ├─────────────────────────────────────────────────────────────────────┤
  41. │ Protocol Layer │
  42. │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │
  43. │ │ JSON-RPC │ │ Requests │ │ Responses │ │ Notify │ │
  44. │ │ Codec │ │ Dispatch │ │ Routing │ │ Stream │ │
  45. │ └──────────────┘ └──────────────┘ └──────────────┘ └────────────┘ │
  46. ├─────────────────────────────────────────────────────────────────────┤
  47. │ Filter Chain Layer │
  48. │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌────────────┐ │
  49. │ │ HTTP / SSE │ │ Routing │ │ Rate Limiter │ │ Auth │ │
  50. │ │ Codecs │ │ & CORS │ │ Circuit Brk │ │ Metrics │ │
  51. │ └──────────────┘ └──────────────┘ └──────────────┘ └────────────┘ │
  52. ├─────────────────────────────────────────────────────────────────────┤
  53. │ Transport Layer │
  54. │ ┌────────────────────────────────────────────────────────────────┐ │
  55. │ │ Stdio │ HTTP(S)+SSE │ Streamable HTTP │ WebSocket │ TCP │ │
  56. │ └────────────────────────────────────────────────────────────────┘ │
  57. ├─────────────────────────────────────────────────────────────────────┤
  58. │ Network Layer │
  59. │ ┌────────────────┐ ┌────────────────┐ ┌────────────────┐ │
  60. │ │ Connection │ │ Listener │ │ Socket │ │
  61. │ │ Management │ │ & Accept │ │ Interface │ │
  62. │ └────────────────┘ └────────────────┘ └────────────────┘ │
  63. ├─────────────────────────────────────────────────────────────────────┤
  64. │ Event Loop & Dispatcher │
  65. │ ┌────────────────────────────────────────────────────────────────┐ │
  66. │ │ Libevent │ Timer Management │ I/O Events │ Buffer │ Result │ │
  67. │ └────────────────────────────────────────────────────────────────┘ │
  68. └─────────────────────────────────────────────────────────────────────┘
  69. ```
  70. ### Design Principles
  71. 1. **Thread-Safe Dispatcher Model** - All I/O in dispatcher threads, no complex synchronization
  72. 2. **Filter Chain Architecture** - Modular, composable request processing
  73. 3. **Production Patterns** - Connection pooling, circuit breaker, graceful shutdown
  74. ## Cross-Language Support
  75. **Use MCP C++ SDK from any programming language** via the stable C API (`libgopher_mcp_c`):
  76. | Language | Binding Type | Features |
  77. |----------|--------------|----------|
  78. | **Python** | ctypes/cffi | Async support, type hints |
  79. | **TypeScript/Node.js** | N-API | High performance, native async |
  80. | **Go** | CGO | Goroutine-safe wrappers |
  81. | **Rust** | FFI | Safe wrappers, ownership guarantees |
  82. | **Java** | JNI | Automatic resource management |
  83. | **C#/.NET** | P/Invoke | Async/await support |
  84. | **Ruby** | Native extension | GC integration |
  85. ```bash
  86. # Installation paths
  87. Headers: /usr/local/include/gopher-mcp/mcp/c_api/
  88. Library: /usr/local/lib/libgopher_mcp_c.{so,dylib,dll}
  89. ```
  90. ## What is MCP?
  91. **Model Context Protocol (MCP)** is an open protocol that enables AI models (like Claude, GPT, etc.) to securely interact with external tools, data sources, and services. MCP provides a standardized way for:
  92. - **AI assistants** to access files, databases, and APIs
  93. - **Developers** to expose tools and resources to AI models
  94. - **Applications** to integrate AI capabilities with enterprise systems
  95. This MCP C++ SDK implements the [official MCP specification](https://modelcontextprotocol.io/) in high-performance C++, suitable for:
  96. - Embedded systems and IoT devices
  97. - High-frequency trading and real-time applications
  98. - Game engines and graphics applications
  99. - Native desktop and mobile applications
  100. - Backend services requiring low latency
  101. ## Features
  102. | Category | Features |
  103. |----------|----------|
  104. | **Protocol** | Full MCP 2025-06-18, 2025-11-25 and 2026-07-28 specifications, JSON-RPC 2.0, resources, tools, prompts |
  105. | **Transports** | stdio, HTTP+SSE, HTTPS+SSE, WebSocket, TCP |
  106. | **Performance** | Zero-copy buffers, lock-free operations, connection pooling |
  107. | **Reliability** | Circuit breaker, rate limiting, retry with backoff, graceful shutdown |
  108. | **Security** | TLS/SSL, authentication middleware, request validation |
  109. | **Observability** | Structured logging, metrics, health endpoints |
  110. | **Cross-Language** | C API for Python, Node.js, Go, Rust, Java, C#, Ruby bindings |
  111. ## Quick Start
  112. ### Build and Install
  113. ```bash
  114. # Show all available commands
  115. make help
  116. # Build
  117. make
  118. # Install (auto-prompts for sudo if needed)
  119. make install
  120. # Run tests
  121. make test
  122. ```
  123. ### Create an MCP Server
  124. ```cpp
  125. #include "mcp/server/mcp_server.h"
  126. int main() {
  127. mcp::server::McpServerConfig config;
  128. config.server_name = "my-mcp-server";
  129. auto server = mcp::server::createMcpServer(config);
  130. // Register a tool
  131. mcp::Tool calculator;
  132. calculator.name = "add";
  133. calculator.description = "Add two numbers";
  134. server->registerTool(calculator, [](const std::string& name,
  135. const mcp::optional<mcp::Metadata>& arguments,
  136. mcp::server::SessionContext& ctx) {
  137. mcp::CallToolResult result;
  138. auto args = arguments.value();
  139. auto a_it = args.find("a");
  140. auto b_it = args.find("b");
  141. double a = mcp::holds_alternative<double>(a_it->second)
  142. ? mcp::get<double>(a_it->second) : 0.0;
  143. double b = mcp::holds_alternative<double>(b_it->second)
  144. ? mcp::get<double>(b_it->second) : 0.0;
  145. result.content.push_back(mcp::TextContent{"Result: " + std::to_string(a + b)});
  146. return result;
  147. });
  148. server->listen("http://0.0.0.0:3000");
  149. server->run();
  150. }
  151. ```
  152. ### Create an MCP Client
  153. ```cpp
  154. #include "mcp/client/mcp_client.h"
  155. int main() {
  156. mcp::client::McpClientConfig config;
  157. config.client_name = "my-mcp-client";
  158. auto client = mcp::client::createMcpClient(config);
  159. client->connect("http://localhost:3000");
  160. // Initialize protocol
  161. auto init = client->initializeProtocol().get();
  162. // Call a tool
  163. auto args = mcp::make<mcp::Metadata>()
  164. .add("a", 10.0)
  165. .add("b", 5.0)
  166. .build();
  167. auto result = client->callTool("add", mcp::make_optional(args)).get();
  168. }
  169. ```
  170. ## Examples
  171. See [examples/mcp/README.md](examples/mcp/README.md) for complete working examples:
  172. ```bash
  173. # Terminal 1: Start server
  174. ./build/examples/mcp/mcp_example_server --verbose
  175. # Terminal 2: Run client with demo
  176. ./build/examples/mcp/mcp_example_client --demo --verbose
  177. ```
  178. The example server includes:
  179. - Resource registration and subscriptions
  180. - Tool execution (calculator, database query, system info)
  181. - Prompt templates
  182. - Session management
  183. - HTTP/SSE endpoints
  184. ## Installation
  185. ### Prerequisites
  186. - C++14 compiler (GCC 8+, Clang 10+, MSVC 2019+)
  187. - CMake 3.10+
  188. - libevent 2.1+
  189. - OpenSSL 1.1+ (optional, for TLS)
  190. ### Build Options
  191. ```bash
  192. # Debug build
  193. make debug
  194. # Release build
  195. make release
  196. # Static libraries only
  197. cmake -B build -DBUILD_SHARED_LIBS=OFF
  198. # Without C API
  199. cmake -B build -DBUILD_C_API=OFF
  200. # Custom install prefix
  201. cmake -B build -DCMAKE_INSTALL_PREFIX=~/.local
  202. ```
  203. ### Windows (Cygwin + MinGW)
  204. Building on Windows requires Cygwin with MinGW-w64 toolchain:
  205. #### Prerequisites
  206. Install [Cygwin](https://www.cygwin.com/) with these packages:
  207. - `make`, `cmake` - Build tools
  208. - `mingw64-x86_64-gcc-g++` - MinGW C++ compiler
  209. - `mingw64-x86_64-libevent` - Event library
  210. - `mingw64-x86_64-openssl` - SSL/TLS library
  211. #### Build Commands
  212. ```bash
  213. # From Cygwin bash shell
  214. ./build-mingw.sh # Release build (default)
  215. ./build-mingw.sh debug # Debug build
  216. ./build-mingw.sh release # Release build
  217. ./build-mingw.sh clean # Clean build directory
  218. ```
  219. #### Output
  220. - Build directory: `build-mingw/`
  221. - Executable: `build-mingw/examples/mcp/mcp_example_server.exe`
  222. ## Documentation
  223. ### MCP C++ Documentation
  224. - [Examples Guide](examples/mcp/README.md) - Working server and client examples
  225. ### MCP CPP Core Components
  226. - [MCP Protocol in C++](docs/mcp_protocol.md) - Model Context Protocol implementation details
  227. - [Tasks](docs/tasks.md) - Long-running tool calls as tasks, on the server and the client
  228. - [Filter Chain](docs/filter_chain.md) - Processing pipeline architecture
  229. - [Transport Layer](docs/transport_layer.md) - Transport implementations
  230. - [Network Layer](docs/network_layer.md) - Connection management and socket abstraction
  231. ### Design Documents
  232. - [Event Loop Design](docs/event_loop_design.md) - Event-driven architecture and dispatcher design
  233. - [Filter Usage Guide](docs/filter_usage_guide.md) - Comprehensive guide for using and creating filters
  234. - [CTAD Alternatives](docs/CTAD_alternatives.md) - Class Template Argument Deduction alternatives for C++14
  235. - [MCP Serialization Coverage](docs/MCP_serialization_coverage.md) - JSON serialization implementation details
  236. ## Comparison with Other C++ MCP SDKs
  237. Several C++ implementations of the Model Context Protocol exist. They serve
  238. different needs — this table is meant to help you pick the right one:
  239. | | **gopher-mcp** (this SDK) | [hkr04/cpp-mcp](https://github.com/hkr04/cpp-mcp) | [Neumann-Labs/mcp-cpp](https://github.com/Neumann-Labs/mcp-cpp) |
  240. |---|---|---|---|
  241. | Focus | Production / enterprise deployments | Lightweight, minimal footprint | Modern C++20 framework |
  242. | MCP spec version | 2025-06-18, 2025-11-25, 2026-07-28 | 2025-03-26 | 2025-11-25 (in progress) |
  243. | C++ standard | C++14 / 17 / 20 | C++17 | C++20 |
  244. | Transports | stdio, HTTP+SSE, HTTPS, Streamable HTTP, WebSocket, TCP | stdio, HTTP+SSE | stdio, HTTP |
  245. | Client + server | Yes | Yes | Yes |
  246. | TLS | Yes | Yes (build flag) | — |
  247. | Event model | Event-driven dispatcher (libevent), thread-safe by design | — | — |
  248. | Resilience | Connection pooling, circuit breaker, rate limiting, backpressure | — | — |
  249. | Observability | Metrics, tracing hooks, structured logging | — | — |
  250. | Language bindings | Python, TypeScript, Go, Rust, Java, C#, Ruby via stable C API | C++ only | C++ only |
  251. | License | Apache-2.0 | MIT | MIT |
  252. If you need a small dependency for a quick stdio tool, a lightweight SDK like
  253. `cpp-mcp` is a fine choice. If you need an MCP C++ SDK for production —
  254. long-lived connections, multiple transports, observability, or calling the
  255. SDK from other languages — that is what gopher-mcp is built for.
  256. ## FAQ
  257. ### What is the Model Context Protocol?
  258. MCP is an open protocol by Anthropic that standardizes how AI models interact with external tools and data. It defines JSON-RPC methods for resources (data), tools (actions), and prompts (templates).
  259. ### Why use C++ for MCP?
  260. C++ provides maximum performance and portability. This SDK is ideal for embedded systems, real-time applications, game engines, and any environment where Python/Node.js overhead is unacceptable.
  261. ### Does this work with Claude, GPT, and other AI models?
  262. Yes. MCP is model-agnostic. Any AI system that supports MCP can use servers built with this SDK.
  263. ### How do I integrate with my Python/Node.js application?
  264. Use the C API bindings. The SDK provides a stable C interface that can be called from any language with FFI support.
  265. ### Is this production-ready?
  266. Yes. The SDK includes connection pooling, circuit breakers, rate limiting, TLS support, and comprehensive error handling suitable for enterprise deployments.
  267. ### What transports are supported?
  268. - **stdio** - Standard input/output (CLI tools)
  269. - **HTTP+SSE** - HTTP with Server-Sent Events (web applications)
  270. - **HTTPS+SSE** - Secure HTTP+SSE
  271. - **WebSocket** - Bidirectional real-time
  272. - **TCP** - Raw TCP sockets
  273. ### How does this compare to cpp-mcp and other C++ MCP libraries?
  274. See the [comparison table](#comparison-with-other-c-mcp-sdks). In short:
  275. gopher-mcp targets production use — more transports (Streamable HTTP,
  276. WebSocket, TCP), connection pooling, circuit breakers, observability, and
  277. multi-language bindings — while lighter SDKs optimize for minimal footprint.
  278. ### How do I contribute?
  279. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. Issues and pull requests welcome!
  280. ## Adopters
  281. Using this MCP C++ SDK in your product or project? We'd love to list you
  282. here — open a pull request or issue to add yourself.
  283. - [Gopher Security](https://gopher.security) - MCP-native AI security platform
  284. ## Keywords & Search Terms
  285. `MCP C++`, `MCP CPP`, `Model Context Protocol C++`, `MCP SDK`, `C++ MCP`, `CPP MCP`, `Model Context Protocol CPP`, `MCP implementation`, `AI model integration C++`, `LLM integration C++`, `MCP server C++`, `MCP client C++`, `Model Context Protocol SDK`, `C++ AI SDK`, `Enterprise MCP`, `Production MCP C++`
  286. ## Contributing
  287. Contributions are welcome! Please read our contributing guidelines before submitting pull requests.
  288. ## License
  289. Apache License 2.0 - see [LICENSE](LICENSE) for details.
  290. ## Related Projects
  291. - [Model Context Protocol Specification](https://modelcontextprotocol.io/)
  292. - [MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk)
  293. - [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.