講座 › 分野2 ツール設計とMCP統合
2.2 MCPツールの構造化エラー
配点 3.6%Structured error responses
ツールが失敗したとき、エージェントが次の手を選べる情報を返す。「失敗しました」だけでは足りない。
未読
失敗は、失敗として伝える 読了

MCPでは、ツールの実行中の失敗は、結果の中で失敗の印(isError)を付けて返します。この印があれば、モデルは失敗だと分かり、別の方法を考えられます。
出典:MCP 仕様:Tools
Tool Execution Errors contain actionable feedback that language models can use to self-correct and retry with adjusted parametershttps://modelcontextprotocol.io/specification/2026-07-28/server/tools.…(取得 2026-11-20)
出典:MCP 仕様:Tools
Clients SHOULD provide tool execution errors to language models to enable self-correction.https://modelcontextprotocol.io/specification/2026-07-28/server/tools.…(取得 2026-11-20)
2種類のエラーを区別する 読了

要求の形そのものが間違っている通信のエラーは、モデルが直しにくい種類です。日付の形式違いや値の範囲外のような、ツール実行のエラーは、モデルが直して再試行できます。
出典:MCP 仕様:Tools
Protocol Errors indicate issues with the request structure itself that models are less likely to be able to fixhttps://modelcontextprotocol.io/specification/2026-07-28/server/tools.…(取得 2026-11-20)
出典:MCP 仕様:Tools
Input validation errors (e.g., date in wrong format, value out of range)https://modelcontextprotocol.io/specification/2026-07-28/server/tools.…(取得 2026-11-20)
原因の種類を分ける 読了

一時的な失敗(時間切れ、サービス停止)、入力の検証の失敗、業務の規則への違反、権限の不足。この4つは、取るべき対応が違います。どれも「操作に失敗しました」で返すと、エージェントは対応を選べません。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
The distinction between transient errors (timeouts, service unavailability), validation errors (invalid input), business errors (policy violations), and permission errorshttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Why uniform error responses (generic "Operation failed") prevent the agent from making appropriate recovery decisionshttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
返す情報:分類・再試行の可否・説明 読了

エラーの分類、再試行して意味があるかどうか、人が読める説明を、構造化して返します。業務規則の違反には、再試行しても無駄だという印と、利用者に伝えられる説明を付けます。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Returning structured error metadata including errorCategory (transient/validation/permission), isRetryable boolean, and human-readable descriptionshttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Including retriable: false flags and customer-friendly explanations for business rule violations so the agent can communicate appropriatelyhttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Custom tools
Claude sees the message you compose. You can add context the raw exception lacks, such as which request failed or what to try instead.https://code.claude.com/docs/en/agent-sdk/custom-tools.md(取得 2026-11-20)
「失敗」と「該当なしの成功」は別物 読了

照会に成功して、結果が0件だった場合は、正常な応答です。接続できなかった失敗とは違います。混ぜると、失敗を空の結果として隠したり、正常な0件を失敗として再試行したりします。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Distinguishing between access failures (needing retry decisions) and valid empty results (representing successful queries with no matches)https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
サブエージェントの中で直し、直せない分だけ上げる 読了

一時的な失敗は、サブエージェントの中で再試行して解決します。解決できないときだけ、調整役に上げます。そのとき、何を試したか、途中までの結果も添えます。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Implementing local error recovery within subagents for transient failures, propagating to the coordinator only errors that cannot be resolved locally along with partial results and what was attemptedhttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
試験のポイント
- 失敗は、失敗の印と、分類・再試行の可否・説明つきで返す。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Returning structured error metadata including errorCategory (transient/validation/permission), isRetryable boolean, and human-readable descriptions
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20) - 一時的・検証・業務・権限の4種類は、対応が違う。一律の「失敗」は避ける。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
The distinction between transient errors (timeouts, service unavailability), validation errors (invalid input), business errors (policy violations), and permission errors
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20) - 0件の成功と、接続の失敗は区別する。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Distinguishing between access failures (needing retry decisions) and valid empty results (representing successful queries with no matches)
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)