Class SyncModernMcpCompleteMethodCallback
java.lang.Object
org.springframework.ai.mcp.annotation.method.complete.AbstractMcpCompleteMethodCallback
org.springframework.ai.mcp.annotation.method.complete.SyncModernMcpCompleteMethodCallback
- All Implemented Interfaces:
SyncCompletionRegistration.Handler
public final class SyncModernMcpCompleteMethodCallback
extends AbstractMcpCompleteMethodCallback
implements SyncCompletionRegistration.Handler
Serves a
completion/complete of a 2026-07-28 ("modern") MCP server by invoking
a method annotated with @McpComplete.
Beyond the parameters the stateless callback supports, a method may declare
McpModernSyncRequestContext, the SDK McpRequestContext or the modern
McpSchema.CompleteRequest. Completions are plain results, so McpSyncNotifier is
not available and progress reported through the context is dropped.
The method may return a modern McpSchema.CompleteResult or any of the legacy return
types, which are converted.
- Since:
- 2.1.0
- Author:
- Christian Tzolov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder forSyncModernMcpCompleteMethodCallbackinstances.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()io.modelcontextprotocol.modern.McpSchema.CompleteResultcomplete(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 io.modelcontextprotocol.modern.McpSchema.CompleteResult complete(io.modelcontextprotocol.modern.server.McpRequestContext context, io.modelcontextprotocol.modern.McpSchema.CompleteRequest request) - Specified by:
completein interfaceSyncCompletionRegistration.Handler
-
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
-