Skip to content
CCAR-F Prep

Domain 2 · 18% of exam

Tool Design & MCP Integration cheat sheet

The idea this domain hangs on

Tool use fails in three places, and each task owns one.

FailureWhat goes wrongUsual causesFix
SelectionThe model picks the wrong toolVague 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
ExecutionThe tool runs and failsNo structured error metadata, so the agent cannot tell retry from rephrase from escalate (2.2)errorCategory, isRetryable, a readable message
FitThe right tool for the wrong jobA 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).
  • MCP tool fields: name, description, inputSchema + optional title, icons, outputSchema, annotations. Discovery/exec: tools/list / tools/call.
  • 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.
Overlap problemMove
Different jobs, similar namesRename + re-describe (analyze_content → extract_web_results)
One generic tool, different input/output contractsSplit (the guide's fix)
Same contract, different verbOne 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

CategoryisRetryableRecovery
Transient (timeout, rate limit)trueRetry after delay
Validation (bad input)Guide assigns no value (lesson: true)Fix input, call again — never resend unchanged
Business (policy violation)falseExplain to customer, alternative path / escalate
Permission (access denied)falseEscalate / 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.typeBehaviourDefault when
autoModel decides tool vs texttools provided
anyMust call some tool (several schemas, document type unknown)—
toolMust call the named tool: {"type":"tool","name":"…"}—
noneMay not call any toolno tools provided
  • Force the first call, then release to auto; forcing every turn loops until the turn cap.
  • tool_choice cannot: 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/tool error 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 inside tool_choice, not top-level. With auto: at most one call. With any/tool: exactly one call.
  • Changing tool_choice between turns invalidates cached message blocks (tool defs/system prompt stay cached).

2.4 — MCP server integration

claude mcp add --transport http <name> <url>            # remote HTTP
claude mcp add [opts] <name> -- <command> [args...]      # local stdio (-- required)
claude mcp add-json <name> '<json>'                       # from JSON
ScopeStorageShared?Notes
local (default)~/.claude.json, nested under project pathNoThis project only
project.mcp.json in project rootYes (VCS)Team-shared; approval prompt in interactive sessions (-p/SDK load without asking)
user~/.claude.jsonNoAll 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.
ToolsResources
WhatAction (create_issue)Content (issue catalogue, docs tree, DB schema)
Driven byModel-controlledApplication-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).
  • Tool naming: mcp__<server>__<tool>; plugin servers mcp__plugin_<plugin>_<server>__<tool>. Permission rules: mcp__server / mcp__server__* / mcp__server__tool.
  • 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.

2.5 — Built-in tools

ToolSearches / does
GrepFile contents (patterns, calls, imports); ripgrep regex; respects .gitignore
GlobFile paths by naming pattern; capped at 100 results
ReadFull file load
WriteFull file output (overwrites; no append)
EditTargeted change via unique old_string match
BashShell commands: tests, builds, git — not the search tool
WebFetchExternal 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.