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
Apply review fixes to subscriptions/listen serving
- Pass the server-scoped subscription bus into the fallback Contexts built
by programmatic call_tool/read_resource/get_prompt, so ctx.notify_* works
there instead of raising.
- Reject subscriptions/listen with 406 when the Accept header lacks
text/event-stream: the response is always an SSE stream, so JSON-response
mode must not serve a content type the client never accepted.
- Release a stream's subscription slot at backlog overflow time; the
stream's own cleanup can be wedged in a transport write that closing the
buffer cannot wake.
- End InMemorySubscriptionBus.publish with a checkpoint so a same-task
publish burst lets listen streams drain between events instead of
overflowing a healthy stream's buffer.
- Describe the graceful-close result as a deliberate end rather than a
"don't re-listen" signal: a stream ended at the overflow cap sends the
same result and the client should re-listen.
- Move a function-body import to the top of the file and fix a stale
comment referencing a removed property.
Copy file name to clipboardExpand all lines: docs/advanced/subscriptions.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,7 +77,7 @@ Down on the low-level `Server` there is no pre-wired anything — and the same p
77
77
78
78
* You own the bus, so you publish to it directly: `await bus.publish(ResourceUpdated(uri=...))`. Put it wherever your handlers can reach it — module scope here, the lifespan in a bigger app.
79
79
*`ListenHandler(bus)` is the same handler `MCPServer` registers; `on_subscriptions_listen=` is an ordinary handler slot. Don't want the SDK's semantics? Write your own handler for the slot — the spec obligations come with it.
80
-
*`ListenHandler.close()` gracefully ends every open stream: each one receives the listen request's result as its final frame, the spec's signal that the server ended the subscription deliberately and the client shouldn't re-listen. Without it, streams end when the client disconnects.
80
+
*`ListenHandler.close()` gracefully ends every open stream: each one receives the listen request's result as its final frame, the spec's signal that the server ended the subscription deliberately — a clean end, as opposed to the abrupt drop a client may treat as a cue to reconnect. Without it, streams end when the client disconnects.
0 commit comments