Project the final CallToolResult to the negotiated protocol version so version-gated fields are not emitted to peers that don't understand them. CallToolResult.structuredContent is a 2025-06-18+ field and is stripped for 2024-11-05 / 2025-03-26. An InputRequiredResult is draft-only (MRTR): its {inputRequests, [requestState]} shape carries no content and exists only on versions whose schema permits it. Emitting it to a non-MRTR peer, whose CallToolResult requires content, is a programming error (a handler ignoring the documented stateless contract), so reject it rather than projecting an off-schema result onto the wire.
Convenience: build a final result from a typed value. Serialises value to JSON and uses it as the result's structuredContent, defaulting the human-readable content to a single text block holding that same JSON. The serialisation is done inline here (independent of any CallToolResult.structured!T helper) so this overload stays compilable on its own.
The handler is done; r is the final result.
As inputRequired, but encodes a typed state as the opaque requestState. Serialises state to JSON and stores its string form. ENCODING CONTRACT: the stored value is serializeToJson(state).toString(), which RequestContext.requestStateAs!T() decodes via deserializeJson!T(parseJsonString(state)). Constrained off string so it does not collide with the verbatim-string overload above.
The handler needs input; the client must gather it and resubmit with the matching inputResponses.
As inputRequired, but also attaches an opaque requestState (SEP-2322): a stateless draft server encodes whatever context it needs to resume the call into this blob, which the client echoes verbatim on the retry and the handler reads back via RequestContext.requestState.
Whether this outcome asks the client for more input.
The MRTR inputRequests this outcome carries (empty unless needsInput). Read by the dispatch path so it can drop requests whose kind the client never declared.
The opaque MRTR requestState this outcome carries (empty unless set).
Return a copy of this input-required outcome with its inputRequests replaced by reqs (preserving requestState). Used by the dispatch path after filtering out unsupported request kinds.
The JSON-RPC result payload (the final result, or an InputRequiredResult).
The outcome of a tool call: either the final CallToolResult, or — on a stateless (MRTR) request — a set of InputRequests the client must satisfy and resubmit. There is no suspension or shared state: inputRequired simply ends this request, and the client opens a fresh one carrying the answers.