gopher-mcp

作者 GopherSecurity已验证

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#.

141
Stars
19
Forks
C++
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/GopherSecurity/gopher-mcp

快速入门

使用 gopher-mcp 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

MCP C++ SDK - Model Context Protocol Implementation for C++

C++14 MCP License Platform Multi-Language

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).

Please give a star if you find this useful!

Table of Contents

Architecture Overview

┌─────────────────────────────────────────────────────────────────────┐
│                         Application Layer                           │
│  ┌────────────────────────────────────────────────────────────────┐ │
│  │      MCP Server │ MCP Client │ Custom Applications             │ │
│  └────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────┤
│                    Cross-Language Binding Layer                     │
│  ┌────────────────────────────────────────────────────────────────┐ │
│  │   Python │ TypeScript │ Go │ Rust │ Java │ C# │ Ruby │ Swift   │ │
│  └────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────┤
│                          C API (FFI Layer)                          │
│  ┌────────────────────────────────────────────────────────────────┐ │
│  │   libgopher_mcp_c: Opaque Handles │ RAII Guards │ Type Safety  │ │
│  └────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────┤
│                            Protocol Layer                           │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌────────────┐  │
│  │   JSON-RPC   │ │   Requests   │ │  Responses   │ │   Notify   │  │
│  │   Codec      │ │   Dispatch   │ │   Routing    │ │   Stream   │  │
│  └──────────────┘ └──────────────┘ └──────────────┘ └────────────┘  │
├─────────────────────────────────────────────────────────────────────┤
│                          Filter Chain Layer                         │
│  ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌────────────┐  │
│  │  HTTP / SSE  │ │   Routing    │ │ Rate Limiter │ │   Auth     │  │
│  │    Codecs    │ │   & CORS     │ │ Circuit Brk  │ │  Metrics   │  │
│  └──────────────┘ └──────────────┘ └──────────────┘ └────────────┘  │
├─────────────────────────────────────────────────────────────────────┤
│                           Transport Layer                           │
│  ┌────────────────────────────────────────────────────────────────┐ │
│  │   Stdio │ HTTP(S)+SSE │ Streamable HTTP │ WebSocket │ TCP      │ │
│  └────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────┤
│                            Network Layer                            │
│  ┌────────────────┐ ┌────────────────┐ ┌────────────────┐           │
│  │   Connection   │ │    Listener    │ │     Socket     │           │
│  │   Management   │ │    & Accept    │ │   Interface    │           │
│  └────────────────┘ └────────────────┘ └────────────────┘           │
├─────────────────────────────────────────────────────────────────────┤
│                       Event Loop & Dispatcher                       │
│  ┌────────────────────────────────────────────────────────────────┐ │
│  │   Libevent │ Timer Management │ I/O Events │ Buffer │ Result   │ │
│  └────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────┘

Design Principles

  1. Thread-Safe Dispatcher Model - All I/O in dispatcher threads, no complex synchronization
  2. Filter Chain Architecture - Modular, composable request processing
  3. Production Patterns - Connection pooling, circuit breaker, graceful shutdown

Cross-Language Support

Use MCP C++ SDK from any programming language via the stable C API (libgopher_mcp_c):

LanguageBinding TypeFeatures
Pythonctypes/cffiAsync support, type hints
TypeScript/Node.jsN-APIHigh performance, native async
GoCGOGoroutine-safe wrappers
RustFFISafe wrappers, ownership guarantees
JavaJNIAutomatic resource management
C#/.NETP/InvokeAsync/await support
RubyNative extensionGC integration
# Installation paths
Headers: /usr/local/include/gopher-mcp/mcp/c_api/
Library: /usr/local/lib/libgopher_mcp_c.{so,dylib,dll}

What is MCP?

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:

  • AI assistants to access files, databases, and APIs
  • Developers to expose tools and resources to AI models
  • Applications to integrate AI capabilities with enterprise systems

This MCP C++ SDK implements the official MCP specification in high-performance C++, suitable for:

  • Embedded systems and IoT devices
  • High-frequency trading and real-time applications
  • Game engines and graphics applications
  • Native desktop and mobile applications
  • Backend services requiring low latency

Features

CategoryFeatures
ProtocolFull MCP 2025-06-18, 2025-11-25 and 2026-07-28 specifications, JSON-RPC 2.0, resources, tools, prompts
Transportsstdio, HTTP+SSE, HTTPS+SSE, WebSocket, TCP
PerformanceZero-copy buffers, lock-free operations, connection pooling
ReliabilityCircuit breaker, rate limiting, retry with backoff, graceful shutdown
SecurityTLS/SSL, authentication middleware, request validation
ObservabilityStructured logging, metrics, health endpoints
Cross-LanguageC API for Python, Node.js, Go, Rust, Java, C#, Ruby bindings

Quick Start

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();
}

Examples

See examples/mcp/README.md for complete working examples:

# Terminal 1: Start server
./build/examples/mcp/mcp_example_server --verbose

# Terminal 2: Run client with demo
./build/examples/mcp/mcp_example_client --demo --verbose

The example server includes:

  • Resource registration and subscriptions
  • Tool execution (calculator, database query, system info)
  • Prompt templates
  • Session management
  • HTTP/SSE endpoints

Installation

