SubscriptionsSupport mixin base

A mixin for MCP servers which serve subscriptions/listen requests.

Stamps the subscription ID on the acknowledgement and holds the request until shutdown. A package:json_rpc_2 handler does not receive that ID, so a transport sets nextSubscriptionId before delivering the request. handleRequestScopedMessage does. A request without one is refused.

See https://modelcontextprotocol.io/specification/2026-07-28/basic/patterns/subscriptions.

Superclass constraints

Properties

advertisedCapabilities → ServerCapabilities
Advertises every registered capability, since this server serves the subscriptions/listen requests a client opens to hear those notifications on. The copy keeps the advertisement off server state.
no setteroverride
cancellations → Stream<CancelledNotification>
Every notifications/cancelled the peer sends with a JSON-RPC requestId, in arrival order.
no setterinherited
capabilities → ServerCapabilities
The capabilities of this server, which discover advertises.
finalinherited
clientCapabilities ↔ ClientCapabilities
The capabilities of the client.
getter/setter pairinherited
clientInfo ↔ Implementation?
The client implementation information provided during initialization.
getter/setter pairinherited
done → Future<void>
Completes after shutdown is called.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
implementation → Implementation
The name, current version, and other info to give to the client.
finalinherited
initialized → Future<InitializedNotification?>
Completes when this server has finished initialization.
no setterinherited
instructions → String?
Instructions for how to use this server, which are given to the client.
finalinherited
isActive → bool
Whether the connection with the peer is active.
no setterinherited
maxInputRequiredRounds → int
How many times a handler may be rerun for an input_required result.
finalinherited
name → String
The name of the associated server.
no setterinherited
nextSubscriptionId ↔ RequestId?
The ID the next subscriptions/listen request opens its subscription under.
getter/setter pair
protocolVersion ↔ ProtocolVersion
The negotiated protocol version.
getter/setter pairinherited
ready → bool
Whether this server is still active and has completed initialization.
no setterinherited
rootsListChanged → Stream<RootsListChangedNotification?>?
Emits an event any time the client notifies us of a change to the list of roots it supports.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
supportsRoots → bool
Whether or not the connected client supports roots requests.
no setterinherited
supportsSampling → bool
Whether or not the connected client supports sampling requests.
no setterinherited

Methods

captureIncomingRequestActivity() → bool Function()
Captures whether the current incoming request has not been cancelled.
inherited
closeProgress(Request? request) → Future<void>
Closes the stream onProgress returned for request, if it opened one.
inherited
discover([DiscoverRequest? request]) → FutureOr<DiscoverResult>
Answers the server/discover request with the protocol versions this server serves, the capabilities initialize registered, and the instructions it was given.
inherited
handleInitialized([InitializedNotification? notification]) → void
Completes initialized.
inherited
handleSubscriptionsListen(SubscriptionsListenRequest request) → FutureOr<SubscriptionsListenResult>
Acknowledges request and keeps it open until the server shuts down.
initialize(MCPServerInitialization initialization) → FutureOr<void>
Registers the features available to a client with initialization.
override
initializeLegacy(InitializeRequest request) → FutureOr<InitializeResult>
Handles the initialize request used by legacy MCP protocols.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyProgress(ProgressNotification notification) → void
Notifies the peer of progress towards completing some request.
inherited
onProgress(Request request) → Stream<ProgressNotification>
A stream of progress notifications for a given request.
inherited
ping({Duration timeout = const Duration(seconds: 1), PingRequest? request}) → Future<bool>
Pings the peer, and returns whether or not it responded within timeout.
inherited
protocolLog(String message) → void
Writes message to the protocol log, if the caller asked for one.
inherited
registerNotificationHandler<T extends Notification?>(String name, void impl(T)) → void
Registers a notification handler named name on this server.
inherited
registerRequestHandler<T extends Request?, R extends Result?>(String name, FutureOr<R> impl(T)) → void
Registers impl for name, and on revisions before 2026-07-28 wraps the handlers that may answer input_required in the legacy shim.
inherited
runOutsideRequest<T>(T callback()) → T
Runs callback without associating its asynchronous work with a request.
inherited
sendNotification(String method, [Notification? notification]) → void
Sends a notification to the peer.
inherited
sendRequest<T extends Result?>(String methodName, [Request? request]) → Future<T>
Sends request to the peer, and handles coercing the response to the type T.
inherited
sendRequestKeepingProgress<T extends Result?>(String methodName, [Request? request]) → Future<T>
Sends request to the peer like sendRequest does, but leaves any progress stream for it open.
inherited
sendRequestWithId<T extends Result?>(String methodName, {Request? request}) → ({RequestId id, Future<T> result, Future<void> sent})
Sends methodName and hands back the JSON-RPC ID it goes out under.
inherited
shutdown() → Future<void>
Ends every open subscription before closing the connection, so each of their requests gets the response the specification asks a server tearing a subscription down to send.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited