You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(client): listen() driver is transport-level — drop the in-Protocol park primitive
The listen() driver no longer registers in Protocol's _responseHandlers
via the bespoke _parkRequest() primitive. Instead it sends directly on
the transport with a STRING request id from a Client-owned counter
('listen:N' — JSON-RPC valid, spec subscriptionId is RequestId verbatim,
zero collision with Protocol's numeric counter), and demuxes the listen
id at the Client layer via three protected overrides:
- _onnotification: consumes a matching ack (resolves opening) and a
matching string-id notifications/cancelled (settles 'remote');
unmatched ack/cancelled pass through to super.
- _onresponse: a string-id response matching a live listen entry is the
server's pre-ack JSON-RPC error (settles with the typed ProtocolError)
or a buggy result (settles InvalidResult); never reaches Protocol's
numeric _responseHandlers map.
- _onclose: settles every live per-listen entry 'remote' before
Protocol._onclose tears the transport down (the prior implementation
got this via _responseHandlers settlement; the redesign no longer
registers there).
TransportSendOptions gains onRequestStreamEnd, fired by transports that
open a per-request stream (Streamable HTTP) when that stream ends or
errors for any non-deliberate reason; threaded through the SSE reconnect
path so a reconnected stream still carries it. stdio/InMemory ignore it.
protocol.ts: _parkRequest, _onParkedNotification, and their dispatch
wiring are gone; _onnotification/_onresponse/_onclose are now protected.
Net diff vs the integration base is three private→protected keyword
changes only.
The opening→open→closed state machine, McpSubscription surface,
ClientOptions.listChanged auto-open, and the per-request requestSignal
mechanism are unchanged; this is internal wiring. Also folds in the bot
finding that _setupListChangedHandlers in the modern connect path was
outside the soft-fail guard (now surfaces via onerror, connect resolves).
0 commit comments