Prerequisites

  • C++14 compiler (GCC 8+, Clang 10+, MSVC 2019+)
  • CMake 3.10+
  • libevent 2.1+
  • OpenSSL 1.1+ (optional, for TLS)

Build Options

# Debug build
make debug

# Release build
make release

# Static libraries only
cmake -B build -DBUILD_SHARED_LIBS=OFF

# Without C API
cmake -B build -DBUILD_C_API=OFF

# Custom install prefix
cmake -B build -DCMAKE_INSTALL_PREFIX=~/.local

Windows (Cygwin + MinGW)

Building on Windows requires Cygwin with MinGW-w64 toolchain:

Prerequisites

Install Cygwin with these packages:

  • make, cmake - Build tools
  • mingw64-x86_64-gcc-g++ - MinGW C++ compiler
  • mingw64-x86_64-libevent - Event library
  • mingw64-x86_64-openssl - SSL/TLS library

Build Commands

# From Cygwin bash shell
./build-mingw.sh           # Release build (default)
./build-mingw.sh debug     # Debug build
./build-mingw.sh release   # Release build
./build-mingw.sh clean     # Clean build directory

Output

  • Build directory: build-mingw/
  • Executable: build-mingw/examples/mcp/mcp_example_server.exe

Documentation

MCP C++ Documentation

MCP CPP Core Components

Design Documents

Comparison with Other C++ MCP SDKs

Several C++ implementations of the Model Context Protocol exist. They serve different needs — this table is meant to help you pick the right one:

gopher-mcp (this SDK)hkr04/cpp-mcpNeumann-Labs/mcp-cpp
FocusProduction / enterprise deploymentsLightweight, minimal footprintModern C++20 framework
MCP spec version2025-06-18, 2025-11-25, 2026-07-282025-03-262025-11-25 (in progress)
C++ standardC++14 / 17 / 20C++17C++20
Transportsstdio, HTTP+SSE, HTTPS, Streamable HTTP, WebSocket, TCPstdio, HTTP+SSEstdio, HTTP
Client + serverYesYesYes
TLSYesYes (build flag)
Event modelEvent-driven dispatcher (libevent), thread-safe by design
ResilienceConnection pooling, circuit breaker, rate limiting, backpressure
ObservabilityMetrics, tracing hooks, structured logging
Language bindingsPython, TypeScript, Go, Rust, Java, C#, Ruby via stable C APIC++ onlyC++ only
LicenseApache-2.0MITMIT

If you need a small dependency for a quick stdio tool, a lightweight SDK like cpp-mcp is a fine choice. If you need an MCP C++ SDK for production — long-lived connections, multiple transports, observability, or calling the SDK from other languages — that is what gopher-mcp is built for.

FAQ

What is the Model Context Protocol?

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).

Why use C++ for MCP?

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.

Does this work with Claude, GPT, and other AI models?

Yes. MCP is model-agnostic. Any AI system that supports MCP can use servers built with this SDK.

How do I integrate with my Python/Node.js application?

Use the C API bindings. The SDK provides a stable C interface that can be called from any language with FFI support.

Is this production-ready?

Yes. The SDK includes connection pooling, circuit breakers, rate limiting, TLS support, and comprehensive error handling suitable for enterprise deployments.

What transports are supported?

  • stdio - Standard input/output (CLI tools)
  • HTTP+SSE - HTTP with Server-Sent Events (web applications)
  • HTTPS+SSE - Secure HTTP+SSE
  • WebSocket - Bidirectional real-time
  • TCP - Raw TCP sockets

How does this compare to cpp-mcp and other C++ MCP libraries?

See the comparison table. In short: gopher-mcp targets production use — more transports (Streamable HTTP, WebSocket, TCP), connection pooling, circuit breakers, observability, and multi-language bindings — while lighter SDKs optimize for minimal footprint.

How do I contribute?

See CONTRIBUTING.md for guidelines. Issues and pull requests welcome!

Adopters

Using this MCP C++ SDK in your product or project? We'd love to list you here — open a pull request or issue to add yourself.

Keywords & Search Terms

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++

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

License

Apache License 2.0 - see LICENSE for details.

Related Projects

常见问题

What is gopher-mcp?

gopher-mcp is an open-source mcp servers skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by GopherSecurity. 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#. It has 141 GitHub stars.

Is gopher-mcp safe to use?

Yes. gopher-mcp passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install gopher-mcp?

Clone the repository with "git clone https://github.com/GopherSecurity/gopher-mcp" and add it to your Claude Code skills directory (see the Installation section above).

What programming language is gopher-mcp written in?

gopher-mcp is primarily written in C++. It is open-source under GopherSecurity on GitHub, so you can review or fork the full source.

Are there alternatives to gopher-mcp?

Yes. SkillsLLM lists many other MCP Servers skills you can browse and compare side by side. Open the MCP Servers category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh gopher-mcp against similar tools.

评论 (0)

暂无评论,成为第一个分享想法的人!

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

Scrapling

by D4Vinci

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

75,9137,581Python
MCP 服务器
查看详情

TrendRadar

by sansan0

⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。

61,65224,883Python
MCP 服务器
查看详情

context7

by upstash

Context7 Platform -- Up-to-date code documentation for LLMs and AI code editors

61,0602,938TypeScript
MCP 服务器
查看详情

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

39,9393,219C
MCP 服务器
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情