Interface McpPromptHandler
Implementations declare a descriptor (the McpPromptSpec returned by
prompts/list) and a get body invoked when the matching
prompts/get method runs.
This is a genuine two-method contract, not a single-method one: both descriptor() and
get(Map, BeanStore) are abstract, so it is deliberately not annotated
@FunctionalInterface and a bare lambda cannot implement it. Routing calls descriptor()
on every registered handler for both prompts/list and prompts/get, so a handler with no
usable descriptor is not a valid handler; making descriptor() abstract catches that at compile
time instead of the first request to reach it at runtime. Use of(McpPromptSpec, BiFunction) for
the common case of wiring both in a single expression.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the static descriptor for this prompt.Renders the prompt.static McpPromptHandlerof(McpPromptSpec descriptor, BiFunction<Map<String, Object>, BeanStore, McpPromptOutcome> get) Builds a handler from a fixed descriptor and agetlambda.
-
Method Details
-
of
static McpPromptHandler of(McpPromptSpec descriptor, BiFunction<Map<String, Object>, BeanStore, McpPromptOutcome> get) Builds a handler from a fixed descriptor and agetlambda.The sanctioned one-expression path for registering a prompt: unlike a bare lambda (which cannot satisfy this two-method interface at all), this factory wires both
descriptor()andget(Map, BeanStore)from a single call.- Parameters:
descriptor- The static descriptor returned from everydescriptor()call. Must not benull and must carry a non-blankname(routing matches incomingprompts/getrequests on name, so a nameless prompt would be silently unreachable).get- The get body, invoked with the incoming arguments and the per-request bean store. Must not benull .- Returns:
- A new handler wiring both. Never
null .
-
descriptor
Returns the static descriptor for this prompt.The
namevalue is used by the boundMcpRevisionto route incomingprompts/getrequests, so each handler in anMcpServerConfigmust use a unique name.- Returns:
- The prompt descriptor. Never
null.
-
get
Renders the prompt.- Parameters:
arguments- The arguments object passed in the JSON-RPC params (nevernull; empty map when omitted).ctx- Per-request bean store. Nevernull.- Returns:
- The rendered prompt. Never
null.
-