Interface McpNotificationStreamOptionsExperimental

interface McpNotificationStreamOptions {
    auth?: StudioAiTokenSource;
    baseUrl?: string;
    fetchImpl?: {
        (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
        (input: string | URL | Request, init?: RequestInit): Promise<Response>;
    };
    initialReconnectDelayMs?: number;
    maxReconnectAttempts?: number;
    maxReconnectDelayMs?: number;
    onError?: ((error: unknown) => void);
    onNotification?: ((notification: McpNotification) => void);
    onStatusChange?: ((status: McpNotificationStreamStatus, detail?: string) => void);
    protocolVersion?: string;
    reconnectBackoffFactor?: number;
    sessionId?: (() => undefined | string);
    signal?: AbortSignal;
    stableStreamMs?: number;
}

Hierarchy (view full)

Properties

baseUrl?: string

The /mcp endpoint's base — the stream opens GET ${baseUrl}/mcp.

"/api"
fetchImpl?: {
    (input: URL | RequestInfo, init?: RequestInit): Promise<Response>;
    (input: string | URL | Request, init?: RequestInit): Promise<Response>;
}

Override for tests. Defaults to globalThis.fetch.

Type declaration

    • (input, init?): Promise<Response>
    • Parameters

      • input: URL | RequestInfo
      • Optionalinit: RequestInit

      Returns Promise<Response>

    • (input, init?): Promise<Response>
    • Parameters

      • input: string | URL | Request
      • Optionalinit: RequestInit

      Returns Promise<Response>

initialReconnectDelayMs?: number
1000
maxReconnectAttempts?: number

Reconnect budget. 0 never reconnects.

5
maxReconnectDelayMs?: number
30000
onError?: ((error: unknown) => void)

Observes recoverable failures — a dropped connection, a non-2xx GET, a malformed frame. A stream that is still retrying reports here and keeps going; the terminal outcome arrives through onStatusChange.

onNotification?: ((notification: McpNotification) => void)

Called for every server-initiated notification. Never called after a terminal status.

onStatusChange?: ((status: McpNotificationStreamStatus, detail?: string) => void)

Observes every lifecycle transition, including the terminal one.

protocolVersion?: string

Sent as mcp-protocol-version when supplied.

reconnectBackoffFactor?: number
2
sessionId?: (() => undefined | string)

Reads the LIVE Mcp-Session-Id on every connect attempt — a function, not a value, because a reconnect after the owning client re-handshook must carry the new session, never the one captured when the watch started.

signal?: AbortSignal

Tears the subscription down — the in-flight GET is aborted, not merely ignored.

stableStreamMs?: number

How long a connection must stay open, with no frames at all, before it counts as healthy and resets the reconnect budget. See the module doc's flap guard.

maxReconnectDelayMs