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

    Interface SessionManager

    Interface for managing sessions.

    Provides unified session lifecycle management for all transport types. Supports heartbeat monitoring, automatic cleanup, and broadcasting.

    interface SessionManager {
        size: number;
        stats: SessionStats;
        broadcastPromptListChanged(): void;
        broadcastResourceListChanged(): void;
        broadcastResourceUpdated(uri: string): void;
        broadcastToolListChanged(): void;
        close(sessionId: string, reason: SessionCloseReason): Promise<void>;
        closeAll(): Promise<void>;
        create(options: CreateSessionOptions): Session | undefined;
        dispose(): void;
        filter(
            predicate: (session: ReadonlySession) => boolean,
        ): Readonly<Session>[];
        forEach(
            callback: (session: ReadonlySession, sessionId: string) => void,
        ): void;
        get(sessionId: string): Session | undefined;
        getByTransportType(type: TransportType): Readonly<Session>[];
        has(sessionId: string): boolean;
        hasCapacity(): boolean;
        hasCapacityForTransport(transportType: TransportType): boolean;
        touch(sessionId: string): boolean;
    }

    Implemented by

    Index

    Properties

    size: number

    Number of active sessions

    Current statistics

    Methods

    • Broadcasts prompt list changed notification to all sessions. Called when dynamic prompts are added/removed.

      Returns void

    • Broadcasts resource list changed notification to all sessions. Called when dynamic resources are added/removed.

      Returns void

    • Sends a resource updated notification to sessions subscribed to the given URI.

      Only sessions that have called resources/subscribe for this URI receive the notifications/resources/updated notification.

      Parameters

      • uri: string

      Returns void

    • Gets a session by ID. Does NOT update activity time (use touch() for that).

      Parameters

      • sessionId: string

        Session identifier

      Returns Session | undefined

      The session if found and active

    • Checks if there's capacity for a specific transport type. Enforces per-transport limits (e.g., maxStreamableHttpSessions, maxSseSessions).

      Parameters

      • transportType: TransportType

        The transport type to check capacity for

      Returns boolean

    • Updates the last activity time for a session. Also resets missed heartbeat count.

      Parameters

      • sessionId: string

        Session identifier

      Returns boolean

      true if session was touched