← Back to Labs

Structured Error Response

tool design mcpFill in Blank

Complete this MCP tool error response for a timeout when calling an external order tracking API. The response must communicate the failure type, whether it can be retried, and set the correct error flag.

// The order tracking API timed out after 5 seconds.
// Return a structured error response so the agent can decide how to recover.
return {
  content: [
    {
      type: "text",
      text: JSON.stringify({
        errorCategory: "",
        isRetryable: ,
        message: "Order tracking API timed out after 5000ms.",
        suggestedAction: "Retry the request or inform the customer of a brief delay.",
        context: { orderId: "#12345", timeoutMs: 5000 },
      }),
    },
  ],
  isError: ,
};
Next Exercise →