Class AsyncModernMcpCompleteMethodCallback
java.lang.Object
org.springframework.ai.mcp.annotation.method.complete.AbstractMcpCompleteMethodCallback
org.springframework.ai.mcp.annotation.method.complete.AsyncModernMcpCompleteMethodCallback
- All Implemented Interfaces:
io.modelcontextprotocol.modern.server.feature.McpAsyncCompletionHandler
public final class AsyncModernMcpCompleteMethodCallback
extends AbstractMcpCompleteMethodCallback
implements io.modelcontextprotocol.modern.server.feature.McpAsyncCompletionHandler
The asynchronous twin of
SyncModernMcpCompleteMethodCallback: serves a
completion/complete of a 2026-07-28 ("modern") MCP server by invoking a method
annotated with @McpComplete.
A method may declare McpModernRequestContext, the SDK McpRequestContext
or the modern McpSchema.CompleteRequest. Completions are plain results, so neither
notifier is available.
The method may return a Mono, a CompletionStage or a Publisher
of a modern McpSchema.CompleteResult or of any legacy return type, which is converted. A
declared Flux is rejected at startup, and a publisher that emits more than one
element fails the call; see ModernReactiveSupport. A plain, blocking return
value runs through McpModernAsyncUtils.fromBlocking(io.modelcontextprotocol.modern.server.McpRequestContext, java.util.concurrent.Callable<T>).
- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder forAsyncModernMcpCompleteMethodCallbackinstances.Nested classes/interfaces inherited from class org.springframework.ai.mcp.annotation.method.complete.AbstractMcpCompleteMethodCallback
AbstractMcpCompleteMethodCallback.AbstractBuilder<T extends AbstractMcpCompleteMethodCallback.AbstractBuilder<T,R>, R>, AbstractMcpCompleteMethodCallback.McpCompleteMethodException -
Field Summary
Fields inherited from class org.springframework.ai.mcp.annotation.method.complete.AbstractMcpCompleteMethodCallback
bean, completeReference, method, prompt, uri, uriTemplateManager, uriVariables -
Method Summary
Modifier and TypeMethodDescriptionbuilder()reactor.core.publisher.Mono<io.modelcontextprotocol.modern.McpSchema.CompleteResult>complete(io.modelcontextprotocol.modern.server.McpRequestContext context, io.modelcontextprotocol.modern.McpSchema.CompleteRequest request) protected booleanisExchangeType(Class<?> paramType) Checks if a parameter type is compatible with the exchange type.static booleanisModernInfrastructureParameter(Class<?> parameterType) Whether a parameter of this type is injected by the modern callback rather than bound from the completion argument.protected io.modelcontextprotocol.common.McpTransportContextresolveTransportContext(Object context) Resolves the transport context from the exchange or context object.protected voidvalidateParameters(Method method) Validates method parameters.protected voidvalidateReturnType(Method method) Validates that the method return type is compatible with the complete callback.Methods inherited from class org.springframework.ai.mcp.annotation.method.complete.AbstractMcpCompleteMethodCallback
buildArgs, validateMethod
-
Method Details
-
isModernInfrastructureParameter
Whether a parameter of this type is injected by the modern callback rather than bound from the completion argument. -
complete
public reactor.core.publisher.Mono<io.modelcontextprotocol.modern.McpSchema.CompleteResult> complete(io.modelcontextprotocol.modern.server.McpRequestContext context, io.modelcontextprotocol.modern.McpSchema.CompleteRequest request) - Specified by:
completein interfaceio.modelcontextprotocol.modern.server.feature.McpAsyncCompletionHandler
-
validateParameters
Description copied from class:AbstractMcpCompleteMethodCallbackValidates method parameters. This method provides common validation logic and delegates exchange type checking to subclasses.- Overrides:
validateParametersin classAbstractMcpCompleteMethodCallback- Parameters:
method- The method to validate
-
validateReturnType
Description copied from class:AbstractMcpCompleteMethodCallbackValidates that the method return type is compatible with the complete callback. This method should be implemented by subclasses to handle specific return type validation.- Specified by:
validateReturnTypein classAbstractMcpCompleteMethodCallback- Parameters:
method- The method to validate
-
resolveTransportContext
protected io.modelcontextprotocol.common.McpTransportContext resolveTransportContext(Object context) Description copied from class:AbstractMcpCompleteMethodCallbackResolves the transport context from the exchange or context object. This method should be implemented by subclasses to extract the transport context from the appropriate exchange type.- Specified by:
resolveTransportContextin classAbstractMcpCompleteMethodCallback- Parameters:
context- The server exchange or transport context- Returns:
- The resolved transport context
-
isExchangeType
Description copied from class:AbstractMcpCompleteMethodCallbackChecks if a parameter type is compatible with the exchange type. This method should be implemented by subclasses to handle specific exchange type checking.- Specified by:
isExchangeTypein classAbstractMcpCompleteMethodCallback- Parameters:
paramType- The parameter type to check- Returns:
- true if the parameter type is compatible with the exchange type, false otherwise
-
builder
-