This package provides a Server-Sent Events (SSE) transport layer specifically designed for Hono applications to interface with a Model Context Protocol (MCP) server. As of version `0.0.7`, it offers a working solution to a known incompatibility: the official `@modelcontextprotocol/sdk` is primarily built for Express.js, leading to issues with Hono's response handling for SSE. This library acts as an interim solution, enabling developers to integrate MCP servers with Hono by correctly managing SSE connections and message routing. Releases are currently rapid patch/minor versions, indicating active development in its early stages. Its primary differentiator is bridging this specific framework gap, ensuring proper header and stream management for Hono-based MCP server implementations, including robust handling of multiple simultaneous connections via session IDs.
npm install hono-mcp-server-sse-transportVerified import paths — ran on the pinned version, not inferred.
Demonstrates setting up a Hono server that acts as an MCP server, using SSE for client communication. It includes session management for multiple concurrent connections.
Monitor the `@modelcontextprotocol/sdk` repository for official Hono integration. Be prepared to migrate if official support is released.
Ensure all imports for `hono-mcp-server-sse-transport` use the direct, top-level named exports as shown in the documentation and examples (e.g., `import { SSETransport } from 'hono-mcp-server-sse-transport';`).Implement robust session management, including proper `onAbort` handlers to remove disconnected clients from the `transports` lookup, and consider strategies for handling stale or unclosed connections.
Ensure your SSE client-side logic is resilient to the order of initial events or specifically handles a 'ping' event before other setup events.
Verify that the client is sending the correct `sessionId` that corresponds to an established SSE connection. Ensure the server-side `transports` object correctly tracks and cleans up connections.
Use the correct deep import path: `import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';`Import `streamSSE` from the correct Hono submodule: `import { streamSSE } from 'hono/streaming';`Ensure you are using `import { SSETransport } from 'hono-mcp-server-sse-transport';` at the top of your TypeScript/ESM file.