Skip to content

2.2 Structured Error Responses

A structured error response is the result an MCP tool returns when a call fails. Its metadata tells the agent the error’s category, whether a retry can work, and how to recover. The MCP protocol provides the isError flag to report the failure to the agent. When the tool sets isError, the model knows that the execution failed. The model reasons about recovery, instead of reading the error text as a normal successful result. This response decides whether the agent recovers intelligently or fails without knowing what went wrong. A generic message such as “Operation failed” is useless to an LLM. It says nothing about what went wrong, whether to retry, or what to try instead.

This lesson uses one made-up example throughout: a picture framer whose agent handles orders through three MCP tools. They are a stock tool for a moulding supplier’s catalogue, a jobs tool for job references, and a refund tool.

The MCP specification reports tool failures through two separate kinds of response. To design recovery, first learn which kind of response a failure belongs to.

Protocol errors are standard JSON-RPC error responses. The server sends one when the request itself is malformed. This happens when the tool name does not exist, when the arguments fail the input schema, or when the server has an internal fault. The response has no result object, only an error with a code and a message. The host application handles protocol errors. The model never sees a tool result, because no tool ran. If the framer’s agent misspelt a tool name, the call would fail at this layer. Below is a generic example.

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

Tool execution errors are results. The tool was found, the arguments were valid and the tool ran. Then an error occurred inside the tool: an upstream API failed, the input data was wrong, or a business rule rejected the request. The server returns a normal result with isError: true and the detail in content. The model reads the result and decides what to do next. A failed stock check at the framer would be a tool execution error. Below is a generic example.

{
"jsonrpc": "2.0",
"id": 4,
"result": {
"content": [{ "type": "text", "text": "Failed to fetch weather data: API rate limit exceeded" }],
"isError": true
}
}

The four categories, isRetryable and the recovery guidance all describe execution errors, because the agent reasons about that layer. A protocol error means that the call was built incorrectly. Fix it in the tool schema or the client, not in the agent’s recovery loop.

Every tool failure belongs to one of four categories. Each category needs a different recovery strategy. The agent needs structured metadata to distinguish the categories.

The fields errorCategory, isRetryable and description are an application-level convention, not part of the MCP envelope. The envelope is the protocol’s CallToolResult, which defines only content, structuredContent and isError. The examples below put the metadata in structuredContent, which is where structured data belongs.

1. Transient Errors Timeouts, service unavailability, rate limits. The underlying system is briefly unreachable, but the request is valid. Recovery: retry after a short delay.

{
"isError": true,
"content": [{
"type": "text",
"text": "Service temporarily unavailable"
}],
"structuredContent": {
"errorCategory": "transient",
"isRetryable": true,
"description": "The order database is experiencing high load. The request is valid and should succeed on retry."
}
}

At the framer, a supplier catalogue that times out under load causes a transient error.

2. Validation Errors Invalid input format, missing required fields, out-of-range values. The request itself is malformed. Recovery: fix the input, then send a corrected call.

{
"isError": true,
"content": [{
"type": "text",
"text": "Invalid order ID format"
}],
"structuredContent": {
"errorCategory": "validation",
"isRetryable": false,
"description": "Order ID must be in format #NNNNN (e.g. #12345). Received: 'order-abc'. Reformat the ID and call again."
}
}

Here isRetryable: false does not mean “give up”. It means that resending this call is pointless, because order-abc fails the same format check every time. The agent still recovers by correcting the input first, and the description tells the agent how. The boolean says whether to resend. errorCategory says what to do instead. At the framer, a job reference in the wrong format is a validation error, which the agent fixes and resends.

3. Business Errors Policy violations, limit exceedances, business rule conflicts. The request is technically valid but breaks a business constraint. Recovery: do not retry. The agent needs an alternative workflow.

{
"isError": true,
"content": [{
"type": "text",
"text": "Refund exceeds policy limit"
}],
"structuredContent": {
"errorCategory": "business",
"isRetryable": false,
"description": "Refund amount of £750 exceeds the £500 automatic refund limit. This requires manager approval. Please escalate to a human agent with the refund details."
}
}

Business errors have isRetryable: false because the same policy violation applies every time. So a retry never resolves a business error. The agent has to take a different path, which is usually escalation. A customer-friendly explanation in the description lets the agent tell the customer why. At the framer, a refund above the automatic limit is a business error, so the agent escalates the refund to a person.

4. Permission Errors Access denied, insufficient credentials, authorisation failures. The tool cannot run because the caller lacks the required permissions. Recovery: escalate or use different credentials.

