Class McpModernAsyncUtils
java.lang.Object
org.springframework.ai.mcp.modern.McpModernAsyncUtils
Runs blocking code inside the asynchronous handlers of a 2026-07-28 ("modern") MCP
server.
- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> reactor.core.publisher.Mono<T>fromBlocking(io.modelcontextprotocol.modern.server.McpRequestContext context, Callable<T> call) Wraps a blocking call the way the SDK adapts its sync handlers: on the calling thread when the request is served blocking (McpRequestContext.isBlocking(), the WebMvc transport), and onSchedulers.boundedElastic()otherwise, so that an event loop is never blocked.
-
Method Details
-
fromBlocking
public static <T> reactor.core.publisher.Mono<T> fromBlocking(io.modelcontextprotocol.modern.server.McpRequestContext context, Callable<T> call) Wraps a blocking call the way the SDK adapts its sync handlers: on the calling thread when the request is served blocking (McpRequestContext.isBlocking(), the WebMvc transport), and onSchedulers.boundedElastic()otherwise, so that an event loop is never blocked.- Type Parameters:
T- the result type- Parameters:
context- the request contextcall- the blocking call; anullresult completes the Mono empty- Returns:
- the deferred result
-