Class AsyncMcpProgressMethodCallback
java.lang.Object
org.springframework.ai.mcp.annotation.method.progress.AbstractMcpProgressMethodCallback
org.springframework.ai.mcp.annotation.method.progress.AsyncMcpProgressMethodCallback
- All Implemented Interfaces:
Function<io.modelcontextprotocol.spec.McpSchema.ProgressNotification,reactor.core.publisher.Mono<Void>>
public final class AsyncMcpProgressMethodCallback
extends AbstractMcpProgressMethodCallback
implements Function<io.modelcontextprotocol.spec.McpSchema.ProgressNotification,reactor.core.publisher.Mono<Void>>
Asynchronous implementation of a progress method callback.
This class creates a Function that invokes a method annotated with @McpProgress
asynchronously when a progress notification is received, returning a Mono.
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for creating AsyncMcpProgressMethodCallback instances.Nested classes/interfaces inherited from class org.springframework.ai.mcp.annotation.method.progress.AbstractMcpProgressMethodCallback
AbstractMcpProgressMethodCallback.AbstractBuilder<T extends AbstractMcpProgressMethodCallback.AbstractBuilder<T,R>, R>, AbstractMcpProgressMethodCallback.McpProgressMethodException -
Field Summary
Fields inherited from class org.springframework.ai.mcp.annotation.method.progress.AbstractMcpProgressMethodCallback
bean, method -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Void>acceptModern(io.modelcontextprotocol.modern.McpSchema.ProgressParams progress, @Nullable ToolContext toolContext) Accepts the progress of a modern client, for a tool call with the given tool context.reactor.core.publisher.Mono<Void>apply(io.modelcontextprotocol.spec.McpSchema.ProgressNotification notification) Accepts a progress notification and processes it.builder()Create a new builder.protected booleanisNotificationType(Class<?> paramType) Accepts the progress type of the modern schema in addition to the legacy notification.protected voidvalidateParameters(Method method) Accepts aToolContextparameter next to the progress parameters.protected voidvalidateReturnType(Method method) Validates that the method return type is compatible with the progress callback.Methods inherited from class org.springframework.ai.mcp.annotation.method.progress.AbstractMcpProgressMethodCallback
buildArgs, validateMethod
-
Method Details
-
isNotificationType
Accepts the progress type of the modern schema in addition to the legacy notification.- Overrides:
isNotificationTypein classAbstractMcpProgressMethodCallback- Parameters:
paramType- The parameter type to check- Returns:
- true if the callback supports the parameter type
-
validateParameters
Accepts aToolContextparameter next to the progress parameters.- Overrides:
validateParametersin classAbstractMcpProgressMethodCallback- Parameters:
method- The method to validate
-
validateReturnType
Description copied from class:AbstractMcpProgressMethodCallbackValidates 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:
validateReturnTypein classAbstractMcpProgressMethodCallback- Parameters:
method- The method to validate
-
apply
public reactor.core.publisher.Mono<Void> apply(io.modelcontextprotocol.spec.McpSchema.ProgressNotification notification) Accepts a progress notification and processes it.- Specified by:
applyin interfaceFunction<io.modelcontextprotocol.spec.McpSchema.ProgressNotification,reactor.core.publisher.Mono<Void>> - Parameters:
notification- the progress notification- Returns:
- a Mono that completes when the method has processed the notification
- Throws:
AbstractMcpProgressMethodCallback.McpProgressMethodException- if there is an error invoking the progress method
-
acceptModern
public reactor.core.publisher.Mono<Void> acceptModern(io.modelcontextprotocol.modern.McpSchema.ProgressParams progress, @Nullable ToolContext toolContext) Accepts the progress of a modern client, for a tool call with the given tool context. The method receives the tool context if it declares aToolContextparameter.- Parameters:
progress- the modern progresstoolContext- the tool context of the tool call that reports the progress, ornullif there is none- Returns:
- a Mono that completes when the method has processed the progress
- Throws:
AbstractMcpProgressMethodCallback.McpProgressMethodException- if there is an error invoking the progress method- Since:
- 2.1.0
-
builder
Create a new builder.- Returns:
- A new builder instance
-