CrabTalk
Blog

MCP error handling: isError vs JSON-RPC errors, and errors an agent can recover from

When an MCP tool should return isError and when a JSON-RPC error, which one the model sees, the error codes, and how to write errors an agent can act on.

CrabTalk Team

An MCP server reports a failure in one of two ways: a JSON-RPC error, or a tool result with isError: true. The difference usually decides whether the model sees the failure. The specification says clients "SHOULD provide tool execution errors to language models to enable self-correction", while they may pass protocol errors on, which are "less likely to result in successful recovery" (tools, 2026-07-28). This post explains which error goes where, the codes, and what an error message needs for an agent to recover from it.

Two kinds of MCP error

Protocol errors are JSON-RPC errors. They mean the request itself was wrong: an unknown tool, a request that isn't a valid tools/call at all, a server fault.

{ "jsonrpc": "2.0", "id": 3, "error": { "code": -32602, "message": "Unknown tool: invalid_tool_name" } }

Tool execution errors are ordinary results with isError: true. They mean the tool ran, or tried to, and failed: an upstream API was down, the input was invalid, a business rule said no.

{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "content": [{ "type": "text", "text": "Invalid departure date: must be in the future. Current date is 08/08/2025." }],
    "isError": true,
    "resultType": "complete"
  }
}

In the 2026-07-28 revision a result also carries resultType. The 2025-11-25 revision moved input validation to the second kind: validation errors "should be returned as Tool Execution Errors rather than Protocol Errors" (changelog), so the model can fix its arguments and try again.

Which one to use

Failure Report as Why
Unknown tool, malformed JSON-RPC Protocol error The client or the request is broken
Wrong or missing arguments in a valid tools/call isError result The model can fix them
Upstream API down or timed out isError result The model can wait, retry or tell the person
Permission refused, budget spent isError result The model can ask the person to act
Server bug Protocol error, -32603 Nothing the model can do

The rule of thumb: if the model could do something about it, it's an isError result.

JSON-RPC error codes in MCP

Code Meaning
-32700 Parse error: invalid JSON
-32600 Invalid request
-32601 Method not found
-32602 Invalid params; also unknown tool, and, since 2026-07-28, resource not found
-32603 Internal error
-32000 to -32019 Legacy implementation codes; no new allocations
-32020 to -32099 Reserved for MCP
Outside -32768 to -32000 Application codes

The ranges are from the JSON-RPC 2.0 specification and the 2026-07-28 changelog, which also moved resource-not-found from -32002 to -32602 and UnsupportedProtocolVersion from -32004 to -32022. A server inventing new codes should pick them outside -32768 to -32000 (error responses).

Write errors the model can act on

The model reads the error text and decides what to do next. Anthropic's advice for tool authors is to "prompt-engineer your error responses to clearly communicate specific and actionable improvements" (Writing effective tools for agents), "rather than opaque error codes or tracebacks".

  • Say what to change. "date must be in the future; today is 2026-11-25" beats "invalid input".
  • Say whether to retry, and when. "Rate limited; retry after 2 seconds" tells the model what to do next.
  • Name the next step when it isn't the model's. If a person has to approve something, give the link.
  • Keep a stable code beside the text. The text is for the model; a code in structuredContent is for programs and for looking up the fix.

The model's own API has the same split: a tool result in the Claude API takes is_error: true, and "Claude might then call the tool again with a new tool_use block, so limit how many retries your loop allows" (handling tool calls).

How CrabTalk reports MCP errors

Over MCP, a tool call refused for something a person or the agent can fix (a missing grant, a spent budget, a changed deployment) comes back as an isError result. Its structuredContent holds the HTTP status, an error code and, when a person can fix it, the link they open. An excerpt:

{
  "isError": true,
  "structuredContent": {
    "status": 403,
    "explain": "E0009",
    "error": "acme/enrich is priced and this key may not call it; …",
    "request": { "url": "https://crabtalk.ai/grant/WDJB-MJHT" }
  }
}

Account execution throttles come back as JSON-RPC errors instead, with the retry delay in error.data; transport throttles are HTTP 429; a throttle where the service runs can arrive as an isError result with status 429; malformed arguments to query or call can return -32602; and a missing or invalid credential fails at HTTP before any MCP message is read. Each code has a page under Errors and an entry in crab explain, with what it means and what to do. The code and the link survive every hop between the service and the client, so an agent gets the same refusal over MCP, HTTP and the CLI.