Skip to content

mountSpec

mountSpec(router, spec, options?: MountSpecOptions)
OptionDefaultDescription
basePath''Prefix for RPC paths and for paths baked into emitted documents
docstruePass false to disable /docs, /callspec.json, and /openapi.json at the mount root
docsPath'/docs'Docs UI path on this router (callspec.json and openapi.json paths are fixed)
mcpPath'/mcp'MCP HTTP endpoint on this router
loggingtruejsout-express request log on this router + jsout error log on unhandled throws; pass false in tests
handleUnhandledError(err, req) => RouteFailure | undefined — map infra throws before INTERNAL_ERROR
logUnhandledErrorjsout logger.errorOverride unhandled-error logging only

When docs is enabled, the docs UI fetches callspec.json at /callspec.json on this router (fixed path). Override only the UI mount:

mountSpec(router, spec, {docsPath: '/explorer'});
// UI at /explorer — still loads ../callspec.json relative to that path

See Error handling § mountSpec runtime.

With app.use('/v1', router) and defaults, a server on port 3000 exposes:

SurfaceURL
Docs UIhttp://127.0.0.1:3000/v1/docs
Contracthttp://127.0.0.1:3000/v1/callspec.json
OpenAPIhttp://127.0.0.1:3000/v1/openapi.json
RPCPOST http://127.0.0.1:3000/v1/{methodName}
MCPhttp://127.0.0.1:3000/v1/mcp (when any route has mcp: true)

API reference