Interface McpSubscriptionEventPublisher
Every event must be made available to every current listener; a
competing-consumer queue is not a valid implementation. Implementations may
perform process-local delivery or coordinate through a distributed service.
The application owns the publisher. Soklet closes only registrations
returned by subscribe(McpSubscriptionEventListener) and never closes
the publisher itself.
This SPI distributes application change events only. Publication requests local reevaluation for the configured notification family; it is not by itself a wire notification or an authorization grant. Soklet owns all MCP stream-delivery mechanics: per-stream queues, duplicate-event coalescing, backpressure, accepted-filter matching, caller-visible catalog comparison, and MCP wire serialization. Publisher events carry no endpoint, client, principal, or authorization-partition target. Publisher implementations must not attempt to perform authorization or stream-delivery functions.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionCreates an independent in-memory publisher with default behavior.voidpublish(@NonNull McpSubscriptionEvent subscriptionEvent) Broadcasts a coarse subscription-change event.default voidBroadcasts a prompt-list-changed event.default voidBroadcasts a resource-list-changed event.default voidpublishResourceUpdated(@NonNull URI resourceUri) Broadcasts a resource-updated event.default voidBroadcasts a tool-list-changed event.subscribe(@NonNull McpSubscriptionEventListener listener) Registers a listener for broadcast events.
-
Method Details
-
fromInMemoryDefaults
Creates an independent in-memory publisher with default behavior.The publisher reaches only listeners registered with that instance in the current process and invokes them synchronously on the publishing thread. Closing a registration does not wait for a delivery already selected or in flight. If a listener throws a runtime exception, all other current listeners are still attempted before the first exception is rethrown with later exceptions suppressed.
- Returns:
- in-memory event publisher
-
subscribe
Registers a listener for broadcast events.- Parameters:
listener- thread-safe listener- Returns:
- an idempotently closable listener registration
-
publish
Broadcasts a coarse subscription-change event.- Parameters:
subscriptionEvent- subscription-change event
-
publishResourcesListChanged
Broadcasts a resource-list-changed event. -
publishResourceUpdated
Broadcasts a resource-updated event.- Parameters:
resourceUri- absolute normalized changed-resource URI in ASCII wire form- Throws:
NullPointerException- ifresourceUriis nullIllegalArgumentException- if the URI is relative, not normalized, or not in ASCII wire form
-
publishToolsListChanged
Broadcasts a tool-list-changed event. -
publishPromptsListChanged
Broadcasts a prompt-list-changed event.
-