I turned my Hono API into an MCP server by changing one import
Описание и применение
Преобразуйте API на Hono в сервер MCP, заменив один импорт, чтобы агенты могли вызывать эндпоинты без дублирования схем.
Задача
Expose an existing Hono API to AI agents without duplicating endpoint definitions.
Результат
The bridge turns a Hono app into an MCP server with a single import change, eliminating duplicate tool definitions and preserving existing validation and middleware.
Рабочий процесс
- Import
mountMcpfromhono-mcp-bridgeand replacezValidatorimport. - Call
mountMcp(app)to register every route as an MCP tool. - The bridge walks
app.routes, extracts schemas viaz.toJSONSchema, and exposes them as tools. - Agents invoke tools by sending JSON RPC requests to
/mcp; the bridge forwards arguments as a real HTTP request to the original handler. - Validation, auth, logging, and rate limits are preserved.
- Optional configuration (
include,exclude,methods,describeTool,allowedOrigins) limits exposed tools and origins.
Доказательства
Method, path, parameters, types, even descriptions: everything an agent needs is already there.
mountMcp(app) // POST /mcp: every route is now a tool
A tool call is a real request. Arguments become a Request passed to app.fetch()
Agents act with the credentials of whoever connected them. Use include, exclude or methods: ['GET'] to limit what is exposed
- Дата записи: 2026-10-19T17:41:18.192Z