Class SyncMcpLoggingMethodCallback

java.lang.Object
org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
org.springaicommunity.mcp.method.logging.SyncMcpLoggingMethodCallback
All Implemented Interfaces:
Consumer<io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification>

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

    • accept

      public void accept(io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification notification)
      Accept the logging message 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.LoggingMessageNotification>
      Parameters:
      notification - The logging message notification, must not be null
      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 SyncMcpLoggingMethodCallback.Builder builder()
      Create a new builder.
      Returns:
      A new builder instance