Interface McpElicitationHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
2026-07-28 SEP-2322
elicitation requests during a client-side Multi-Round-Trip-Request (MRTR) auto-resume loop.
Passed to McpClient.callToolWithElicitation(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>, org.apache.juneau.rest.client.mcp.v20260728.McpElicitationHandler), McpClient.getPromptWithElicitation(java.lang.String, java.util.Map<java.lang.String, java.lang.Object>, org.apache.juneau.rest.client.mcp.v20260728.McpElicitationHandler), and
McpClient.readResourceWithElicitation(java.lang.String, org.apache.juneau.rest.client.mcp.v20260728.McpElicitationHandler): each time the server pauses a call with an input_required
result, the client decodes that round's pending requests (there may be more than one) and invokes
elicit(Map) to obtain the matching answers, which it then echoes back on the resume call. This turns
the otherwise hand-driven McpClient.callRaw(java.lang.String, org.apache.juneau.bean.mcp.v20260728.RequestParams<?>)/ElicitationRequests/ElicitationResponses
loop into a single call plus one handler.
A handler answers by returning, keyed by the same server-assigned ids it was given, an ElicitResult
per request it wishes to answer — an ElicitAction.ACCEPT with content, or an
ElicitAction.DECLINE/ElicitAction.CANCEL to refuse. Decline/cancel answers are still sent back
to the server (which decides the terminal outcome of a refused elicitation); the client does not short-circuit
them locally.
- Since:
- 10.0.0
-
Method Summary
Modifier and TypeMethodDescriptionelicit(Map<String, ElicitRequest> requests) Answers one round of elicitation requests.
-
Method Details
-
elicit
Answers one round of elicitation requests.The returned map may legitimately omit ids the handler chooses not to answer (the server may then re-pause, bounded by the auto-resume loop's max-rounds guard); returning
null outright is illegal and causes the auto-resume loop to throwIllegalArgumentException; and any extra/unknown ids present in the returned map are echoed back to the server unvalidated.- Parameters:
requests- The pending requests for this round, keyed by server-assigned id (decoded viaElicitationRequests.requests(Map)). Nevernull ; may contain more than one entry, and an individual value may benull if the corresponding raw entry was absent/null .- Returns:
- The answers keyed by the same server-assigned ids. Must not be
null . AnElicitResultvalue must not benull . Use aLinkedHashMapfor deterministic ordering of the echoedinputResponses. May legitimately omit ids the handler chooses not to answer (the server may then re-pause, bounded by the loop's max-rounds guard). - Throws:
IOException- If the handler performs its own I/O (e.g. prompting a remote user) and it fails; the auto-resume loop propagates it to the caller unchanged.
-