Tool use fails in three places, and each task owns one.
Failure
What goes wrong
Usual causes
Fix
Selection
The model picks the wrong tool
Vague or overlapping descriptions, keyword-sensitive system prompt (2.1); too many tools (2.3); thin MCP descriptions losing to built-ins (2.4)
Better descriptions, fewer role-scoped tools, a rename
Execution
The tool runs and fails
No structured error metadata, so the agent cannot tell retry from rephrase from escalate (2.2)
errorCategory, isRetryable, a readable message
Fit
The right tool for the wrong job
A generic tool doing several jobs (2.1); built-in misuse (2.5)
Split the tool; Grep for contents, Glob for paths, Edit for targeted changes
A selection problem is almost never fixed by a new component (router, classifier): it is a description, a smaller tool set or a rename.
2.1 — Tool interface design
Tool descriptions are THE selection mechanism — not metadata. Misrouting fix order: expand descriptions first, never few-shot examples, a routing classifier, or consolidation as step one.
Five elements of a production description: purpose · inputs w/formats · example queries · edge cases/limits · boundaries vs similar tools. The negative boundary (when not to use it, which sibling instead) is the most-omitted element.
API docs' checklist: what it does · when to use it and when not · what each parameter means · caveats/limits; "at least 3–4 sentences".
Messages API tool name regex: ^[a-zA-Z0-9_-]{1,128}$. Required fields: name, description, input_schema; input_examples optional (each must validate against input_schema).
Casing trap: API input_schema (snake_case) vs MCP inputSchema (camelCase). outputSchema, title, annotations are MCP-only; nearest API-side control is strict: true (inputs match the schema).
Annotation hints: readOnlyHint, destructiveHint, idempotentHint, openWorldHint — advisory; clients MUST treat them as untrusted unless the server is trusted.
One generic tool, different input/output contracts
Split (the guide's fix)
Same contract, different verb
One tool with an action parameter (docs' consolidation) — still loses as a "first step"
System-prompt interference: good descriptions + one tool systematically over-selected + its name/domain word in the system prompt → audit the prompt and reword neutrally. Prompt sets the goal; descriptions decide routing.
Build workflow tools, not API wrappers: schedule_event not list_events+create_event. Namespace by service (asana_search) or resource (asana_projects_search).
Claude Code cuts server instructions and upfront tool descriptions at 4,096 characters, and descriptions of tools loaded through tool search at 16,384 (2,048 before v2.1.296) — put critical details first. Tool search (default on): MCP tools deferred and discovered on demand; only tool names and server instructions load at session start.
2.2 — Structured error responses
Category
isRetryable
Recovery
Transient (timeout, rate limit)
true
Retry after delay
Validation (bad input)
Guide assigns no value (lesson: true)
Fix input, call again — never resend unchanged
Business (policy violation)
false
Explain to customer, alternative path / escalate
Permission (access denied)
false
Escalate / different credentials
MCP's two error channels (spec 2026-07-28): protocol errors (JSON-RPC: unknown tool, malformed request, server error) vs tool execution errors (isError: true inside a successful result: API failures, input validation, business logic). Invalid tool arguments are execution errors now (the 2025-06-18 revision listed them as protocol errors).
Clients SHOULD pass tool execution errors to the model; they only MAY pass protocol errors. A business refusal raised as a protocol error may never reach the model.
errorCategory / isRetryable / description are the guide's application convention, not MCP fields: carry them as JSON in the text block and/or structuredContent.
Messages API equivalent: tool_result.is_error; MCP connector: mcp_tool_result.is_error.
structuredContent = a JSON value (any type in 2026-07-28), also serialised to a text block; if outputSchema is declared, server MUST conform, client SHOULD validate.
Access failure (isError:true, couldn't reach data) ≠ valid empty result (isError:false, resultCount:0, reached data + found nothing). Empty-as-error → wasted retries + false escalation; failure-as-empty → confident decisions on missing data. The #1 tested distinction.
Invalid tool call: report with is_error: true; Claude may call again, so cap retries in your loop (no fixed 2–3× promise). strict: true prevents missing params/type mismatches only.
Agent SDK: an uncaught handler exception becomes an error result carrying the raw exception message; catch it yourself to compose the recovery message.
Multi-agent propagation: local recovery for transient failures first; propagate only unresolvable errors with failure type · what was attempted · partial results · alternatives. Never silently suppress (empty-as-success), never kill the whole workflow, never a generic "search unavailable" after retries (sample Q8).
2.3 — Tool distribution & tool_choice
4-5 tools per agent (the guide's figure, against 18), scoped to its role. Bloated/overlapping tool sets are a named Anthropic failure mode (ambiguous decision points + wasted context).
Two levers: distribution = which tools an agent has (persists); tool_choice = whether a tool must be called (one request).
Scoped cross-role tool (sample Q9: 85% simple checks, 2-3 round trips, +40% latency): give synthesis a narrow verify_fact; complex 15% still via coordinator. Not full web search, not batching, not speculative caching.
Replace generic tools with constrained ones: fetch_url → load_document (validates before fetching) = least privilege. Same for run_query(sql) → get_order(order_id).
Agent SDK AgentDefinition.tools omitted → subagent inherits every tool; a left-out tool is simply absent (no prompt, no error).
tool_choice.type
Behaviour
Default when
auto
Model decides tool vs text
tools provided
any
Must call some tool (several schemas, document type unknown)
—
tool
Must call the named tool: {"type":"tool","name":"…"}
—
none
May not call any tool
no tools provided
Force the first call, then release to auto; forcing every turn loops until the turn cap.
tool_choicecannot: enforce a session-wide rule (use a hook) · validate arguments (strict: true) · make a tool exist (distribution).
Forced (any/tool): the response starts with a tool call — no text before tool_use, even if asked.
Manual extended thinking works only with auto/none; any/toolerror out. Adaptive thinking doesn't block forcing, but a forced call skips thinking.
Current product: Fable 5.2, Mythos 5.2, Opus 5.5, Sonnet 5.5, Fable 5.1, Mythos 5.1 return 400 for any/tool (docs: auto + strict tool use, or structured outputs). Exam answer unchanged: any / forced.
disable_parallel_tool_use lives insidetool_choice, not top-level. With auto: at most one call. With any/tool: exactly one call.
claude mcp add --transport http <name> <url> # remote HTTPclaude mcp add [opts] <name> -- <command> [args...] # local stdio (-- required)claude mcp add-json <name> '<json>' # from JSON
Scope
Storage
Shared?
Notes
local (default)
~/.claude.json, nested under project path
No
This project only
project
.mcp.json in project root
Yes (VCS)
Team-shared; approval prompt in interactive sessions (-p/SDK load without asking)
user
~/.claude.json
No
All your projects
Exam guide's two tiers: project (.mcp.json, team) vs user-level (~/.claude.json, personal) — the guide's "user-level" covers both local and user.
Precedence on name collision: local > project > user > plugin servers > claude.ai connectors — whole entry wins, never merged; managedMcpServers ranks above all. Same name, different endpoints → warning in claude mcp list and /mcp.
MCP "local scope" (~/.claude.json) ≠ general local settings (.claude/settings.local.json) — classic exam trap.
Env var expansion: ${VAR} and ${VAR:-default}, valid in command/args/env/url/headers. Unset with no default: config still loads, warning, literal ${VAR} used. Empty string counts as set. Never a real token as the default.
Dynamic auth headers: headersHelper (command run at connection time). OAuth via /mcp or claude mcp login <name>; not possible in -p/SDK runs.
Transports (spec 2026-07-28): stdio and Streamable HTTP (POST to one endpoint; JSON or request-scoped SSE reply); custom allowed. Standalone SSE deprecated in Claude Code. type: "streamable-http" aliases "http"; a url with no type is an error. SDK heuristic: command → stdio, URL → HTTP/SSE, own code → SDK MCP server.
/mcp = status / OAuth login. claude mcp list|get|remove. Project-server approval resets via claude mcp reset-project-choices. --strict-mcp-config + --mcp-config = only the servers you pass (CI).
Current product: tool search defers MCP tool definitions. Exam answer: tools from all configured servers are discovered at connection time and available simultaneously.
Tools
Resources
What
Action (create_issue)
Content (issue catalogue, docs tree, DB schema)
Driven by
Model-controlled
Application-driven
Stem wording
"agent needs to do X"
"agent needs visibility into what exists" / many exploratory calls
MCP resource @-mention: @server:protocol://resource/path. MCP prompt: listed as /servername:promptname (MCP); /mcp__servername__promptname also runs it.
MCP tool output: warning above 10,000 tokens; default maximum 25,000 (MAX_MCP_OUTPUT_TOKENS); over the limit it is saved to a file, not truncated. Text over 50,000 characters is saved to a file regardless (raise per tool with anthropic/maxResultSizeChars).
Use community servers first (Jira, GitHub, Notion); build custom only for team-specific workflows or proprietary systems. "Build our own Jira server to control the descriptions" is still wrong.
Sparse MCP descriptions lose to built-in search (agent prefers Grep over an under-described MCP search tool) — enhance the description (capability, output, when it beats Grep), don't rename to mimic a built-in. Tool absent = scope problem; present but unchosen = description problem.
File paths by naming pattern; capped at 100 results
Read
Full file load
Write
Full file output (overwrites; no append)
Edit
Targeted change via unique old_string match
Bash
Shell commands: tests, builds, git — not the search tool
WebFetch
External URL content (domain: permission rules)
Agent (was Task)
Spawns subagents — renamed in Claude Code v2.1.63
Edit non-unique match (safety, not a bug): the exam guide names Read + Write as the fallback when Edit cannot find unique anchor text; current docs first widen old_string or set replace_all: true. Read + Write is not the default for routine edits. Retrying the same Edit fails identically.
Edit zero matches is a different failure: old_string must match exactly (whitespace included) — fix the text, widening won't help.
Current product: on macOS, Linux and WSL Grep and Glob are left out of the default tool set (search runs as find/grep through Bash); naming either in --tools/--allowedTools restores both. Exam answer unchanged: Grep for contents, Glob for paths.
Incremental exploration: Grep → Read → Grep again (wrappers/barrels) → Read only what's justified. Read-everything fails twice: context exhaustion and attention dilution.
Wrapper modules ("audit found 3 of 40 call sites"): enumerate every exported name first (export { x as y }, export * from, import * as ns), then Grep for each.
Deprecation-tracing pattern: Grep (find callers) → Glob (find sibling test files) → Grep again (catch wrapper/indirect consumers). Not Glob first.
Agent/Task: the guide requires allowedTools to include "Task"; current docs say Agent calls need no approval. Answer the guide's way.
SDK tools option scopes built-in availability: tools:["Read","Grep"] keeps only those; tools:[] removes all built-ins (MCP tools unaffected).
--allowedTools skips prompts; --tools restricts availability. --disallowedTools: bare name removes the tool entirely ("*" = all); scoped rule (Bash(rm *)) leaves it available, denies only matches.
Bash prefix matching: Bash(git diff *) — the trailing space matters (without it, Bash(git diff*) also matches git diff-index).
WebFetch(domain:*.example.com) matches subdomains, not the apex domain.