honojs-middleware/packages/mcp
Aditya Mathur 1baa0b281d
feat: added @hono/mcp package (#1178)
* feat: added hono/mcp package

* chore: changeset

* chore: minor changes

* chore: minor changes

* chore: formated the code

* chore: minor correction

* chore: removed changelog file

* chore: changed the class name

* chore: updated the readme

* fix: closed the stream

* chore: minor change

* fix: added an interval to keep the connection alive and merge 2 streams into a single one

* chore: updated lockfile

* fix: stupid mistake 😅

* chore: formatted the README.md file

* chore: minor change

* chore: minor changes

* chore: minor change

* add an explicit return type annotation

* format the code

---------

Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
2025-06-18 07:07:30 +09:00
..
src feat: added @hono/mcp package (#1178) 2025-06-18 07:07:30 +09:00
README.md feat: added @hono/mcp package (#1178) 2025-06-18 07:07:30 +09:00
package.json feat: added @hono/mcp package (#1178) 2025-06-18 07:07:30 +09:00
tsconfig.build.json feat: added @hono/mcp package (#1178) 2025-06-18 07:07:30 +09:00
tsconfig.json feat: added @hono/mcp package (#1178) 2025-06-18 07:07:30 +09:00
tsconfig.spec.json feat: added @hono/mcp package (#1178) 2025-06-18 07:07:30 +09:00
vitest.config.ts feat: added @hono/mcp package (#1178) 2025-06-18 07:07:30 +09:00

README.md

Hono MCP (Model Context Protocol)

Connect Hono with a Model Context Protocol (MCP) server over HTTP Streaming Transport.

Usage

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

const app = new Hono()

// Your MCP server implementation
const mcpServer = new McpServer({
  name: 'my-mcp-server',
  version: '1.0.0',
})

app.all('/mcp', async (c) => {
  const transport = new StreamableHTTPTransport()
  await mcpServer.connect(transport)
  return transport.handleRequest(c)
})

export default app

Author

Aditya Mathur https://github.com/mathuraditya724

License

MIT