Skip to main content

Configuration

The central configuration object is ServerConfig, accepted by startAdminServer(). Related context types flow into tool execution.

ServerConfig​

Only port is required.

FieldTypeDefaultDescription
portnumber— (required)TCP port to bind, integer 0–65535.
hoststring"127.0.0.1"Interface to bind; loopback by default to avoid accidental exposure.
apiKeystringundefinedShared secret required by the admin API and HTTP transport when set.
specPathstringundefinedSpecification loaded once at startup.
baseUrlOverridestringundefinedOverrides the upstream base URL derived from servers[0].url.
upstreamHeadersRecord<string, string>undefinedHeaders merged into every upstream request.
requestTimeoutMsnumberundefinedPer-request upstream timeout in milliseconds.
persistStatebooleantruePersist the loaded specification across restarts.
stateFilePathstringundefinedLocation of the persisted state file.
allowedOriginsstring[]undefinedAllowed CORS origins; empty/omitted disables cross-origin access.
allowedHostsstring[]undefinedAllowed Host header values.
maxLogEntriesnumber200Maximum in-memory log entries retained.
redactSensitiveHeadersbooleantrueRedact sensitive header values before logging.
redactHeaderNamesstring[]undefinedExtra header names to redact beyond the built-in list.
securitySecurityContextundefinedCredentials forwarded to the upstream API for every tool call.

SecurityContext​

FieldTypeSent as
bearerTokenstringAuthorization: Bearer <token>
basicAuth{ username, password }Authorization: Basic <base64>
apiKeysRecord<string, string>Exact header-name to value pairs.

Credentials are injected by the executor and are never exposed as model-facing tool arguments.

ExecutionContext​

Per-call context passed to executeToolCall and returned by a ContextProvider:

FieldTypeDescription
baseUrlOverridestringOverrides the spec's server URL for this call.
upstreamHeadersRecord<string, string>Extra upstream headers.
requestTimeoutMsnumberPer-call timeout (clamped to a 1s minimum).
securitySecurityContextPer-call credentials.
correlationIdstringCorrelates log entries for one invocation.
protocolProtocolHintTransport that initiated the call.
onLog(entry) => voidReceives request/response log entries; must never throw.
signalAbortSignalCancels an in-flight upstream request.

Literal unions and guards​

UnionValuesGuard function
TransportMode"stdio" | "web"—
SpecSource"startup-file" | "upload" | "paste" | "runtime"isSpecSource()
ServiceStatus"running" | "stopped" | "error"isServiceStatus()
ProtocolHint"streamable-http" | "sse" | "stdio"isProtocolHint()
LogDirection"request" | "response" | "internal"—
LogLevel"debug" | "info" | "warn" | "error"—
ParameterLocation"path" | "query" | "header" | "cookie"isParameterLocation()
BodyEncoding"json" | "form-urlencoded" | "multipart" | "text" | "binary"isBodyEncoding()

BuildMcpServerOptions​

Passed as the third argument to buildMcpServer():

FieldTypeDefaultDescription
protocolProtocolHintundefinedAdvertised protocol hint.
namestring"openapi-mcp"Advertised server name.
versionstring"1.1.0"Advertised server version.
pageSizenumber100Max entries per list response (capped at 500).
instructionsstringbuilt-inHuman usage hint exposed via MCP instructions.

Transport layer options (AttachMcpRoutesOptions)​

Import attachMcpRoutes from @powerduck/openapi-mcp-server and pass an options object as its second argument. The legacy attachSseRoutes() wrapper accepts only positional (app, specProvider, contextProvider, routeGuard?) arguments.

FieldTypeDefaultDescription
specProviderSpecProvider— (required)Supplies the document for new sessions.
contextProviderContextProvider— (required)Supplies the upstream context for each call.
routeGuardRequestHandlerundefinedMiddleware applied to every MCP route.
maxSessionsnumber64Concurrent session cap.
sessionIdleMsnumber600000Idle timeout in milliseconds; 0 disables it.
allowedOriginsstring[]undefinedAllowed origins; a non-empty list enables DNS-rebinding protection.
allowedHostsstring[]undefinedAllowed Host header values.
enableLegacySsebooleantrueMount the deprecated HTTP+SSE transport.
onEvent(event: McpSessionEvent) => voidundefinedReceives lifecycle events; must never throw.

These are options for attachMcpRoutes, not additional ServerConfig fields. The admin server forwards its origin and host settings, but uses the transport's default session limit and idle timeout. Use the public transport function directly when you need to customize those limits.

See also​