Interface McpSubscriptionEventPublisher


Thread-safe broadcast publisher for application-owned MCP subscription-change events.

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 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

      void publish(@NonNull McpSubscriptionEvent subscriptionEvent)
      Broadcasts a coarse subscription-change event.
      Parameters:
      subscriptionEvent - subscription-change event
    • publishResourcesListChanged

      Broadcasts a resource-list-changed event.
    • publishResourceUpdated

      default void publishResourceUpdated(@NonNull URI resourceUri)
      Broadcasts a resource-updated event.
      Parameters:
      resourceUri - absolute normalized changed-resource URI in ASCII wire form
      Throws:
      NullPointerException - if resourceUri is null
      IllegalArgumentException - if the URI is relative, not normalized, or not in ASCII wire form
    • publishToolsListChanged

      default void publishToolsListChanged()
      Broadcasts a tool-list-changed event.
    • publishPromptsListChanged

      default void publishPromptsListChanged()
      Broadcasts a prompt-list-changed event.