Class SyncMcpProgressMethodCallback

java.lang.Object
org.springaicommunity.mcp.method.progress.AbstractMcpProgressMethodCallback
org.springaicommunity.mcp.method.progress.SyncMcpProgressMethodCallback
All Implemented Interfaces:
Consumer<io.modelcontextprotocol.spec.McpSchema.ProgressNotification>

public final class SyncMcpProgressMethodCallback extends AbstractMcpProgressMethodCallback implements Consumer<io.modelcontextprotocol.spec.McpSchema.ProgressNotification>
Synchronous implementation of a progress method callback. This class creates a Consumer that invokes a method annotated with @McpProgress synchronously when a progress notification is received.
Author:
Christian Tzolov
  • Method Details

    • 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
    • accept

      public void accept(io.modelcontextprotocol.spec.McpSchema.ProgressNotification notification)
      Accept the progress notification and process it.

      This method builds the arguments for the method call and invokes the method.

      Specified by:
      accept in interface Consumer<io.modelcontextprotocol.spec.McpSchema.ProgressNotification>
      Parameters:
      notification - The progress notification, must not be null
      Throws:
      AbstractMcpProgressMethodCallback.McpProgressMethodException - if there is an error invoking the progress method
      IllegalArgumentException - if the notification is null
    • builder

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