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

    Interface SessionStore

    Interface for session CRUD storage and lifecycle management.

    The built-in InMemorySessionStore uses a Map and is suitable for single-instance deployments.

    For horizontal scaling across multiple server instances, implement this interface with a shared backend (e.g., Redis, PostgreSQL).

    class RedisSessionStore implements SessionStore {
    // ... implement all methods with Redis as the backend
    }

    const manager = new SessionManagerImpl({
    store: new RedisSessionStore(redisClient),
    });
    interface SessionStore {
        size: number;
        stats: SessionStats;
        broadcastPromptListChanged(): void;
        broadcastResourceListChanged(): void;
        broadcastResourceUpdated(uri: string): void;
        broadcastToolListChanged(): void;
        create(options: CreateSessionOptions): Session | undefined;
        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;
        markShuttingDown(): void;
        remove(sessionId: string, reason: SessionCloseReason): Session | undefined;
        removeAll(): Session[];
        touch(sessionId: string): boolean;
    }

    Implemented by

    Index

    Properties

    size: number

    Number of active sessions

    Current statistics

    Methods

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

      Unlike list-changed broadcasts (sent to all sessions), this only notifies sessions that have subscribed to the specific resource URI via resources/subscribe.

      Parameters

      • uri: string

      Returns void