MCP SSE サーバーとクライアントの例
このリポジトリには、SSE (Server-Sent Events) ベースの MCP (Model Context Protocol) サーバーおよびクライアントの完全なサンプル実装が含まれています。
概要
モデルコンテキストプロトコル(MCP)は、AIシステム向けに設計された通信プロトコルです。この実装では、サーバー送信イベント(SSE)を使用してクライアントとのリアルタイム通信を行うMCPサーバーの作成方法を示します。
特徴
SSEベースのMCPサーバー:Express.jsとMCP SDKのSSEServerTransportを使用してサーバーを実装します。
インタラクティブMCPクライアント:SSEサーバーに接続するクライアント実装を提供します
ツールの実装: 適切な説明が付いたサンプルツール(加算、乗算)が含まれています
動的リソース: URIパターンを使用した動的リソーステンプレートのデモンストレーション
デバッグサポート: 詳細なログ記録とデバッグ構成が含まれています
コンポーネント
server.js
- StdioServerTransport を使用した基本的な MCP サーバーsse-server.js
- Express.js で SSEServerTransport を使用する MCP サーバーclient.js
- 基本サーバーのクライアントsse-client.js
- SSEサーバーのクライアント
はじめる
依存関係をインストールします:
SSE サーバーを起動します。
別のターミナルで、SSE クライアントを実行します。
サーバー機能
SSE サーバーは以下を提供します。
加算と乗算のツールエンドポイント
テンプレートをサポートする動的な挨拶リソース
複数のクライアントに対する適切なセッション管理
デバッグのための詳細なログ
クライアントの機能
SSE クライアントは次のことを実証します。
SSEサーバーへの接続
利用可能なツールとリソースの一覧
パラメータを使用してツールを呼び出す
動的パラメータを使用したリソースの読み取り
URI テンプレート
サーバーは、URI テンプレートをクライアントに公開して、リソース URI を動的に構築する方法をクライアントが理解できるようにする方法を示します。
ライセンス
マサチューセッツ工科大学
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
リアルタイム通信用の Server-Sent Events (SSE) を使用した Model Context Protocol (MCP) サーバーの実装。計算および動的リソース テンプレート用のツールを提供します。
Related MCP Servers
- -securityAlicense-qualityMCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.Last updated -14MIT License
- -securityAlicense-qualityThis server implements the Model Context Protocol (MCP) to handle asynchronous tasks with real-time status tracking, robust error handling, and automatic resource management.Last updated -1MIT License
- AsecurityFlicenseAqualityA specialized server that helps users create new Model Context Protocol (MCP) servers by providing tools and templates for scaffolding projects with various capabilities.Last updated -81645
- AsecurityFlicenseAqualityA Model Context Protocol (MCP) server that interacts with system APIs, allowing users to check connections, search employees, register breakfast, and update chemical information by shifts.Last updated -219