Class AsyncModernMcpPromptMethodCallback
- All Implemented Interfaces:
io.modelcontextprotocol.modern.server.feature.McpAsyncPrompt.Handler
SyncModernMcpPromptMethodCallback: serves a
prompts/get of a 2026-07-28 ("modern") MCP server by invoking a method
annotated with @McpPrompt.
A method may declare McpModernRequestContext, the SDK
McpRequestContext, McpAsyncNotifier 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 Mono, a CompletionStage or a Publisher
of a modern McpSchema.GetPromptOutcome 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 forAsyncModernMcpPromptMethodCallbackinstances.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()reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.McpAsyncResponse<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 reactor.core.publisher.Mono<io.modelcontextprotocol.modern.server.McpAsyncResponse<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.McpAsyncPrompt.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
-