Class McpModernAsyncUtils

java.lang.Object
org.springframework.ai.mcp.modern.McpModernAsyncUtils

public final class McpModernAsyncUtils extends Object
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 Type
    Method
    Description
    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 on Schedulers.boundedElastic() otherwise, so that an event loop is never blocked.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 on Schedulers.boundedElastic() otherwise, so that an event loop is never blocked.
      Type Parameters:
      T - the result type
      Parameters:
      context - the request context
      call - the blocking call; a null result completes the Mono empty
      Returns:
      the deferred result