Skip to main content

success

Function success 

Source
pub fn success(answer: &impl Serialize) -> Result<JsonObject, OutcomeError>
Expand description

A handler’s answer, as a tools/call result.

An object answer becomes structuredContent and a text block holding the same JSON. The duplication is the specification’s own recommendation, not redundancy: a 2025-06-18 client reads structuredContent and a 2024-11-05 one reads the text, and a result carrying only the former is unreadable to the latter. A non-object answer is a text block alone, since there is no structured form to carry it.

structuredContent here is a 2025-06-18-or-later value. A codec targeting an earlier revision drops it, and that is the codec’s call to make.

§Errors

OutcomeError::Answer when answer will not serialise — a bug in the handler’s own types.