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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder forSyncModernMcpPromptMethodCallbackinstances.Nested classes/interfaces inherited from class org.springframework.ai.mcp.annotation.method.prompt.AbstractMcpPromptMethodCallback
AbstractMcpPromptMethodCallback.AbstractBuilder<B extends AbstractMcpPromptMethodCallback.AbstractBuilder<B,T>, T extends AbstractMcpPromptMethodCallback> -
Field Summary
Fields inherited from class org.springframework.ai.mcp.annotation.method.prompt.AbstractMcpPromptMethodCallback
bean, method, prompt -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectassignExchangeType(Class<?> paramType, Object exchange) builder()io.modelcontextprotocol.modern.server.McpSyncResponse<io.modelcontextprotocol.modern.McpSchema.GetPromptOutcome>get(io.modelcontextprotocol.modern.server.McpRequestContext context, io.modelcontextprotocol.modern.McpSchema.GetPromptRequest request) static booleanisModernInfrastructureParameter(Class<?> parameterType) Whether a parameter of this type is injected by the modern callback rather than bound from the prompt arguments.booleanprotected booleanisSupportedExchangeOrContextType(Class<?> paramType) Checks if a parameter type is compatible with the exchange type.protected voidvalidateParamType(Class<?> paramType) protected voidvalidateReturnType(Method method) Validates that the method return type is compatible with the prompt callback.Methods inherited from class org.springframework.ai.mcp.annotation.method.prompt.AbstractMcpPromptMethodCallback
buildArgs, convertArgumentValue, convertToGetPromptResult, validateMethod, validateParameters
-
Method Details
-
isModernInfrastructureParameter
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:
getin interfaceio.modelcontextprotocol.modern.server.feature.McpSyncPrompt.Handler
-
validateParamType
- Overrides:
validateParamTypein classAbstractMcpPromptMethodCallback
-
isSupportedExchangeOrContextType
Description copied from class:AbstractMcpPromptMethodCallbackChecks if a parameter type is compatible with the exchange type.- Specified by:
isSupportedExchangeOrContextTypein classAbstractMcpPromptMethodCallback- Parameters:
paramType- The parameter type to check- Returns:
- true if the parameter type is compatible with the exchange type, false otherwise
-
assignExchangeType
- Specified by:
assignExchangeTypein classAbstractMcpPromptMethodCallback
-
validateReturnType
Description copied from class:AbstractMcpPromptMethodCallbackValidates that the method return type is compatible with the prompt callback.- Specified by:
validateReturnTypein classAbstractMcpPromptMethodCallback- Parameters:
method- The method to validate
-
builder
-