Class AsyncMcpLoggingMethodCallback

java.lang.Object
org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
org.springaicommunity.mcp.method.logging.AsyncMcpLoggingMethodCallback
All Implemented Interfaces:
Function<io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<Void>>

public final class AsyncMcpLoggingMethodCallback extends AbstractMcpLoggingMethodCallback implements Function<io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<Void>>
Class for creating Function callbacks around logging consumer methods that return Mono. This class provides a way to convert methods annotated with McpLogging into callback functions that can be used to handle logging message notifications in a reactive way. It supports methods with either a single LoggingMessageNotification parameter or three parameters (LoggingLevel, String, String).
Author:
Christian Tzolov
  • Method Details

    • apply

      public reactor.core.publisher.Mono<Void> apply(io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification notification)
      Apply the callback to the given notification.

      This method builds the arguments for the method call, invokes the method, and returns a Mono that completes when the method execution is done.

      Specified by:
      apply in interface Function<io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification,reactor.core.publisher.Mono<Void>>
      Parameters:
      notification - The logging message notification, must not be null
      Returns:
      A Mono that completes when the method execution is done
      Throws:
      AbstractMcpLoggingMethodCallback.McpLoggingConsumerMethodException - if there is an error invoking the logging consumer method
      IllegalArgumentException - if the notification is null
    • validateReturnType

      protected void validateReturnType(Method method)
      Validates that the method return type is compatible with the logging consumer callback.
      Specified by:
      validateReturnType in class AbstractMcpLoggingMethodCallback
      Parameters:
      method - The method to validate
      Throws:
      IllegalArgumentException - if the return type is not compatible
    • builder

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