Agent / foldkit-agent-mcp

SseStream

interface · packages/agent-mcp/src/http.ts:30

interface SseStream {
  readonly backlog: ReadonlyArray<SseEvent>
  readonly subscribe: (
    send: (event: SseEvent) => void,
    end?: () => void,
  ) => () => void
}

An open SSE stream.

Members

SseStream.backlog

property · packages/agent-mcp/src/http.ts:32

readonly backlog: ReadonlyArray<SseEvent>

Replayed immediately on subscribe, when the client resumed.

SseStream.subscribe

property · packages/agent-mcp/src/http.ts:45

readonly subscribe: (
  send: (event: SseEvent) => void,
  end?: () => void,
) => () => void

Attaches the transport to the session, returning an unsubscribe.

end is called at most once, when the session is terminated -- by DELETE, by idle expiry, or by server close -- and the transport must close the response body when it is. A session already terminated by the time the transport subscribes calls end immediately, so the window between opening the response and reading it cannot leave a stream open forever. It is optional only because a transport that has no way to close its response can do nothing with it; one that omits it keeps the response open until the client itself disconnects.