Add public subscriptions/listen server handler (SEP-2575) - #1775
Open
tarekgh wants to merge 2 commits into
Open
Conversation
added 2 commits
July 29, 2026 14:18
Adds an opt-in McpServerHandlers.SubscriptionsListenHandler and a WithSubscriptionsListenHandler builder method so server authors can own the long-lived subscriptions/listen stream for custom subscription kinds, application-driven notifications, and stateless Streamable HTTP delivery over the held-open POST response. Fixes modelcontextprotocol#1662 Copilot-Session: 80653343-5dcb-43cb-89b0-8ac8e572c4f7
The client dispatches incoming messages concurrently, so cross-notification arrival order is not observable at the handler level. Assert only that the acknowledgement and streamed notification each arrive tagged with the subscription id, and prove fan-out suppression via the synchronous empty-fan-out plus a completed-and-empty channel check. Copilot-Session: 80653343-5dcb-43cb-89b0-8ac8e572c4f7
Contributor
Author
|
CC @jeffhandley |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1662
Adds an opt-in, typed
subscriptions/listenserver handler so server authors can own the long-lived subscription stream directly.What
McpServerHandlers.SubscriptionsListenHandlerhandler slot.WithSubscriptionsListenHandler(...)builder method.When set, the handler is a full replacement for the built-in
subscriptions/listenhandling: it owns the stream, sends the acknowledgement, tags notifications with the subscription id, and receives no automatic*/list_changedfan-out. It runs through the same request pipeline as other typed handlers, so it can stream notifications over the request response stream even under stateless Streamable HTTP, where the held-open POST is the only solicited server-to-client channel. Protocol-version gating (2026-07-28+) is enforced by the SDK. No server capabilities are auto-advertised, so authors declare only what their handler delivers.Tests
Acknowledgement-first ordering and subscription-id tagging, replacement suppressing automatic list-changed fan-out, pre-2026-07-28 rejection, cancellation cleanup, and stateless streaming over the held-open POST. Full core suite passes.