Overview
Sunpeak provides three ways to run a production MCP server, from zero-config to full control:| Approach | Use case |
|---|---|
sunpeak start | Zero-config — loads tools, resources, and auth from dist/ automatically |
createMcpHandler | Node.js — mount the MCP handler on your own Express/Fastify/http server |
createHandler | Web Standard — Cloudflare Workers, Deno, Bun, Vercel Edge |
sunpeak start auto-discovers tools from dist/tools/, resources from dist/{name}/, and auth from dist/server.js, then passes them to startProductionHttpServer internally.
createMcpHandler and createHandler accept these as config objects — you load and pass them yourself. This gives full control over how tools, resources, and auth are provided.
All three use MCP Streamable HTTP transport on a single /mcp endpoint.
createMcpHandler
Creates a Node.js request handler for MCP over Streamable HTTP.
POST /mcp, GET /mcp, DELETE /mcp, and OPTIONS /mcp. For unmatched paths it does nothing, so you can chain it with your own routes.
Example: Express
ProductionServerConfig
Server name reported to hosts during MCP handshake.
Server version reported to hosts.
Tool registrations. Each has a
name, tool config (resource reference, title, description), optional schema (Zod shape for input validation), and handler function.Resource registrations. Each has a
name, uri, html (self-contained HTML string), and optional _meta.Auth function called on every request. Return
AuthInfo to authenticate, null to reject with 401. See Server Entry.createHandler
Creates a Web Standard request handler for serverless and edge runtimes.
createMcpHandler, this handler does not do path matching — it handles every request it receives. Mount it behind your own router.
Example: Cloudflare Worker
Example: Hono
WebHandlerConfig
Same shape as ProductionServerConfig, except auth takes a Web Standard Request:
Auth function for Web Standard environments. Return
AuthInfo to authenticate, null to reject with 401.startProductionHttpServer
The built-in HTTP server used by sunpeak start. A convenience wrapper around createMcpHandler that adds a root page, favicon, and graceful shutdown.
sunpeak start instead of calling this directly.