Hono Mcp Server Sse Transport

hono-mcp-server-sse-transport

Server-Sent Events transport for Hono and Model Context Protocol

0 downloads
v0.0.7

Capabilities

tools

Installation

Quick Install

Install using the MCPSearch CLI (recommended)

mcp install hono-mcp-server-sse-transport

Don't have the CLI? Install it first

Run with npx

Run directly without installing

npx -y hono-mcp-server-sse-transport

Manual Configuration

Add to your MCP client configuration file

CClaude Code / Claude Desktop

Add to ~/.claude/claude_desktop_config.json

{
  "mcpServers": {
    "hono-mcp-server-sse-transport": {
      "command": "npx",
      "args": [
        "-y",
        "hono-mcp-server-sse-transport"
      ]
    }
  }
}

CuCursor

Add to ~/.cursor/mcp.json

{
  "mcp": {
    "servers": {
      "hono-mcp-server-sse-transport": {
        "command": "npx",
        "args": [
          "-y",
          "hono-mcp-server-sse-transport"
        ]
      }
    }
  }
}

VSVS Code / Continue.dev

Add to .vscode/mcp.json or Continue settings

{
  "mcpServers": {
    "hono-mcp-server-sse-transport": {
      "command": "npx",
      "args": [
        "-y",
        "hono-mcp-server-sse-transport"
      ]
    }
  }
}

About

# MCP Server transport for Hono applications ## Overview This project provides a transport for Hono application that needs to connect to MCP Server. [An official TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk) is designed to be used with `express`. If you try and follow their instructions but change `express` with `hono`, you will find that it's not going to work. Even if you set `HttpBinding` as an env (see an example from [@hono/node-server](https://github.com/honojs/node-server?tab=readme-ov-file#accessing-nodejs-api)), it still doesn't work as some headers are being added to a response after it's sent. This implementation is inspired by the following [pull request](https://github.com/modelcontextprotocol/typescript-sdk/pull/178) You can use this transport until there is a proper support for Hono in the official SDK. ## Getting started ### Installation ```bash pnpm add -D hono-mcp-server-sse-transport ``` ### Usage ```typescript import { Hono } from 'hono'; import { serve } from '@hono/node-server'; import { streamSSE } from 'hono/streaming'; import { SSETransport } from 'hono-mcp-server-sse-transport'; import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; const mcpServer = new McpServer( { name: 'your-mcp-server-name', version: '1.0.0', }, { capabilities: { tools: {}, }, }, ); // here you add your tools // ... const app = new Hono(); // to support multiple simultaneous connections we have a lookup object from // sessionId to transport const transports: { [sessionId: string]: SSETransport } = {}; app.get('/sse', (c) => { return streamSSE(c, async (stream) => { const transport = new SSETransport('/messages', stream); transports[transport.sessionId] = transport; stream.onAbort(() => { delete transports[transport.sessionId]; }); await mcpServer.connect(transport); while (true) { // This will keep the connection alive // You can also await for a promise that never resolves await stream.sleep(60_000); } }); }); app.post('/messages', async (c) => { const sessionId = c.req.query('sessionId'); const transport = transports[sessionId]; if (transport == null) { return c.text('No transport found for sessionId', 400); } return await transport.handlePostMessage(c); }); serve( { fetch: app.fetch, port: 3000, }, ); ```

Reviews

No reviews yet. Be the first to review this package!

Compatible With

Claude CodeCursorWindsurfContinue.dev

Details

Version
0.0.7
License
MIT
Category
memory
MCP Version
1.0
Published
4/6/2025
Updated
5/22/2025