OptionalauthAuthentication configuration.
Enables OAuth 2.1 or custom token verification on the server.
When configured, the /mcp endpoint requires Bearer authentication.
Health and metrics endpoints remain unauthenticated for probes.
Only relevant for HTTP-based transports — stdio mode does not support authentication (a warning is logged if configured).
createServer({
name: 'my-server',
version: '1.0.0',
transport: { mode: 'http' },
auth: {
provider: myOAuthProvider,
issuerUrl: new URL('https://auth.example.com'),
requiredScopes: ['mcp:read'],
},
});
OptionalcapabilitiesServer capabilities to advertise.
OptionalhandlersCustom protocol handler hooks.
Allows customizing behavior when MCP protocol events occur. The framework handles protocol compliance - these are for app logic.
Note: Cancellation is handled automatically by the framework.
OptionalhealthHealth endpoint configuration for API connectivity monitoring.
Wires a ConnectionStateManager to the /ready endpoint so
readiness probes reflect the actual API connection state.
OptionallifecycleLifecycle hooks for startup/shutdown.
Server name displayed to MCP clients.
OptionalonCalled before the OpenTelemetry SDK is initialized.
Power users can use this callback to configure low-level OTEL APIs before the framework creates the NodeSDK instance. Common use cases:
DiagLogger via diag.setLogger() for SDK-level
diagnostics (by default no DiagLogger is set — output is suppressed)The callback runs after framework config resolution but before
OTEL_LOG_LEVEL is consumed from process.env and SDK construction.
If you set a DiagLogger here, the framework will not override it.
Important: Custom DiagLoggers must NOT write to stdout (reserved for MCP protocol data in stdio transport mode).
OptionalsessionSession management configuration.
Fine-tune session lifecycle behavior (timeouts, cleanup intervals, capacity). Only relevant for HTTP-based transports — stdio always uses a single session with no background tasks.
All values are optional and fall back to environment variables / config file defaults from the standard config cascade.
OptionalshutdownShutdown configuration.
OptionaltelemetryEnable OpenTelemetry tracing and metrics.
When set via createServer(), this is resolved from:
telemetry option (highest priority)OTEL_ENABLED env var or config file (fallback)OptionaltelemetryOpenTelemetry service name.
Transport configuration (required).
Explicitly specify how the server communicates with clients.
Use { mode: 'stdio' } for CLI usage or { mode: 'http' } for network usage.
Server version (typically from package.json).
Complete server configuration options.
This interface provides a declarative way to configure an MCP server. All options have sensible defaults.
Example