TB

tigranbs/bun-mcp-sse-transport

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

13 stars 6 forks 质量 27 趋势 20

Bun Server Transport 用于 MCP - MCP SSE 的应用

概览

使用 Bun 的模拟环境协议(MCP)的服务器-恒星事件(SSE)传输执行. 这个软件包为MCP服务器提供了一个Bun特定执行SSE运输的功能. 它能够利用SSE协议从服务器到客户端的实时单向通信,客户端到服务器的通信通过HTTP POST请求处理. - 专门为 Bun 运行时间所建 - 执行 MCP 传输接口 - 管理 SSE 连接与正信头 - 处理收到的 JSON- RPC 消息 - 与 Bun. serve 的简单集成 1. 当客户端连接/sse时,服务器创建了SSE连接 2. 服务器发送端点 URL 客户端应当在此 POST 消息 3 。 客户端将JSON-RPC消息发送到端点URL 4. 服务器接收到这些消息并传递到MCP服务器 5.

概述(AI 翻译)

使用 Bun 的模拟环境协议(MCP)的服务器-恒星事件(SSE)传输执行.

□ 概览

这个软件包为MCP服务器提供了一个Bun特定执行SSE运输的功能. 它能够利用SSE协议从服务器到客户端的实时单向通信,客户端到服务器的通信通过HTTP POST请求处理.

□ 关键特性

  • 专门为Bun运行时间建造
  • 实施MCP运输接口
  • 管理与适当信头的SSE连接
  • 处理收到的JSON-RPC消息
  • 与 Bun.serve 的简单整合

快速使用( X)

如何运作

  1. 当客户端连接到/sse时,服务器创建了SSE连接
  2. 服务器发送端点 URL, 客户端应在其中发送 POST 消息
  3. 客户端向端点 URL 发送 JSON- RPC 消息
  4. 服务器接收这些消息并传递给MCP服务器
  5. MCP服务器通过SSE连接处理消息并发送回复

这一实施遵循了MCP标准,同时利用Bun的流电能力来高效地实时通信.

本页由 AI 翻译,技术细节请以原文为准。

README

bun-mcp-sse-transport

A Server-Sent Events (SSE) transport implementation for the Model Context Protocol (MCP) using Bun.

Overview

This package provides a Bun-specific implementation of SSE transport for MCP servers. It enables real-time, one-way communication from server to client using the SSE protocol, with client-to-server communication handled via HTTP POST requests.

Key Features

  • Built specifically for Bun runtime
  • Implements the MCP transport interface
  • Manages SSE connections with proper headers
  • Handles incoming JSON-RPC messages
  • Simple integration with Bun.serve

Quick Usage

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { BunSSEServerTransport } from "bun-mcp-sse-transport";

// Create SSE transport
const transport = new BunSSEServerTransport("/messages");

// Connect to MCP server
const server = new McpServer({ name: "MyServer", version: "1.0.0" });
server.connect(transport);

// Set up Bun HTTP server
Bun.serve({
  port: 3000,
  routes: {
    "/sse": () => transport.createResponse(),
    "/messages": (req) => transport.handlePostMessage(req)
  }
});

How It Works

  1. When a client connects to /sse, the server creates an SSE connection
  2. The server sends the endpoint URL where the client should POST messages
  3. The client sends JSON-RPC messages to the endpoint URL
  4. The server receives these messages and passes them to the MCP server
  5. The MCP server processes the messages and sends responses via the SSE connection

This implementation follows the MCP standard while leveraging Bun’s streaming capabilities for efficient real-time communication.

在 GitHub 查看完整 README

安装

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

Open the repository installation guide 新手?先看 mcpskill.org 教程 →