Interface McpSimulation
- All Superinterfaces:
AutoCloseable
Thread-safe handle for one asynchronous off-network MCP request.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionawaitCompletion(@NonNull Duration timeout) Waits up totimeoutfor immutable terminal completion.awaitResponse(@NonNull Duration timeout) Waits up totimeoutfor the immutable response head.awaitStreamItem(@NonNull Duration timeout) Waits up totimeoutfor and removes the next captured SSE item.voidclose()Simulates a client disconnect if the request remains active.Performs a nonblocking terminal-state check.
-
Method Details
-
awaitResponse
@NonNull Optional<@NonNull McpSimulationResponse> awaitResponse(@NonNull Duration timeout) throws InterruptedException Waits up totimeoutfor 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 interruptedIllegalArgumentException- iftimeoutis negativeNullPointerException- iftimeoutis null
-
awaitStreamItem
@NonNull Optional<@NonNull McpSimulationStreamItem> awaitStreamItem(@NonNull Duration timeout) throws InterruptedException Waits up totimeoutfor 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 interruptedIllegalArgumentException- iftimeoutis negativeNullPointerException- iftimeoutis null
-
awaitCompletion
@NonNull Optional<@NonNull McpSimulationCompletion> awaitCompletion(@NonNull Duration timeout) throws InterruptedException Waits up totimeoutfor 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 interruptedIllegalArgumentException- iftimeoutis negativeNullPointerException- iftimeoutis 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:
closein interfaceAutoCloseable
-