Class AsyncModernMcpCompleteMethodCallback

java.lang.Object
org.springframework.ai.mcp.annotation.method.complete.AbstractMcpCompleteMethodCallback
org.springframework.ai.mcp.annotation.method.complete.AsyncModernMcpCompleteMethodCallback
All Implemented Interfaces:
io.modelcontextprotocol.modern.server.feature.McpAsyncCompletionHandler

public final class AsyncModernMcpCompleteMethodCallback extends AbstractMcpCompleteMethodCallback implements io.modelcontextprotocol.modern.server.feature.McpAsyncCompletionHandler
The asynchronous twin of SyncModernMcpCompleteMethodCallback: serves a completion/complete of a 2026-07-28 ("modern") MCP server by invoking a method annotated with @McpComplete.

A method may declare McpModernRequestContext, the SDK McpRequestContext or the modern McpSchema.CompleteRequest. Completions are plain results, so neither notifier is available.

The method may return a Mono, a CompletionStage or a Publisher of a modern McpSchema.CompleteResult or of any legacy return type, which is converted. A declared Flux is rejected at startup, and a publisher that emits more than one element fails the call; see ModernReactiveSupport. A plain, blocking return value runs through McpModernAsyncUtils.fromBlocking(io.modelcontextprotocol.modern.server.McpRequestContext, java.util.concurrent.Callable<T>).

Since:
2.1.0
Author:
Christian Tzolov
  • Method Details

    • isModernInfrastructureParameter

      public static boolean isModernInfrastructureParameter(Class<?> parameterType)
      Whether a parameter of this type is injected by the modern callback rather than bound from the completion argument.
    • complete

      public reactor.core.publisher.Mono<io.modelcontextprotocol.modern.McpSchema.CompleteResult> complete(io.modelcontextprotocol.modern.server.McpRequestContext context, io.modelcontextprotocol.modern.McpSchema.CompleteRequest request)
      Specified by:
      complete in interface io.modelcontextprotocol.modern.server.feature.McpAsyncCompletionHandler
    • validateParameters

      protected void validateParameters(Method method)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Validates method parameters. This method provides common validation logic and delegates exchange type checking to subclasses.
      Overrides:
      validateParameters in class AbstractMcpCompleteMethodCallback
      Parameters:
      method - The method to validate
    • validateReturnType

      protected void validateReturnType(Method method)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Validates that the method return type is compatible with the complete callback. This method should be implemented by subclasses to handle specific return type validation.
      Specified by:
      validateReturnType in class AbstractMcpCompleteMethodCallback
      Parameters:
      method - The method to validate
    • resolveTransportContext

      protected io.modelcontextprotocol.common.McpTransportContext resolveTransportContext(Object context)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Resolves the transport context from the exchange or context object. This method should be implemented by subclasses to extract the transport context from the appropriate exchange type.
      Specified by:
      resolveTransportContext in class AbstractMcpCompleteMethodCallback
      Parameters:
      context - The server exchange or transport context
      Returns:
      The resolved transport context
    • isExchangeType

      protected boolean isExchangeType(Class<?> paramType)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Checks if a parameter type is compatible with the exchange type. This method should be implemented by subclasses to handle specific exchange type checking.
      Specified by:
      isExchangeType in class AbstractMcpCompleteMethodCallback
      Parameters:
      paramType - The parameter type to check
      Returns:
      true if the parameter type is compatible with the exchange type, false otherwise
    • builder