NI

nerding-io/mcp-sse-example

Developer tools

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

50 stars 17 forks 品質 43 トレンド 0

nerding-io/mcp-sse-example は [https://github.com/nerding-io/mcp-sse-example.] からインポートされた MCP サーバー候補です

概要

nerding-io/mcp-sse-example は [https://github.com/nerding-io/mcp-sse-example.] からインポートされた MCP サーバー候補です

概要(AI 翻訳)

トランスポートレイヤーとして、サーバー・セント・イベント(SSE)を使用して、モデル・コンテキスト・プロトコル(MCP)機能をWebアプリケーションに統合するためのリファレンス・実装です。

概要

このプロジェクトでは、SSE トランスポートプロトコルを使用してクライアントと通信する MCP サーバーを作成する方法を説明します。 Webアプリケーションは、AIモデルとのリアルタイム通信のための永続的な接続を維持しながら、強力なMCP機能にアクセスすることができます。

主な機能:

  • Web の互換性のための Server-Sent イベントを使用して MCP サーバーを実装
  • ウェブクライアントからアクセスできるカスタムMCPツールを作成する
  • MCP 互換クライアントを SSE ベースのサーバーに接続
  • 標準化されたプロトコルによるWebベースの機能でAIアシスタントを拡張

MCP SSEとは?

モデルコンテキストプロトコル(MCP)は、SSEがWebアプリケーションに理想的である複数の輸送メカニズムをサポートしています。

-Server-Sent Events(SSE):サーバーがクライアントに更新をプッシュできる一方向接続を確立するためのWeb標準

  • SSE上のMCP: トランスポートレイヤーとしてSSEを使用してMCPプロトコルを実装し、WebクライアントがMCPサーバーとやり取りできるようにします

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

README

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

MCP Server-Sent Events (SSE) - Example

A reference implementation for integrating Model Context Protocol (MCP) capabilities into web applications using Server-Sent Events (SSE) as the transport layer.

Overview

This project demonstrates how to create an MCP server that communicates with clients using the SSE transport protocol. It enables web applications to access powerful MCP capabilities while maintaining a persistent connection for real-time communication with AI models.

Key features:

  • Implement MCP servers using Server-Sent Events for web compatibility
  • Create custom MCP tools that can be accessed from web clients
  • Connect any MCP-compatible client to your SSE-based server
  • Extend AI assistants with web-based capabilities through standardized protocols

What is MCP SSE?

The Model Context Protocol (MCP) supports multiple transport mechanisms, with SSE being ideal for web applications:

  • Server-Sent Events (SSE): A web standard for establishing a unidirectional connection where servers can push updates to clients
  • MCP over SSE: Implements the MCP protocol using SSE as the transport layer, enabling web clients to interact with MCP servers
  • Real-time AI interactions: Allows continuous streaming of AI responses while maintaining tool execution capabilities

Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • NPM or Yarn
  • A Brave Search API key for the example search tool

Installation

# Clone the repository
git clone https://github.com/yourusername/mcp-sse-example.git
cd mcp-sse-example

# Install backend dependencies
cd backend
npm install

Configuration

Create a .env file in the backend directory with your API credentials:

BRAVE_API_KEY=your_api_key_here

Usage

Starting the Server

# Build and start the server
npm run build
npm run start

The MCP SSE server will be available at http://localhost:3001.

Docker Deployment

# From the project root
docker-compose up -d

How It Works

This implementation uses:

  1. Express.js as the web server
  2. SSEServerTransport from the MCP SDK to handle the SSE protocol
  3. McpServer to register and manage tools

The server exposes two main endpoints:

  • /sse - For establishing SSE connections
  • /messages - For receiving messages from clients

Example Implementation

The core server implementation:

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import express from "express";

const server = new McpServer({
  name: "Example SSE Server",
  version: "1.0.0",
});

// Register tools
server.tool("example_tool", { param: z.string() }, async ({ param }) => ({
  content: [{ type: "text", text: `Processed: ${param}` }],
}));

const app = express();
let transport: SSEServerTransport;

app.get("/sse", async (req, res) => {
GitHub で README 全文を見る

インストール

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

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