{
"isError": true,
"content": [{
"type": "text",
"text": "Access denied"
}],
"structuredContent": {
"errorCategory": "permission",
"isRetryable": false,
"description": "The current service account does not have permission to access financial records. Escalate to a senior agent with financial system access."
}
}

At the framer, a request for records that the agent has no rights to read raises a permission error.

isRetryable answers one narrow question: will resending this exact request work? Only transient errors get true, because the call was valid and the system was briefly unavailable. Every other category gets false, because something has to change first: the input (validation), the request itself (business) or the caller (permission).

Read isRetryable to decide whether to resend the call without changes. Then read errorCategory to decide what to do when you cannot resend it.

Category isRetryable Recovery
transient true Resend the same call after a delay
validation false Correct the input, send a new call
business false Take an alternative path or escalate
permission false Retry as a principal with the right access

The most important distinction is between the three false rows. The agent alone can recover from a validation error. Business and permission errors are not recoverable by the agent alone. A policy limit applies however the agent words the request. A permission error needs a different account, not a better call. So false means “not this call again”, not “stop”.

An access failure means the tool could not reach the data source. A timeout occurred, authentication failed, or the service was unavailable. The data might exist, but the tool could not check.

A valid empty result means the tool queried the data source successfully and found no matches. The query ran correctly, and no data matches the criteria. The agent should not retry. The answer is “no results found”.

A tool should distinguish the two. An access failure needs a retry decision. A valid empty result is a successful query with no matches. Confusing the two breaks recovery logic.

Say the framer’s agent asks the stock tool for a moulding the supplier has never made. The query runs and finds nothing. The tool’s response does not separate “I could not reach the catalogue” from “I reached it and found nothing”. So the agent treats the empty answer as a failure, retries three times and passes the request to a person. The tool succeeded.

To fix this, structure tool responses so that a successful query with no results is clearly different from a failed query. Below is a generic pair of responses.

// Valid empty result — NOT an error
{
"isError": false,
"content": [{
"type": "text",
"text": "No customer found matching email 'john@example.com'. The query executed successfully but returned no matches."
}],
"structuredContent": {
"resultCount": 0
}
}
// Access failure — IS an error
{
"isError": true,
"content": [{
"type": "text",
"text": "Could not reach customer database"
}],
"structuredContent": {
"errorCategory": "transient",
"isRetryable": true,
"description": "Connection to the customer database timed out after 5 seconds. The query did not execute."
}
}

In multi-agent systems, error handling follows one principle: recover locally, and propagate errors selectively. Say the framer’s coordinator sends a subagent to compare moulding prices from five suppliers.

  1. Subagents implement local recovery for transient failures. If one supplier’s price list times out, the subagent retries before it involves the coordinator.
  2. Only propagate errors that cannot be resolved locally. If all retries fail, the subagent reports the failure to the coordinator.
  3. Include partial results and what was attempted. The coordinator needs context: “I checked 3 of 5 suppliers successfully. Suppliers 4 and 5 timed out. Here are partial results from the 3 that answered.”

This principle prevents two anti-patterns: silently suppressing errors by returning empty results as success, and ending an entire workflow on a single failure. Both make the coordinator decide with missing information.

The key distinction to learn in this domain is between an access failure and a valid empty result. The exam tests it directly.

The exam guide names the four categories and the isRetryable boolean. So know them by name, even though the MCP specification does not define them. Expect questions on which category a failure belongs to and what recovery it needs. The guide specifies both. If a question depends on the isRetryable value for validation, ask whether resending this exact call would work. Your answer will be false.

Five exam-style multiple-choice questions on Structured Error Responses. Pick an answer, then open the explanation.

A tool returns an empty array after a customer lookup. The agent retries 3 times, then escalates to a human agent. Analysis shows the customer’s account simply does not exist. What is the root cause of this wasted effort?

  • A. The tool does not distinguish an access failure from a valid empty result, so the agent retries a success.
  • B. The retry limit is too low, and raising it to five would resolve this.
  • C. The escalation threshold is too aggressive; the agent should exhaust considerably more retries before it involves a human operator.
  • D. The system prompt should instruct the agent not to retry customer lookups.
Answer & explanation

Correct: A

  • A is correct because the tool queried the data source successfully and found no matches. That is a valid empty result rather than an access failure, but without structured metadata separating the two, the agent reads both as something worth retrying.
  • B is wrong because more retries make it worse. The query already succeeded, so repeating it returns the same empty array every time.
  • C is wrong because the escalation threshold is not the problem. The agent should not be retrying at all, and a valid empty result needs neither retry nor escalation.
  • D is wrong because hard-coding per-tool retry rules in the system prompt is brittle and does not generalise to the next tool. Structured error metadata is the durable fix.

