Skip to main content
Welcome back. In this demonstration we compare two distinct error categories you’ll encounter when calling tools via MCP/JSON-RPC: tool (runtime) errors and protocol (MCP/JSON-RPC) errors. We’ll show representative request/response payloads, how each appears in the UI and server logs, and the correct place to handle them. This guide is useful when designing error handling for tool orchestration or when training models to react to tool outcomes.

Setup

Start with a clean environment. In the tools list there is a tool reachable at:
The tool is named 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:
Inspecting the Messages / Requests view shows the request and the tool’s response. The response contains an execution payload with content that describes the failure. A simplified excerpt looks like:
Key points:
  • is_error: true indicates 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 content payload and can make decisions (retry, fallback, or ask for human input).
Server logs typically surface the same error on stderr (tool runtime logs are commonly written to stderr; MCP protocol traffic often uses stdout). Example server log excerpt:
Why this matters
  • 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:
Inspecting the protocol layer shows a JSON-RPC style error response rather than a content error blob. A simplified JSON-RPC rejection looks like:
Notice the differences:
  • There is no content payload with is_error for 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.
Protocol-level rejections usually do not produce the same stderr runtime exception that tool-level failures do, because the tool process isn’t invoked. Instead, the MCP server returns a JSON-RPC 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.
Summary table: Tool error vs Protocol error
  • Handle tool/runtime errors at the model level:
    • Provide the model with the content error payload so it can choose retries, fallbacks, or clarifying questions.
    • Implement retry/backoff and fallback tool strategies when upstream services are flaky.
  • Handle protocol errors at the orchestration layer:
    • Detect JSON-RPC error responses 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.
  • Logging and monitoring:
    • Correlate stderr tool runtime logs with the content responses in the UI to diagnose runtime failures.
    • Monitor MCP/JSON-RPC error codes to detect systemic operational issues (maintenance windows, auth failures).
References
  • 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
By designing your error handling with these distinctions in mind, you’ll ensure that actionable failures are exposed to the model while orchestration-level problems are handled reliably outside the model’s reasoning context.

Watch Video