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
  • Method Details

    • isModernInfrastructureParameter

      public static boolean isModernInfrastructureParameter(Class<?> parameterType)
      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:
      complete in interface SyncCompletionRegistration.Handler
    • validateParameters

      protected void validateParameters(Method method)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Validates method parameters. This method provides common validation logic and delegates exchange type checking to subclasses.
      Overrides:
      validateParameters in class AbstractMcpCompleteMethodCallback
      Parameters:
      method - The method to validate
    • validateReturnType

      protected void validateReturnType(Method method)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Validates 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:
      validateReturnType in class AbstractMcpCompleteMethodCallback
      Parameters:
      method - The method to validate
    • resolveTransportContext

      protected io.modelcontextprotocol.common.McpTransportContext resolveTransportContext(Object context)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Resolves 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:
      resolveTransportContext in class AbstractMcpCompleteMethodCallback
      Parameters:
      context - The server exchange or transport context
      Returns:
      The resolved transport context
    • isExchangeType

      protected boolean isExchangeType(Class<?> paramType)
      Description copied from class: AbstractMcpCompleteMethodCallback
      Checks 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:
      isExchangeType in class AbstractMcpCompleteMethodCallback
      Parameters:
      paramType - The parameter type to check
      Returns:
      true if the parameter type is compatible with the exchange type, false otherwise
    • builder