Class SyncModernMcpPromptMethodCallback

java.lang.Object
org.springframework.ai.mcp.annotation.method.prompt.AbstractMcpPromptMethodCallback
org.springframework.ai.mcp.annotation.method.prompt.SyncModernMcpPromptMethodCallback
All Implemented Interfaces:
io.modelcontextprotocol.modern.server.feature.McpSyncPrompt.Handler

public final class SyncModernMcpPromptMethodCallback extends AbstractMcpPromptMethodCallback implements io.modelcontextprotocol.modern.server.feature.McpSyncPrompt.Handler
Serves a prompts/get of a 2026-07-28 ("modern") MCP server by invoking a method annotated with @McpPrompt.

Beyond the parameters the stateless callback supports, a method may declare McpModernSyncRequestContext, the SDK McpRequestContext, McpSyncNotifier or the modern McpSchema.GetPromptRequest (which carries the MRTR fields). A method that declares the notifier is served as a streaming response so that progress notifications can be pushed before the result; the context alone leaves the response a plain result.

The method may return a modern McpSchema.GetPromptOutcome (a GetPromptResult or an InputRequiredResult) 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 prompt arguments.
    • isStreaming

      public boolean isStreaming()
    • get

      public io.modelcontextprotocol.modern.server.McpSyncResponse<io.modelcontextprotocol.modern.McpSchema.GetPromptOutcome> get(io.modelcontextprotocol.modern.server.McpRequestContext context, io.modelcontextprotocol.modern.McpSchema.GetPromptRequest request)
      Specified by:
      get in interface io.modelcontextprotocol.modern.server.feature.McpSyncPrompt.Handler
    • validateParamType

      protected void validateParamType(Class<?> paramType)
      Overrides:
      validateParamType in class AbstractMcpPromptMethodCallback
    • isSupportedExchangeOrContextType

      protected boolean isSupportedExchangeOrContextType(Class<?> paramType)
      Description copied from class: AbstractMcpPromptMethodCallback
      Checks if a parameter type is compatible with the exchange type.
      Specified by:
      isSupportedExchangeOrContextType in class AbstractMcpPromptMethodCallback
      Parameters:
      paramType - The parameter type to check
      Returns:
      true if the parameter type is compatible with the exchange type, false otherwise
    • assignExchangeType

      protected Object assignExchangeType(Class<?> paramType, Object exchange)
      Specified by:
      assignExchangeType in class AbstractMcpPromptMethodCallback
    • validateReturnType

      protected void validateReturnType(Method method)
      Description copied from class: AbstractMcpPromptMethodCallback
      Validates that the method return type is compatible with the prompt callback.
      Specified by:
      validateReturnType in class AbstractMcpPromptMethodCallback
      Parameters:
      method - The method to validate
    • builder