pub struct ToolFailure(/* private fields */);Expand description
A tool failure the model is meant to read and act on.
MCP has two error channels, and which one you use decides whether the text ever
reaches the model. JSON-RPC protocol errors are for the client’s problems –
unknown tool, arguments that violate the schema – and a client may reasonably
treat one as a transport failure. Tool execution errors are returned as an
ordinary result with isError: true, precisely so the model can see them and
try something else.
Everything this server produces is the second kind: “run login”, “the item ids
currently in the cart are X and Y”, “quantity must be greater than 0”. Those
messages exist to be acted on, and as protocol errors they were at risk of being
swallowed. Verified on the wire, not assumed – see tests/mcp_protocol.rs.
The mechanism: rmcp flips isError for any error type that converts to content;
only ErrorData (rmcp’s own) short-circuits into a protocol error. Hence a type of
our own. Not an intra-doc link: with --no-deps, the rmcp pages it would point at
are never generated, so even a fully-qualified path would resolve to a dead link.