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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating AsyncMcpLoggingConsumerMethodCallback instances.Nested classes/interfaces inherited from class org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
AbstractMcpLoggingMethodCallback.AbstractBuilder<T extends AbstractMcpLoggingMethodCallback.AbstractBuilder<T,R>, R>, AbstractMcpLoggingMethodCallback.McpLoggingConsumerMethodException -
Field Summary
Fields inherited from class org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
bean, method -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>apply(io.modelcontextprotocol.spec.McpSchema.LoggingMessageNotification notification) Apply the callback to the given notification.builder()Create a new builder.protected voidvalidateReturnType(Method method) Validates that the method return type is compatible with the logging consumer callback.Methods inherited from class org.springaicommunity.mcp.method.logging.AbstractMcpLoggingMethodCallback
buildArgs, validateMethod, validateParameters
-
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:
applyin interfaceFunction<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 methodIllegalArgumentException- if the notification is null
-
validateReturnType
Validates that the method return type is compatible with the logging consumer callback.- Specified by:
validateReturnTypein classAbstractMcpLoggingMethodCallback- Parameters:
method- The method to validate- Throws:
IllegalArgumentException- if the return type is not compatible
-
builder
Create a new builder.- Returns:
- A new builder instance
-