A refund tool returns an error: “Refund amount of 750 pounds exceeds the 500 pounds automatic refund limit.” The agent retries 3 times. Why does each retry fail?

  • A. The retry delay is too short for the rule to update.
  • B. The tool is not returning the isError flag, so the agent never recognises that the call has failed at all.
  • C. The agent should automatically reduce the refund to the 500-pound limit and retry the call at the lower amount.
  • D. This is a business error, and the same policy applies on every attempt, so the agent should escalate.
Answer & explanation

Correct: D

  • D is correct because business errors such as policy violations and limit breaches are non-retryable by nature. The 500-pound limit applies identically on every attempt, so the agent has to take an alternative path, normally escalation to a manager.
  • A is wrong because business rules do not change between retries inside a session. The limit is policy, not a transient condition.
  • B is wrong because the isError flag is not the gap. The metadata fails to say isRetryable: false, so the agent treats a permanent refusal as a temporary one.
  • C is wrong because the agent should not quietly reduce the refund. The customer asked for 750 pounds, and only a human can approve or refuse that amount.

Which combination of error metadata fields enables an agent to make appropriate recovery decisions for any tool failure?

  • A. errorCode (integer), errorMessage (string), and timestamp (ISO date).
  • B. httpStatus (integer), retryAfter (seconds), and errorBody (JSON) carried straight through from the upstream service.
  • C. errorCategory (transient/validation/business/permission), isRetryable (boolean), and description.
  • D. severity (low, medium or high), businessImpact (free-text string), and resolution (free-text string).
Answer & explanation

Correct: C

  • C is correct because those three cover everything the agent has to decide: errorCategory says what kind of failure occurred, isRetryable says whether to retry or take an alternative path, and description carries human-readable guidance for recovery or escalation.
  • A is wrong because a code and a timestamp say nothing about whether to retry or what to do instead.
  • B is wrong because HTTP-centric metadata does not map cleanly onto MCP tool responses, and retryAfter speaks only to transient failures. Business and permission failures are left uncovered.
  • D is wrong because severity does not imply retryability. A high-severity transient error may be retryable while a low-severity business error is not.

In a multi-agent system, a web search subagent encounters a timeout on 2 of 5 sources. It has successful results from the other 3 sources. What should the subagent do?

  • A. Return only the 3 successful results, presenting them as though all 5 sources had been searched successfully.
  • B. Report partial results from the 3 sources that succeeded, noting that sources 4 and 5 timed out.
  • C. Report failure to the coordinator and discard every result, including those already gathered successfully.
  • D. Retry all 5 sources from scratch to guarantee coverage.
Answer & explanation

Correct: B

  • B is correct because the coordinator needs the findings and the shape of what was attempted: three of five sources searched, sources four and five timed out, here is what came back. That is what lets it decide whether to proceed, retry the two, or widen the search.
  • A is wrong because silently suppressing the timeouts hides failure information. The coordinator can no longer tell “nothing on those sources” from “could not reach those sources”.
  • C is wrong because discarding good results ends the whole workflow over a partial failure. Three sources’ worth of findings still have value.
  • D is wrong because retrying all five throws away work that already succeeded. Only sources four and five need another attempt.

A tool receives an identifier “order-abc” when the expected format is #NNNNN (e.g., #12345). The tool should return:

  • A. isError: true, errorCategory: “transient”, isRetryable: true, with a message telling the agent to retry later.
  • B. isError: false, with an empty result set indicating that no order matching that reference number was found.
  • C. isError: true, errorCategory: “business”, isRetryable: false, with a message telling the agent to escalate to a human.
  • D. isError: true, errorCategory: “validation”, isRetryable: false, with the expected format in the message.
Answer & explanation

Correct: D

  • D is correct because the format is wrong, which makes this a validation failure. isRetryable is false because resending “order-abc” fails the same check every time. That is not a dead end: the category tells the agent to reformat the identifier to #NNNNN and issue a new call, and the message supplies the format it needs.
  • A is wrong because nothing is temporarily unavailable. Waiting and resending the same malformed identifier produces the same error, which is exactly what isRetryable: true would invite.
  • B is wrong because an empty result hides the real problem. The tool did not search and find nothing; it could not search at all, and that is exactly the distinction the category exists to preserve.
  • C is wrong because no business rule was violated. A malformed identifier is a fixable input problem, not something that needs a human.