bun -sse-transport
Bun Server Transport implementation for MCP - MCP SSE
claude mcp add --transport stdio tigranbs-bun-mcp-sse-transport bun -sse-transport
How to use
This MCP server provides a Bun-based Server-Sent Events (SSE) transport for the Model Context Protocol (MCP). It enables real-time, one-way updates from the server to MCP clients via SSE, while client-to-server messages are delivered over an HTTP POST endpoint. The transport is designed to integrate cleanly with Bun runtimes and Bun’s streaming capabilities, allowing efficient MCP communication with minimal latency. To use it, install the package and wire it into your MCP server, then expose two routes: one for establishing the SSE connection and another for receiving client messages via POST.
In typical usage, you create an MCP server instance, instantiate the BunSSEServerTransport with a designated SSE path (for example, /sse/messages), connect the transport to your MCP server, and then run a Bun server with routes that serve the SSE stream and handle incoming messages. Clients connect to the SSE endpoint to subscribe to real-time updates and POST their JSON-RPC messages to the specified message endpoint. The server then forwards those messages to the MCP core, which processes them and delivers responses back to clients over SSE.
How to install
Prerequisites:\n- Bun runtime installed on your system (https://bun.sh/)\n- Basic Node-style project structure or a Bun project setup\n\nStep 1: Install Bun (if not already installed)\nbash\n# Follow Bun's official installation guide if needed\ncurl -fsSL https://bun.sh/install | bash\n``\n\nStep 2: Initialize your project (if starting from scratch)\nbash\nmkdir bun-mcp-sse-transport-demo\ncd bun-mcp-sse-transport-demo\nbun init # or npm init, depending on your setup\n\n\nStep 3: Install the Bun SSE MCP transport package\n```bash\nbun add bun-mcp-sse-transport\n\n\nStep 4: Create your MCP server script (example)\ntypescript\n// server.ts\nimport { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";\nimport { BunSSEServerTransport } from "bun-mcp-sse-transport";\n\nconst transport = new BunSSEServerTransport("/messages");\n\nconst server = new McpServer({ name: "MyServer", version: "1.0.0" });\nserver.connect(transport);\n\nBun.serve({\n port: 3000,\n routes: {\n "/sse": () => transport.createResponse(),\n "/messages": (req) => transport.handlePostMessage(req)\n }\n});\n\n\nStep 5: Run the server\nbash\nbun run ts-node/server.ts # or your preferred Bun run method\n
Additional notes
Notes and tips:\n- Ensure Bun is installed and available in your system PATH to use bun commands.\n- The transport expects a dedicated SSE endpoint (e.g., /sse) to establish the streaming connection, and a separate POST endpoint (e.g., /messages) to receive client messages.\n- If you deploy behind a reverse proxy, configure appropriate HTTP/2 support for SSE and allow streaming responses.\n- Monitor connection health and handle reconnections on the client side, as SSE connections can drop and may need re-establishment.\n- The MCP server interactions rely on the standard MCP message flow (client sends JSON-RPC, server responds over SSE). Ensure CORS and authentication policies allow the required endpoints if used in a web environment.\n- You can customize the SSE route and POST route paths by passing different endpoints to the BunSSEServerTransport constructor and your Bun.serve routes.\n- If you encounter issues with Bun compatibility, verify that your Bun version supports the streaming features used by the transport.
Related MCP Servers
context7
Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
MiniMax -JS
Official MiniMax Model Context Protocol (MCP) JavaScript implementation that provides seamless integration with MiniMax's powerful AI capabilities including image generation, video generation, text-to-speech, and voice cloning APIs.
mcp-bun
Bun Javascript Runtime MCP Server for AI Agents
mcp-bundler
Is the MCP configuration too complicated? You can easily share your own simplified setup!
akyn-sdk
Turn any data source into an MCP server in 5 minutes. Build AI-agents-ready knowledge bases.
mcp-turso
MCP server for interacting with Turso-hosted LibSQL databases