# How should an agent handle errors from an MCP server?

Pass a tool result marked `isError: true` back to the model, and handle JSON-RPC errors in the client: retry `-32022` with a version from the server's `data.supported` list, resend with the capabilities `-32021` names if your client has them, and otherwise fix the request or stop. That's per the Model Context Protocol's 2026-07-28 specification, current as of October 2026.

The standard codes come from the JSON-RPC 2.0 specification: `-32700` parse error, `-32600` invalid request, `-32601` method not found, `-32602` invalid params, and `-32603` internal error. MCP uses `-32602` for an unknown tool, a missing resource, and a request without its required `_meta` fields. Sent again unchanged, those fail again, which is [how a retry storm starts](/answers/failure-modes/what-causes-a-retry-storm-in-an-agent). `-32603` is the one a retry might fix, but the spec sets no retry rule for it, so bound it yourself.

`-32020` means required HTTP headers are missing or don't match the request body, so your client sent something wrong. Codes from `-32000` to `-32019` are legacy, and the spec says not to read a meaning into them, except `-32002`, which older servers send for a missing resource. A timeout your SDK raises carries no MCP code, since it never came from the server, and the request may still be running there, so resending it can run it twice.

---

Published: 2026-10-18

Sources:
- Model Context Protocol specification 2026-07-28: Overview (error codes): https://modelcontextprotocol.io/specification/2026-07-28/basic (fetched 2026-10-18)
- Model Context Protocol specification 2026-07-28: Versioning: https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning (fetched 2026-10-18)
- Model Context Protocol specification 2026-07-28: Tools: https://modelcontextprotocol.io/specification/2026-07-28/server/tools (fetched 2026-10-18)
- Model Context Protocol specification 2026-07-28: Resources: https://modelcontextprotocol.io/specification/2026-07-28/server/resources (fetched 2026-10-18)
- JSON-RPC 2.0 Specification: https://www.jsonrpc.org/specification (fetched 2026-10-18)

Source: https://tessary.ai/answers/mcp-tool-reliability/how-should-an-agent-handle-errors-from-an-mcp-server
More on MCP tool reliability: https://tessary.ai/answers/mcp-tool-reliability
From Tessary, agent reliability for AI agents in production: https://tessary.ai
