HonoHub Logo

HonoHub

Stateless MCP

Create a stateless MCP with @hono/mcp

This is the simplest way to connect and host an MCP server. This way, you can handle all incoming requests without needing to reconnect to the transport for each request. The can be used when you don't need to maintain any state across multiple requests like user preferences, database connections, etc.

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StreamableHTTPTransport } from "@hono/mcp";
import { Hono } from "hono";

const app = new Hono();
const mcpServer = new McpServer({
	name: "my-mcp-server",
	version: "1.0.0",
});

const transport = new StreamableHTTPTransport();

app.all("/mcp", async (c) => {
    if (!mcpServer.isConnected()) {
        // Connecting the MCP server to the transport
        await mcpServer.connect(transport);
    }

    return transport.handleRequest(c);
});

export default app;

Characteristics

  • No memory of previous requests or responses
  • Each call is processed in isolation
  • Multiple clients can interact without interference
  • Easy to implement

Example Use Cases

  • Weather API MCP Server
  • Currency Conversion MCP Server
  • Password Generator MCP Server