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 (via startAdminServer)

The internal attachMcpRoutes function powers the admin server's HTTP transport. These options are configured through ServerConfig fields when using startAdminServer(). The public attachSseRoutes() function accepts only positional (app, specProvider, contextProvider, routeGuard?) arguments.

ServerConfig fieldTypeDefaultDescription
maxSessions (internal)number64Concurrent session cap.
sessionIdleMs (internal)number600000Idle reaper timeout; 0 disables.
allowedOriginsstring[]undefinedAllowed CORS origins; enables DNS-rebinding protection.
allowedHostsstring[]undefinedAllowed Host header values.
enableLegacySse (internal)booleantrueMount the deprecated HTTP+SSE transport.

These are implementation details of the admin server. For most use cases, startAdminServer(config) with the documented ServerConfig fields is sufficient. attachMcpRoutes itself is not exported from the package root.

See also