Factory function that returns a configured server —
either an AdcpServer from createAdcpServer() or a raw SDK McpServer
from createTaskCapableServer(). Called once per request so each gets a
fresh instance (a server can only be connected once). Receives a
ServeContext with a shared taskStore and the resolved host —
branch on host to return host-specific handlers in multi-host mode.
Optionaloptions: ServeOptionsPort, path, and callback configuration.
The http.Server instance. Use the onListening callback or
listen for the 'listening' event to know when it's ready.
Start an HTTP server that serves an AdCP MCP agent.
Creates a new MCP server instance per request (stateless), wires up the StreamableHTTPServerTransport, and returns the underlying http.Server for lifecycle control.
A shared task store is created once and passed to the factory on every request via
ServeContext. This ensures MCP Tasks (create → poll → result) work correctly across stateless HTTP requests.Multi-host. Pass functions for
publicUrlandprotectedResourceand branch onctx.hostin the factory to front multiple hostnames from one process. The framework resolves host fromX-Forwarded-Host(whentrustForwardedHost: true) orHost, threads it throughServeContext, and caches per-hostpublicUrl/PRM so each hostname advertises its own audience-boundresource.