CertSafari
    Anthropic Claude Certified Architect – Foundations (CCAR-F)· Lessons

    Domain 2 · Lesson 9/30

    Structured error responses for MCP tools

    Implement structured error responses for MCP tools

    19 min read
    3.6% of exam
    9 sources
    Published 20 Oct 2026
    Docs as of 14 Oct 2026

    What you will be able to do

    • Tell apart the two MCP error channels: JSON-RPC protocol errors and tool execution errors that set isError
    • Explain why a uniform "Operation failed" response blocks recovery decisions, and which structured fields restore them
    • Sort a tool failure into one of four kinds (transient, validation, business or permission) and set isRetryable correctly for it
    • Write error results with errorCategory, isRetryable and a readable description, including a customer-friendly explanation for business-rule refusals
    • Decide whether a subagent should retry a failure itself or report it to the coordinator with partial results and a list of what it tried
    • Return a successful query with no matches as a valid result, and keep it separate from an access failure

    Key concept

    Tool execution error (isError) — A failure that happens inside a tool goes back to the agent as a normal tool result with isError set to true. The agent reads that result like any other, so the error text and metadata are what it uses to decide whether to retry, change the request, ask the user or give up.

    1.Two channels for MCP errors

    An MCP tool can fail in two ways, and each kind goes back on a different channel. If the request never reaches a working tool, the server sends a standard JSON-RPC error. Examples are a call to a tool that does not exist, or a request that does not fit the CallToolRequest schema. If the tool runs and the work fails, the server sends a normal result with isError: true. That covers an upstream API failing, an argument with the wrong value, or an operation that a business rule refuses. The difference matters because only the second channel reaches the model in a form it can act on. The MCP schema gives the reason: a tool's own failure reported as a protocol-level error would leave the model unable to see that an error occurred, while an isError result arrives as the tool's error text, the way any other tool result does.

    Protocol error: the tool name was not recognised, so the server returns a JSON-RPC error object instead of a resultjson
    {
      "jsonrpc": "2.0",
      "id": 3,
      "error": {
        "code": -32602,
        "message": "Unknown tool: invalid_tool_name"
      }
    }
    Tool execution error: the tool ran, rejected the input, and returned a normal result with isError setjson
    {
      "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
      }
    }

    Protocol errors point to a broken connection between client and server. The model can rarely fix them by changing what it sends. Execution errors do the opposite: they carry feedback the model can use to correct itself. A date in the wrong format, a value out of range or a missing required argument are all input validation errors, so they go back as isError: true results and not as protocol errors. The protocol channel is reserved for an unknown tool, a request that fails the CallToolRequest envelope, and server errors. If a tool's own failure goes out as a JSON-RPC error, the agent loses the chance to correct itself, because the model cannot see that the call failed.

    The Claude API uses the same pattern with different spelling. A client tool that fails returns a tool_result block with "is_error": true and the error text in content. Apart from the flag, an error result looks exactly like a success. Claude reads the flag and the text, then answers based on them. For example, it might tell the user the weather service is down and suggest trying later.

    Checkpoint 1 of 8· Fill the gap

    A tool ran but rejected the departure date because it was in the past. The server must send this failure so the model can see it and correct itself. Which top-level key completes this response?

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

    Sources123456

    2.Why "Operation failed" leaves the agent guessing

    When a tool reports an error, the agent has three possible moves. It can try again with corrected input, ask the user for clarification, or explain the limitation and stop. Each move depends on different information. To retry with corrected input, the agent needs to know which input was wrong. Asking the user only makes sense if a person can supply the missing piece. Explaining the limitation only helps if the explanation is true. The generic text "Operation failed" gives the agent none of this, so it falls back on guessing.

    Guessing goes wrong in predictable ways. If the agent treats every failure as temporary, it keeps resending a request that can never succeed. Each attempt costs a turn and tokens and changes nothing. If it treats every failure as final, it gives up on a timeout that would have cleared on the second try. If it apologises to the user for a "system problem" when a policy actually blocked the request, it misleads the customer about what happened.

    A uniform error response is the root of this. It folds very different failures into one signal: a timeout, a malformed date, a refused refund and a revoked token all arrive as the same "Operation failed", yet each needs its own recovery. The timeout needs a wait and a retry, the date needs a corrected argument, the refund needs an explanation to the customer, and the token needs someone to grant access. With identical text for all four, the agent cannot choose between those recoveries and can only apply one policy to every case. Structured metadata puts the choice back into the data. An errorCategory says what kind of failure occurred, an isRetryable flag says whether resending the same request could ever work, and a description says what to fix or tell the user. A false flag is what prevents wasted retry attempts: the agent skips resends that were never going to succeed.

    In an Agent SDK tool handler, the difference comes from whether you catch the error. If the handler throws an uncaught exception, the MCP server turns it into an error result containing the raw exception message. The agent loop keeps running, but Claude only sees whatever the exception happened to say. If the handler catches the error and returns isError: true itself, Claude sees a message you wrote. That message can explain which request failed and what to try instead, and the next section shows how to structure it.

    Checkpoint 2 of 8· Check yourself

    Your refund tool's handler catches every failure and returns isError: true with the text "Operation failed". A customer asks for a refund that company policy does not allow. What is the most likely result?

    Sources57

    3.Four categories of error and when to retry

    A structured error answers one question first: would the identical request succeed if it were sent again unchanged? The isRetryable boolean holds that answer. The errorCategory field says why, which tells the agent what has to change before the call can work. Most failures fall into one of four categories, and only one of them is retryable.

    The four error categories, whether the same request can be resent, and what the agent does next
    CategorySame request succeeds if resent?What has to changeAgent's next moveExample failure
    TransientYes, after a short waitNothing; the service has to recoverRetry, with backoffConnectionError: the weather service API is not available (HTTP 500)
    ValidationNoThe inputCorrect the arguments, then call againError: Missing required 'location' parameter
    BusinessNoThe request itself, or the account's stateExplain the rule to the user and offer alternativesToo many attendees (max 10)
    PermissionNoThe credentialsGet broader access or escalateToken lacks the role the operation requires

    Transient errors are timeouts, rate limits and services that are temporarily down. The request was valid, and a later attempt can succeed without any change, so these are the only errors with isRetryable: true.

    Validation errors mean the input is wrong: a wrong type, a wrong format, a value out of range, or a missing required field. Classing one as transient because "the agent can fix it later" confuses two things. A transient error goes away by itself. A validation error goes away only once the request changes. Mark it isRetryable: false and include a description that names the bad field, so the agent knows exactly what to correct.

    Permission errors and business errors are both refusals, but they come from different places. A permission error is about who is calling. Say a deploy_service call arrives with a token scoped only to read: it will fail every time it is sent with that token. That makes it errorCategory: "permission" with isRetryable: false, and the fix is a credential with the right role. It is not a transient outage, and the token is not malformed input. A business error is about what was asked for. A calendar that allows at most ten attendees, or an account under a legal hold, will refuse the request whoever sends it and however it is formatted. Business errors are also isRetryable: false, but they need one more thing: a customer-friendly explanation the agent can pass on to the user. With that, the agent can reply "the calendar only allows 10 attendees per event; I can split this into two sessions" instead of apologising for a system failure.

    These fields go inside the result your handler builds. MCP defines isError as the failure flag. Everything else in the result is up to the server: the text in content, and an optional structuredContent value that can follow the tool's output schema. Putting errorCategory, isRetryable and a description in that payload is a reasonable design for the content, not a breach of the protocol.

    Checkpoint 3 of 8· Check yourself

    Fifteen attendees are passed to create_calendar_event, and the calendar refuses with "Too many attendees (max 10)". Which error metadata from the handler lets the agent respond best?

    Checkpoint 4 of 8· Exam question

    A team is reviewing an MCP tool's error contract before launch. The current design returns isError: true with additional custom fields errorCategory: "validation" and isRetryable: true whenever the caller omits a required customer_id argument, on the reasoning that the agent might supply it correctly on a later attempt within the same conversation. What is the primary flaw in this retry guidance?

    Checkpoint 5 of 8· Exam question

    A deploy_service MCP tool requires an API token scoped to the deploy role. An agent calls it using a token scoped only to read. The server returns isError: true with generic text "Operation failed." Under a structured error design, how should this failure be categorized and handled differently from a network timeout on the same tool?

    Sources68523

    4.Using isRetryable to choose between retrying and escalating

    In a multi-agent system, a subagent handles what it can fix itself and passes the rest up to the coordinator, as described in Recover locally, propagate what's left. The isRetryable flag is what lets the subagent make that call without guessing. A transient error is the subagent's to absorb: it retries with backoff, and the coordinator never needs to hear about it unless the retries run out. A non-retryable error is different. Retrying with the same credentials or inputs cannot change the result, so the subagent stops and reports. The category tells the coordinator what kind of help is needed, such as broader credentials, a corrected input or a decision from a person.

    The report should cover the whole batch, not just the failures. Take a subagent that enriches 50 customer records through a lookup_address tool. 47 lookups succeed, and 3 come back isError: true with errorCategory: "permission" because its credentials don't cover those customers' region. It cannot get broader credentials itself. The useful response contains three things:

    • The 47 enriched records, returned as partial results
    • The 3 unresolved customers, each with its permission error and description
    • What was attempted, so the coordinator doesn't repeat lookups that already failed

    Each alternative fails in its own way. Leaving out the three failures hides a gap, and the coordinator will treat the batch as complete. Marking the whole batch as an error throws away 47 good results because of 3 bad ones. Retrying the permission failures with backoff wastes calls on errors that have already said they will not clear.

    Checkpoint 6 of 8· Check yourself

    Which report should reach the coordinator when a subagent enriching 50 customer records through lookup_address gets 47 successes and 3 isError: true results with errorCategory "permission" because its credentials don't cover those customers' region?

    Checkpoint 7 of 8· Exam question

    A subagent responsible for enriching customer records calls an internal lookup_address tool for 50 customers. For 47 the lookup succeeds; for 3 the tool returns isError: true with errorCategory: "permission" because the subagent's credentials lack access to those records' region. The subagent cannot obtain broader credentials itself. What should it send back to the coordinator?

    Sources51

    5.An empty result is not an access failure

    A query that ran and found nothing is a success. A query that could not run is a failure. They can look alike, since in both cases no data comes back, but they mean opposite things. If isError is left unset, the call is treated as successful. A search_tickets call that finds zero tickets for a customer should therefore return a normal result: an empty list and isError false. That is a complete answer: this customer has no matching tickets.

    Mixing up the two cases goes wrong in both directions. If an empty search comes back as isError: true with the text "No tickets found", the agent thinks the system is broken. It apologises for a failure that never happened, or it retries a query whose answer will not change. The opposite mistake is worse. If a timeout or a denied request comes back as an empty list, the agent tells the user confidently that nothing exists, when in fact nobody looked. An access failure needs an error result so the agent can decide whether to retry. An empty match does not need that decision.

    Here is the test for any "no data" case: did the tool actually answer the question it was asked? A calendar listing that returns {"events": []} did: that day has no events. A listing that timed out before reaching the calendar did not, so it returns isError: true, errorCategory: "transient" and isRetryable: true.

    Checkpoint 8 of 8· Match them up

    Match each "no data came back" outcome to the tool result the handler should return.

    Tap a term, then the definition that fits it.

    Sources39

    Sources

    (9)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Protocol Errors indicate issues with the request structure itself that models are less likely to be able to fix”
      ↩︎ Two channels for MCP errors
      “Tool Execution Errors contain actionable feedback that language models can use to self-correct and retry with adjusted parameters”
      ↩︎ Two channels for MCP errors
      “should return a tool execution error that says so, so the model can recover by creating a new one.”
      ↩︎ Using isRetryable to choose between retrying and escalating
      “Tool Execution Errors contain actionable feedback that language models can use to self-correct and retry with adjusted parameters”
      ↩︎ Checkpoint
    2. 2.
      “Input validation errors (e.g., date in wrong format, value out of range)”
      ↩︎ Two channels for MCP errors
      “Malformed requests (requests that fail to satisfy CallToolRequest schema)”
      ↩︎ Two channels for MCP errors
      “Implement proper access controls”
      ↩︎ Four categories of error and when to retry
      “Implement proper access controls”
      ↩︎ Exam trap 2
    3. 3.
      “Otherwise, the LLM would not be able to see that an error occurred and self-correct.”
      ↩︎ Two channels for MCP errors
      “An optional JSON value that represents the structured result of the tool call.”
      ↩︎ Four categories of error and when to retry
      “If not set, this is assumed to be false (the call was successful).”
      ↩︎ An empty result is not an access failure
      “Any errors that originate from the tool SHOULD be reported inside the result object, with isError set to true”
      ↩︎ Key concept
      “If not set, this is assumed to be false (the call was successful).”
      ↩︎ Exam trap 3
      “Otherwise, the LLM would not be able to see that an error occurred and self-correct.”
      ↩︎ Exam trap 4
    4. 4.
      “when a tool returns a result marked isError: true, Claude receives the result”
      ↩︎ Two channels for MCP errors
    5. 5.
      “The is_error flag is the only difference from a successful result.”
      ↩︎ Two channels for MCP errors
      “Claude reads the error and can retry with corrected input, ask the user for clarification, or explain the limitation.”
      ↩︎ Why "Operation failed" leaves the agent guessing
      “I can split this into two sessions, or you can let me know which 10 people to prioritize.”
      ↩︎ Four categories of error and when to retry
      “When a tool raises an error, send the error message back with is_error: true instead of crashing.”
      ↩︎ Using isRetryable to choose between retrying and escalating
      “I tried to schedule the all-hands but the calendar only allows 10 attendees per event. I can split this into two sessions”
      ↩︎ Checkpoint
    6. 6.
      “ConnectionError: the weather service API is not available (HTTP 500)”
      ↩︎ Two channels for MCP errors
      “If a tool request is invalid or missing parameters, Claude will retry 2-3 times with corrections before apologizing to the user.”
      ↩︎ Four categories of error and when to retry
      “If a tool request is invalid or missing parameters, Claude will retry 2-3 times with corrections before apologizing to the user.”
      ↩︎ Exam trap 1
    7. 7.
      “The MCP server converts it to an error result carrying the raw exception message. Claude sees that message, and the agent loop continues.”
      ↩︎ Why "Operation failed" leaves the agent guessing
      “You can add context the raw exception lacks, such as which request failed or what to try instead.”
      ↩︎ Why "Operation failed" leaves the agent guessing
      “You can add context the raw exception lacks, such as which request failed or what to try instead.”
      ↩︎ Exam trap 5
    8. 9.
      “If true, the content typically describes the error that occurred. Default: false”
      ↩︎ An empty result is not an access failure

    Ready to test yourself?

    Practise the 15 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.