MCP Server Framework - v1.0.0
    Preparing search index...

    Interface SessionConfigOptions

    Session configuration options for the programmatic API.

    Allows fine-tuning session lifecycle behavior directly from createServer() or McpServerBuilder.withOptions(). All properties are optional — defaults are resolved from environment variables and config files via the standard config cascade.

    This is particularly useful for "lightweight stateful" deployments where short session timeouts are preferred over full stateless mode, retaining cross-request features (cancellation, sampling, elicitation) that stateless mode cannot support.

    // Lightweight stateful — short-lived sessions with all MCP features
    createServer({
    name: 'my-server',
    version: '1.0.0',
    transport: { mode: 'http' },
    session: {
    timeoutMs: 60_000, // 1 minute instead of default 30 min
    cleanupIntervalMs: 10_000, // Check every 10s
    },
    });

    // Custom session store for horizontal scaling
    createServer({
    name: 'my-server',
    version: '1.0.0',
    transport: { mode: 'http' },
    session: { store: new RedisSessionStore() },
    });

    SessionConfig for default values

    interface SessionConfigOptions {
        cleanupIntervalMs?: number;
        keepAliveIntervalMs?: number;
        maxMissedHeartbeats?: number;
        maxSessions?: number;
        store?: SessionStore;
        timeoutMs?: number;
    }
    Index

    Properties

    cleanupIntervalMs?: number

    Interval between cleanup sweeps in milliseconds.

    The housekeeper checks for expired/stale sessions at this interval. Set to 0 to disable cleanup (e.g., stdio mode).

    60_000 (60 seconds, from MCP_SESSION_CLEANUP_INTERVAL_MS)
    
    keepAliveIntervalMs?: number

    Keep-alive heartbeat interval in milliseconds.

    The housekeeper sends keep-alive pings at this interval to detect dead connections. Set to 0 to disable heartbeats.

    30_000 (30 seconds, from MCP_SESSION_KEEP_ALIVE_INTERVAL_MS)
    
    maxMissedHeartbeats?: number

    Maximum missed heartbeats before a session is considered stale.

    3 (from MCP_SESSION_MAX_MISSED_HEARTBEATS)
    
    maxSessions?: number

    Maximum concurrent sessions across all transports.

    200 (from MCP_MAX_SESSIONS)
    
    store?: SessionStore

    Custom session store implementation.

    When provided, replaces the built-in in-memory session store. Useful for horizontal scaling with Redis, PostgreSQL, or another shared backend.

    InMemorySessionStore
    
    timeoutMs?: number

    Session timeout in milliseconds.

    Sessions inactive for longer than this value are cleaned up by the housekeeper. Lower values create "lightweight" sessions that free resources faster.

    1_800_000 (30 minutes, from MCP_SESSION_TIMEOUT_MS)