Use the supported server entry point when your Node application should own the HTTP listener and authentication. The handler consumes an extracted discovery bundle; it doesn't compile source or start a service. This hosting path needs a separate discovery export even though the backend also uses Node. When Shoalrun's built-in Node server or generated Vercel function hosts MCP, its build already includes that data and no separate export is required.
Before you begin
You need Node.js 22.12 or newer, Shoalrun, and a discovery bundle for the intended content selection. Your framework must be able to pass a standard Request to a route and send the returned Response.
Open a handler for one bundle
Import the server-only entry point in your backend:
import { createMcpHandler } from '@shoalrun/cli/mcp/server'; const handleMcp = await createMcpHandler({ directory: './releases/example/discovery', path: '/mcp', allowedHosts: ['docs.example.com'], allowedOrigins: ['https://app.example.com'], });Replace the directory and hostnames with your deployment values.
directoryandallowedHostsare required. The path defaults to/mcp; origins default to an empty list. The handler binds to the bundle's publication and revision.Route authorized requests to the handler
After your host has routed and authorized an incoming request, call:
const response = await handleMcp(request);Send that response through your framework's normal route integration. The host provides the listener, TLS, authentication, traffic controls, and shutdown behavior. Allowed-host and origin checks aren't user authentication. Bind each handler to the selected bundle it should serve.
The MCP route supports POST requests and OPTIONS preflight. It doesn't provide a persistent session or standalone event stream. Responses use
Cache-Control: no-store.Check the endpoint
Connect your MCP client to
https://docs.example.com/mcp. Confirm it discoversget_publications,search_docs,get_page,get_outline, andget_section. Search for a known page and follow its returned read instruction.Run the adapter conformance checker against that endpoint and its exact bundle. Requesting another publication or an unknown page must fail rather than reading another build.
Update the deployment
Publish a complete bundle in a new immutable directory, open a replacement handler, and switch traffic after verification. Each read checks actual bytes against the opened inventory. Changed bytes fail instead of being served under the old revision. This API doesn't maintain a revision archive for you.
The existing shoalrun serve and generated Vercel endpoint remain alternatives when you don't need an embedded route. See connect an MCP client for those hosting paths.
HTML, Markdown, and agents
The handler returns read-only discovery and Markdown through MCP. It doesn't serve the HTML website or apply its theme. Agents receive the selected bundle's content and publication scope. Use the separate Content REST handler when your application needs exported HTML fragments.