HC

hkr04/cpp-mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

341 stars 85 forks 品質 72 トレンド 34MIT

軽量C++ MCP(モデルコンテキストプロトコル)SDK

概要

モデルコンテキストプロトコル(MCP)は、AIモデルやエージェントがさまざまなリソース、ツール、サービスとやり取りするための標準化された方法を提供するオープンプロトコルです。このフレームワークは、2025年3月26日の基本プロトコル仕様に準拠し、MCPプロトコルのコア機能を実装しています。 - : JSON-RPC 2.0標準に基づくリクエスト/レスポンス通信 - : ファイルやAPIなどのリソースの標準インターフェース - : 構造化パラメータを持つツールの登録と呼び出し - : AIワークフロー用にプロンプトテンプレートを登録し、クライアントに公開 - : 新しいリソースタイプやツールで簡単に拡張できる - : HTTPおよび標準的な入出力(stdio)通信方式をサポート ここに、このリポジトリを利用しているオープンソースプロジェクトを紹介します。もしあなたも使っているなら、ぜひPRを提出してここで紹介してください! - humanus.cpp: 軽量C++ LLMエージェントフレームワーク - ...あなたの貢献をお待ちしています...

概要(AI 翻訳)

モデルコンテキストプロトコル(MCP)は、AIモデルやエージェントがさまざまなリソース、ツール、サービスとやり取りするための標準化された方法を提供するオープンプロトコルです。このフレームワークは、2025年3月26日の基本プロトコル仕様に準拠し、MCPプロトコルのコア機能を実装しています。

コア機能

  • JSON-RPC 2.0 通信:JSON-RPC 2.0標準に基づくリクエスト/レスポンス通信
  • リソース抽象化:ファイルやAPIなどのリソースの標準インターフェース
  • ツール登録:構造化パラメータを持つツールの登録および呼び出し
  • プロンプトテンプレート:AIワークフローのためにプロンプトテンプレートを登録し、クライアントに公開する
  • 拡張可能なアーキテクチャ:新しいリソースタイプやツールで簡単に拡張できる
  • マルチトランスポートサポート:HTTPおよび標準入出力(stdio)通信方式をサポートします

ビルドの方法

CMakeで作る例:

テストでビルドする:

SSL対応ビルド:

採用者

ここに、このリポジトリを利用しているオープンソースプロジェクトをいくつかご紹介します。 もしあなたも使っているなら、ぜひPRを提出してここで紹介してください!

  • humanus.cpp:軽量C++ LLMエージェントフレームワーク
  • …あなたの貢献を待っています…

構成要素

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

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)
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →