Class AsyncMcpProgressMethodCallback

java.lang.Object
org.springframework.ai.mcp.annotation.method.progress.AbstractMcpProgressMethodCallback
org.springframework.ai.mcp.annotation.method.progress.AsyncMcpProgressMethodCallback
All Implemented Interfaces:
Function<io.modelcontextprotocol.spec.McpSchema.ProgressNotification,reactor.core.publisher.Mono<Void>>

public final class AsyncMcpProgressMethodCallback extends AbstractMcpProgressMethodCallback implements Function<io.modelcontextprotocol.spec.McpSchema.ProgressNotification,reactor.core.publisher.Mono<Void>>
Asynchronous implementation of a progress method callback. This class creates a Function that invokes a method annotated with @McpProgress asynchronously when a progress notification is received, returning a Mono.
Author:
Christian Tzolov
  • Method Details

    • isNotificationType

      protected boolean isNotificationType(Class<?> paramType)
      Accepts the progress type of the modern schema in addition to the legacy notification.
      Overrides:
      isNotificationType in class AbstractMcpProgressMethodCallback
      Parameters:
      paramType - The parameter type to check
      Returns:
      true if the callback supports the parameter type
    • validateParameters

      protected void validateParameters(Method method)
      Accepts a ToolContext parameter next to the progress parameters.
      Overrides:
      validateParameters in class AbstractMcpProgressMethodCallback
      Parameters:
      method - The method to validate
    • validateReturnType

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

      public reactor.core.publisher.Mono<Void> apply(io.modelcontextprotocol.spec.McpSchema.ProgressNotification notification)
      Accepts a progress notification and processes it.
      Specified by:
      apply in interface Function<io.modelcontextprotocol.spec.McpSchema.ProgressNotification,reactor.core.publisher.Mono<Void>>
      Parameters:
      notification - the progress notification
      Returns:
      a Mono that completes when the method has processed the notification
      Throws:
      AbstractMcpProgressMethodCallback.McpProgressMethodException - if there is an error invoking the progress method
    • acceptModern

      public reactor.core.publisher.Mono<Void> acceptModern(io.modelcontextprotocol.modern.McpSchema.ProgressParams progress, @Nullable ToolContext toolContext)
      Accepts the progress of a modern client, for a tool call with the given tool context. The method receives the tool context if it declares a ToolContext parameter.
      Parameters:
      progress - the modern progress
      toolContext - the tool context of the tool call that reports the progress, or null if there is none
      Returns:
      a Mono that completes when the method has processed the progress
      Throws:
      AbstractMcpProgressMethodCallback.McpProgressMethodException - if there is an error invoking the progress method
      Since:
      2.1.0
    • builder

      public static AsyncMcpProgressMethodCallback.Builder builder()
      Create a new builder.
      Returns:
      A new builder instance