MCP TypeScript SDK (V2)
    Preparing search index...

    Configuration options for WebStandardStreamableHTTPServerTransport

    interface WebStandardStreamableHTTPServerTransportOptions {
        allowedHosts?: string[];
        allowedOrigins?: string[];
        enableDnsRebindingProtection?: boolean;
        enableJsonResponse?: boolean;
        eventStore?: EventStore;
        onsessionclosed?: (sessionId: string) => void | Promise<void>;
        onsessioninitialized?: (sessionId: string) => void | Promise<void>;
        retryInterval?: number;
        sessionIdGenerator?: () => string;
        supportedProtocolVersions?: string[];
    }
    Index

    Properties

    allowedHosts?: string[]

    List of allowed Host header values for DNS rebinding protection. If not specified, host validation is disabled.

    Use external middleware for host validation instead.

    allowedOrigins?: string[]

    List of allowed Origin header values for DNS rebinding protection. If not specified, origin validation is disabled.

    Use external middleware for origin validation instead.

    enableDnsRebindingProtection?: boolean

    Enable DNS rebinding protection (requires allowedHosts and/or allowedOrigins to be configured). Default is false for backwards compatibility.

    Use external middleware for DNS rebinding protection instead.

    enableJsonResponse?: boolean

    If true, the server will return JSON responses instead of starting an SSE stream. This can be useful for simple request/response scenarios without streaming. Default is false (SSE streams are preferred).

    eventStore?: EventStore

    Event store for resumability support If provided, resumability will be enabled, allowing clients to reconnect and resume messages

    onsessionclosed?: (sessionId: string) => void | Promise<void>

    A callback for session close events This is called when the server closes a session due to a DELETE request. Useful in cases when you need to clean up resources associated with the session. Note that this is different from the transport closing, if you are handling HTTP requests from multiple nodes you might want to close each WebStandardStreamableHTTPServerTransport after a request is completed while still keeping the session open/running.

    Type Declaration

      • (sessionId: string): void | Promise<void>
      • Parameters

        • sessionId: string

          The session ID that was closed

        Returns void | Promise<void>

    onsessioninitialized?: (sessionId: string) => void | Promise<void>

    A callback for session initialization events This is called when the server initializes a new session. Useful in cases when you need to register multiple mcp sessions and need to keep track of them.

    Type Declaration

      • (sessionId: string): void | Promise<void>
      • Parameters

        • sessionId: string

          The generated session ID

        Returns void | Promise<void>

    retryInterval?: number

    Retry interval in milliseconds to suggest to clients in SSE retry field. When set, the server will send a retry field in SSE priming events to control client reconnection timing for polling behavior.

    sessionIdGenerator?: () => string

    Function that generates a session ID for the transport. The session ID SHOULD be globally unique and cryptographically secure (e.g., a securely generated UUID, a JWT, or a cryptographic hash)

    If not provided, session management is disabled (stateless mode).

    supportedProtocolVersions?: string[]

    List of protocol versions that this transport will accept. Used to validate the mcp-protocol-version header in incoming requests.

    Note: When using Server.connect(), the server automatically passes its supportedProtocolVersions to the transport, so you typically don't need to set this option directly.