Class AsyncMcpElicitationMethodCallback
java.lang.Object
org.springaicommunity.mcp.method.elicitation.AbstractMcpElicitationMethodCallback
org.springaicommunity.mcp.method.elicitation.AsyncMcpElicitationMethodCallback
- All Implemented Interfaces:
Function<io.modelcontextprotocol.spec.McpSchema.ElicitRequest,reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.ElicitResult>>
public final class AsyncMcpElicitationMethodCallback
extends AbstractMcpElicitationMethodCallback
implements Function<io.modelcontextprotocol.spec.McpSchema.ElicitRequest,reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.ElicitResult>>
Class for creating Function callbacks around elicitation methods that return Mono.
This class provides a way to convert methods annotated with
McpElicitation into
callback functions that can be used to handle elicitation requests in a reactive way.
It supports methods with a single ElicitRequest parameter.- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating AsyncMcpElicitationMethodCallback instances.Nested classes/interfaces inherited from class org.springaicommunity.mcp.method.elicitation.AbstractMcpElicitationMethodCallback
AbstractMcpElicitationMethodCallback.AbstractBuilder<T extends AbstractMcpElicitationMethodCallback.AbstractBuilder<T,R>, R>, AbstractMcpElicitationMethodCallback.McpElicitationMethodException -
Field Summary
Fields inherited from class org.springaicommunity.mcp.method.elicitation.AbstractMcpElicitationMethodCallback
bean, method -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.ElicitResult>apply(io.modelcontextprotocol.spec.McpSchema.ElicitRequest request) Apply the callback to the given request.builder()Create a new builder.protected booleanisExchangeType(Class<?> paramType) Checks if a parameter type is compatible with the exchange type.protected voidvalidateReturnType(Method method) Validates that the method return type is compatible with the elicitation callback.Methods inherited from class org.springaicommunity.mcp.method.elicitation.AbstractMcpElicitationMethodCallback
buildArgs, validateMethod, validateParameters
-
Method Details
-
apply
public reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.ElicitResult> apply(io.modelcontextprotocol.spec.McpSchema.ElicitRequest request) Apply the callback to the given request.This method builds the arguments for the method call, invokes the method, and returns a Mono that completes with the result.
- Specified by:
applyin interfaceFunction<io.modelcontextprotocol.spec.McpSchema.ElicitRequest,reactor.core.publisher.Mono<io.modelcontextprotocol.spec.McpSchema.ElicitResult>> - Parameters:
request- The elicitation request, must not be null- Returns:
- A Mono that completes with the result of the method invocation
- Throws:
AbstractMcpElicitationMethodCallback.McpElicitationMethodException- if there is an error invoking the elicitation methodIllegalArgumentException- if the request is null
-
validateReturnType
Validates that the method return type is compatible with the elicitation callback.- Specified by:
validateReturnTypein classAbstractMcpElicitationMethodCallback- Parameters:
method- The method to validate- Throws:
IllegalArgumentException- if the return type is not compatible
-
isExchangeType
Checks if a parameter type is compatible with the exchange type.- Specified by:
isExchangeTypein classAbstractMcpElicitationMethodCallback- Parameters:
paramType- The parameter type to check- Returns:
- true if the parameter type is compatible with the exchange type, false otherwise
-
builder
Create a new builder.- Returns:
- A new builder instance
-