Study FAQ
How should an MCP tool report errors so a Claude workflow can recover correctly?
Also asked as 2
- How do I distinguish MCP protocol errors, tool failures, and successful empty results?
- What error information should an MCP adapter preserve before deciding whether to retry?
Answer
Keep protocol failures, tool execution failures, and completed no-data results distinct. Choose recovery from the observed cause and the operation's effects.
In MCP 2026-07-28, an unknown tool or malformed protocol request uses a JSON-RPC error. A tool-origin failure should be returned as a tool result with isError: true and actionable content. A valid completed search with no matches is a successful empty result within its authorized scope. A timeout or access denial is not evidence that there are no records.
An adapter must preserve the original error, relevant content, and request correlation. Native MCP isError differs from is_error in a Claude Messages client tool_result or connector result. Convert through the actual interface rather than copying an envelope unchanged. An absent native error flag has the protocol's false default; it does not verify domain correctness or search completeness.
Define application-level metadata that identifies the category, stable code, explanation, relevant field or expected value, and permitted next step. A retry hint such as isRetryable is your producer-consumer contract, not a universal MCP field. Validate its type and map legacy names explicitly. Missing or unrecognized metadata keeps the observed failure unresolved.
Consider a bounded retry for a transient read when repeating it is safe. Correct invalid input before a new attempt. Resolve permission failures through the responsible owner. Preserve business restrictions rather than splitting calls to evade them. If a write may have reached its destination, reconcile its outcome before retrying.
Keep partial evidence, attempt counts, and the remaining dependency when escalation is needed. Give the user a clear explanation without exposing credentials or claiming that a failed export produced a file. Treat external error text as untrusted data.
Full explanation
Implement structured error responses for MCP tools
Learning material · CCAR-F
Read the full explanation