Setup
Start with a clean environment. In the tools list there is a tool reachable at:flaky_lookup and exposes two execution modes in the UI: “Anticipated” and “Protocol”. We’ll run both to demonstrate the differences.
Anticipated (tool-level) error
Select Anticipated and execute the tool. The UI returns a tool error:content that describes the failure. A simplified excerpt looks like:
is_error: trueindicates the tool execution failed at runtime.result_type: "complete"indicates the tool finished its execution path (albeit unsuccessfully), so the request is marked as complete in the UI.- The model receives this
contentpayload and can make decisions (retry, fallback, or ask for human input).
- Tool/runtime errors are actionable by the model because the error message is present in the tool’s
content. The model can decide how to proceed (e.g., schedule a retry, switch to a fallback tool, or ask for clarification). - Operators can monitor stderr for these runtime failures and correlate them with tool responses in the UI.
Protocol (MCP/JSON-RPC) error
Now clear the view and select Protocol, then execute the tool. In this scenario the MCP server rejects the call before the tool process runs. The UI displays a different failure:content error blob. A simplified JSON-RPC rejection looks like:
- There is no
contentpayload withis_errorfor the model to read. - This is a protocol-level rejection: the MCP/JSON-RPC layer refused or could not route the request, so the tool never executed.
- Protocol errors typically indicate operational conditions (maintenance, invalid request, authentication/authorization failures) that must be handled by the orchestration layer rather than by the model.
Protocol (JSON-RPC/MCP) errors are not intended to be surfaced to the model as tool output. They are rejections at the protocol layer and generally cannot be acted on by the model in the same way as tool runtime errors.
error object directly to the caller.
Key differences and takeaways
Tool errors are runtime failures produced by a tool and are intentionally surfaced to the model (via
content with is_error: true) so the model can act. Protocol errors are MCP/JSON-RPC-level rejections returned before tool execution; they are represented as an error object in the JSON-RPC response and are not actionable by the model in the same way.Recommended handling patterns
- Handle tool/runtime errors at the model level:
- Provide the model with the
contenterror payload so it can choose retries, fallbacks, or clarifying questions. - Implement retry/backoff and fallback tool strategies when upstream services are flaky.
- Provide the model with the
- Handle protocol errors at the orchestration layer:
- Detect JSON-RPC
errorresponses and perform orchestration-level actions (retry the request, alert operators, or surface a clear message to end users). - Do not rely on the model to interpret protocol errors as recoverable tool failures.
- Detect JSON-RPC
- Logging and monitoring:
- Correlate stderr tool runtime logs with the
contentresponses in the UI to diagnose runtime failures. - Monitor MCP/JSON-RPC error codes to detect systemic operational issues (maintenance windows, auth failures).
- Correlate stderr tool runtime logs with the
- JSON-RPC specification: https://www.jsonrpc.org/specification
- Best practices for error handling in orchestration systems: consider integrating structured logs and alerts for protocol-level failures