Skip to main content
These recipes show the adapter boundary. Each assumes a Toolgrain server with registered tools; see the complete examples for runnable applications and lifecycle handling. Mount combined handlers at the application root so auth metadata is reachable.

Express

Matched MCP responses keep their protocol/auth status; unrelated paths call Express’s next before reading the body. Close both the application listener and Toolgrain server on shutdown.

Hono

The application owns Node listener shutdown and server.close().

Elysia

Run supported Bun applications on 1.4.4 or later within 1.x. The repository also has a protected Clerk Elysia example, kept separate from its ordinary credential-free flow.

Next.js App Router

For an unprotected endpoint, define the server once in a route module and export its Web handler:
app/mcp/route.ts
Here lib/server.ts is your module exporting a composed server. Use explicit metadata factories in a matching well-known route when protecting a filesystem-routed endpoint; exporting /mcp alone does not make the public metadata path routable. Apply the same production host settings to both handlers. See authorization integration. The examples independently test plain Node, Express, Hono, Elysia, and Next.js. Fastify and NestJS are not separately verified; do not infer a tested integration from shared Request/Response types.