Interface McpSimulation

All Superinterfaces:
AutoCloseable

@ThreadSafe public interface McpSimulation extends AutoCloseable
Thread-safe handle for one asynchronous off-network MCP request.
Author:
Mark Allen
  • Method Details

    • awaitResponse

      Waits up to timeout for the immutable response head.

      A zero timeout performs a nonblocking check. Very large positive durations are saturated to the longest supported wait. Response reads are repeatable.

      Parameters:
      timeout - maximum time to wait; must not be negative
      Returns:
      the response when available, otherwise empty
      Throws:
      InterruptedException - if the waiting thread is interrupted
      IllegalArgumentException - if timeout is negative
      NullPointerException - if timeout is null
    • awaitStreamItem

      Waits up to timeout for and removes the next captured SSE item. Removing an item releases a pending-item slot but does not refund captured bytes. A zero timeout performs a nonblocking check, and very large positive durations are saturated to the longest supported wait. Unlike response and completion reads, successful item reads are destructive.
      Parameters:
      timeout - maximum time to wait; must not be negative
      Returns:
      the next item when available, otherwise empty
      Throws:
      InterruptedException - if the waiting thread is interrupted
      IllegalArgumentException - if timeout is negative
      NullPointerException - if timeout is null
    • awaitCompletion

      Waits up to timeout for immutable terminal completion.

      A zero timeout performs a nonblocking check. Very large positive durations are saturated to the longest supported wait. Completion reads are repeatable.

      Parameters:
      timeout - maximum time to wait; must not be negative
      Returns:
      completion when available, otherwise empty
      Throws:
      InterruptedException - if the waiting thread is interrupted
      IllegalArgumentException - if timeout is negative
      NullPointerException - if timeout is null
    • isComplete

      Performs a nonblocking terminal-state check.
      Returns:
      whether terminal completion is available
    • close

      void close()
      Simulates a client disconnect if the request remains active. Closing is idempotent, does not discard already captured values, and cannot replace an earlier terminal winner.

      For MCP 2025-06-18 and 2025-11-25, disconnecting after progress has committed SSE detaches the response writer without canceling application work solely for that disconnect. Finite and uncommitted requests retain disconnect cancelation. Work retained after detachment remains subject to its request deadline and server shutdown; later progress and results are discarded.

      Specified by:
      close in interface AutoCloseable