Tool Design & MCP Integration
Writing tool descriptions so Claude picks the right tool, returning structured MCP errors, distributing tools by role and configuring tool_choice, integrating MCP servers into Claude Code (.mcp.json, scopes, environment variables), and choosing the right built-in tool.
- 2.1 Design effective tool interfaces with clear descriptions and boundaries
- 2.2 Implement structured error responses for MCP tools
- 2.3 Distribute tools appropriately across agents and configure tool choice
- 2.4 Integrate MCP servers into Claude Code and agent workflows
- 2.5 Select and apply built-in tools (Read, Write, Edit, Bash, Grep, Glob) effectively
Domain overview
Domain 2 makes up 18% of the CCAR-F exam, about 11 of 60 questions. Questions appear in Scenario 1 – Customer Support (MCP tools get_customer, lookup_order, process_refund, escalate_to_human), Scenario 3 – Multi-Agent Research (distributing tools across subagents, error propagation), and Scenario 4 – Developer Productivity (built-in tools, MCP servers in Claude Code).
Typical questions: the agent picks the wrong tool → what should you fix first; a tool error leaves the agent stuck → how should the error response be designed; which scope a tool belongs in; Grep or Glob. Many questions have options that are "correct but not enough": add few-shot examples, change the model, or merge tools. You need to recognize the highest-leverage, lowest-cost change that still addresses the root cause.
| Task | Content | Keywords |
|---|---|---|
| 2.1 | Tool interface | description, boundaries, renaming/splitting tools |
| 2.2 | Structured errors | isError, error category, retryable |
| 2.3 | Tool distribution | 4–5 tools per agent, tool_choice |
| 2.4 | MCP integration | .mcp.json, ~/.claude.json, ${VAR}, resources |
| 2.5 | Built-in tools | Grep, Glob, Read, Write, Edit, Bash |
2.1 Designing tool interfaces: descriptions and boundaries
The description is the primary tool-selection mechanism
Claude doesn't see a tool's code, only its name, description, and input_schema. The description is therefore the primary mechanism the model uses to select tools. A minimal description ("Retrieves customer information") makes tool selection unreliable, especially when several tools look alike.
A good description (the Tool use with the Messages API course recommends 3–4 sentences or more) should state:
- what the tool does and when to use it / not use it;
- the meaning and input format of each parameter, with example queries;
- edge cases and boundaries with similar tools, e.g. "does not return permit status; use
get_permit_status"; - what the tool does not return.
The Writing tools for agents article suggests writing as if you were onboarding a new employee. Parameter names should be unambiguous (user_id rather than user). In one experiment, Claude kept appending "2025" to search queries until the description was fixed.
Key point
Fix the part that causes the failure: if the agent picks the wrong tool, fix the description (emphasize when to use it, not just what it does). If the agent passes parameters in the wrong format, fix the schema and add input_examples. If parameters must always match the schema, use strict: true.
Overlapping descriptions cause misrouting
Two tools, analyze_content and analyze_document, with near-identical descriptions will cause Claude to route between them inconsistently. The fixes the Exam Guide lists:
- Rename and rewrite the descriptions to remove the overlap, e.g. rename
analyze_contenttoextract_web_resultswith a web-specific description. - Split a generic tool into purpose-specific tools with clear input/output contracts. For example, split
analyze_documentintoextract_data_points,summarize_content, andverify_claim_against_source. - Review the system prompt for keywords that unintentionally pull Claude toward one tool, e.g. the sentence "always analyze content thoroughly" makes Claude favor
analyze_content.
Conversely, consolidating several thin tools into fewer tools can also work. The Tool use course consolidated 6 tools into 3 (one lookup_project_status tool with an enum fields parameter), raising the eval score from 14/30 (47%) to 26/30 (87%) on claude-sonnet-5. The general principle is each tool has a clear purpose and no overlap, not "the more the better" or "the fewer the better".
Exam trap
When the agent confuses two tools with sparse descriptions, the first step is to expand the descriptions. Few-shot examples, a routing layer, or merging tools all take more effort and don't address the root cause. The Exam Guide treats this as a high-leverage, low-cost change.
(Sources: CCAR-F Exam Guide, Task 2.1; Anthropic Academy: Tool use with the Messages API — Creating tools that Claude picks; Anthropic Engineering: Writing effective tools for AI agents; Claude Docs: Troubleshooting tool use)
2.2 Structured error responses for MCP tools
The isError flag and error categories
An MCP tool reports an error with the isError flag in its result. This signals to the agent that the call failed rather than returning valid data. A generic error such as "Operation failed" leaves the agent unable to tell whether to retry, change approach, or inform the user.
| Error type | Example | Retry? | What the agent should do |
|---|---|---|---|
| Transient | Timeout, service unavailable | Yes | Retry, possibly with backoff |
| Validation | Malformed order number | No (fix the input) | Fix the parameter or ask the customer again |
| Business | Refund exceeds policy | No | Explain to the customer, escalate |
| Permission | No access rights | No | Report the error, use another channel |
Error responses should include structured metadata: errorCategory, isRetryable (boolean), and a human-readable description. Business errors also need a customer-friendly explanation the agent can relay to the customer.
{
"isError": true,
"content": [{"type": "text", "text": "{\"errorCategory\": \"business\", \"isRetryable\": false, \"message\": \"Order ORD-881 is more than 30 days old, outside the automatic refund window.\", \"customerExplanation\": \"This order is past the 30-day return window.\"}"}]
}
Without this metadata, the agent tends to retry pointlessly on non-retryable errors, or give up on transient ones.
Access failures vs valid empty results
Two cases must be distinguished: failing to access the data source (timeout, permission error) and a successful query that returns no matches. If a tool returns an empty list when it actually timed out, the agent will wrongly conclude that "there is no data". Errors must be flagged as errors.
Error propagation in multi-agent systems
A subagent should recover locally from transient errors (retry) and propagate to the coordinator only the errors it cannot resolve itself. When it does, it should include the failure type, the query attempted, partial results, and alternative approaches. Returning "search unavailable" or a disguised empty result leaves the coordinator unable to make a decision.
Exam trap
The options "the subagent throws an exception to stop the entire workflow" and "the subagent returns an empty list marked as success" are both wrong. The first wastes partial results; the second hides the error. The correct answer is to return structured error context so the coordinator can decide for itself.
Scenario example
In Scenario 1, lookup_order occasionally times out and returns "Error". Sometimes the agent retries an "order number does not exist" error 5 times; other times it escalates immediately on a timeout. The fix is to have the MCP server return isError with errorCategory and isRetryable: the agent retries timeouts, asks the customer again when the order number is wrong, and never retries business errors.
(Sources: CCAR-F Exam Guide, Task 2.2; Claude Cookbooks: Claude Agent SDK — The SRE Incident Response Agent (MCP isError); Anthropic Engineering: Writing effective tools for AI agents)
2.3 Distributing tools across agents and tool_choice
Fewer tools, matched to the role
Giving an agent too many tools (18 instead of 4–5) reduces tool-selection reliability. An agent with tools outside its specialization tends to misuse them: a synthesis subagent with a web search tool will go searching on its own instead of synthesizing. The principle is to scope tools to the role:
- web search subagent: search and page-reading tools;
- synthesis subagent: no general-purpose search tool.
You can grant scoped cross-role tools for high-frequency needs. For example, the synthesis subagent gets a narrow verify_fact tool for simple checks, while complex verification still goes through the coordinator. Another fix is to replace a generic tool with a constrained one: replace fetch_url (fetches any URL) with load_document, which accepts only valid document URLs.
tool_choice
| Value | Behavior | When to use |
|---|---|---|
{"type": "auto"} |
Default; Claude decides whether to call a tool or answer in text | Normal conversation |
{"type": "any"} |
Must call at least one tool; Claude chooses which | You need a guaranteed tool call instead of text |
{"type": "tool", "name": "extract_metadata"} |
Forces that specific tool | A particular step must run first |
{"type": "none"} |
Tools may not be used | Turns that need only text |
The Exam Guide gives two use cases. First, use "any" for data extraction with multiple document schemas: Claude must call a tool rather than return free-form text. Second, force extract_metadata to run first, then handle the enrichment steps in follow-up turns. You can add "disable_parallel_tool_use": true to any tool_choice to limit responses to at most one tool. Forcing a specific tool does not by itself prevent other parallel calls in the same turn.
Key point
The exam tests the tool_choice concepts as described in the Exam Guide. In practice, per the claude-api skill documentation (Nov 2026): forced tool_choice any/tool returns a 400 error on Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5.1, and Claude Mythos 5.1. The alternative is to use auto with instructions in the prompt and strict: true, or structured outputs.
Scenario example
In Scenario 3, the synthesis subagent has 14 tools, including web search, and often goes off to find new sources instead of synthesizing. Meanwhile, 85% of its verification needs are just looking up a single number. The right approach is to remove the general-purpose search tool, grant a scoped verify_fact tool, and let the coordinator handle complex verification.
(Sources: CCAR-F Exam Guide, Task 2.3; Anthropic Courses (GitHub): Tool use — Tool choice; Claude Cookbooks: Tool use — Tool choice; Anthropic Skills: claude-api; Anthropic Academy: Introduction to subagents)
2.4 Integrating MCP servers into Claude Code and agent workflows
What MCP is
MCP (Model Context Protocol) moves tool definition and execution to a server, so your application doesn't have to write the schemas and functions for every service itself. MCP complements tool use rather than replacing it: in the end, Claude still receives tool definitions and calls tools as usual. An MCP server provides three primitives:
| Primitive | Controlled by | Examples |
|---|---|---|
| Tools | Model: Claude decides to call them | create_issue, query_db |
| Resources | Application: loads data into context | Issue catalog, documentation tree, DB schema |
| Prompts | User: usually surfaced as slash commands | Predefined prompt templates |
Key point
Tools are model-controlled; resources are application-controlled. When the agent spends many calls just to find out "what's there" (issue catalog, documentation tree, database schema), expose that catalog as an MCP resource so the agent can see it up front without exploratory tool calls.
Configuration scopes in Claude Code
| Scope | Stored in | Used for |
|---|---|---|
| Project | .mcp.json at the repo root, committed to git |
Tools shared by the whole team |
| User | ~/.claude.json |
Personal servers used across all projects |
| Local | ~/.claude.json (per project) |
Experimental servers, just for you, in the current project |
Add servers with claude mcp add; inspect and disable servers during a session with /mcp. In .mcp.json, use ${VAR} environment variables to avoid committing secrets:
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.example.com/mcp/github",
"headers": { "Authorization": "Bearer ${GITHUB_TOKEN}" }
}
}
}
Tools from all configured servers are discovered at connection time and available simultaneously. MCP tool names take the form mcp__<server>__<tool>. In the Agent SDK, strict_mcp_config=True restricts the session to explicitly declared servers.
Context cost and tool precedence
Each server adds its tool list to the context even if those tools are never used. Claude Code enables tool search by default, keeping full definitions out of the context until they are needed. If an equivalent CLI exists (e.g. gh), the CLI is usually more context-efficient.
When an MCP tool is more capable than a built-in tool, e.g. semantic code search versus Grep, but the agent still chooses Grep, rewrite the MCP tool's description to make its capabilities and when to use it clear.
Community or custom server: for standard integrations such as Jira, Confluence, Sentry, or Slack, prefer existing community servers (e.g. mcp-atlassian, sentry-mcp). Write your own server only for team-specific workflows.
Exam trap
Putting a team-shared server in ~/.claude.json is wrong, because teammates won't get that server. Writing a token directly into .mcp.json is also wrong, because the secret will be exposed in git. Correct answer: project-scoped .mcp.json, with secrets supplied through ${ENV_VAR}. Hosting or deploying MCP servers is out of scope for the exam.
(Sources: CCAR-F Exam Guide, Task 2.4; Anthropic Academy: Claude Code 101 — MCP; Anthropic Academy: Introduction to Model Context Protocol; Anthropic Academy: The AI-native SDLC playbook; Claude Cookbooks: Claude Agent SDK)
2.5 Selecting and using built-in tools effectively
| Tool | What it does | Use when |
|---|---|---|
| Grep | Searches file contents | Finding function names, error messages, import statements |
| Glob | Matches file path patterns | Finding all **/*.test.tsx files, config files by name |
| Read | Reads an entire file | Following logic once you've located the file |
| Write | Overwrites an entire file | Creating a new file, or rewriting when Edit can't be used |
| Edit | Targeted modification via unique text matching | Small changes in a large file |
| Bash | Runs shell commands | Running tests, git diff, builds |
Edit requires the text to replace to match exactly (including whitespace) and be unique in the file. If the anchor text appears multiple times and Edit fails, the fallback is to Read the whole file, then Write the modified version.
Exploring an unfamiliar codebase incrementally
Don't Read every file upfront: the context fills quickly, mostly with irrelevant content. The right approach:
- Grep for entry points, e.g. function names or routes.
- Read the files you find and follow their imports.
- Repeat, reading only what you need at each step.
When tracing how a function is used across wrapper modules (modules that re-export), first identify all the relevant exported names, then Grep for each name across the codebase. If you Grep only for the original name, you'll miss call sites that go through an alias.
Exam tip
"Find files by name or extension" → Glob. "Find files containing string X" → Grep. "Change one line" → Edit. "Edit reports the match isn't unique" → Read + Write. "Understand a feature's processing flow" → Grep for the entry point, then Read along the imports.
(Sources: CCAR-F Exam Guide, Task 2.5; Anthropic Academy: Building with the Claude API (Claude Code's general-purpose tools); Anthropic Academy: Introduction to subagents; Anthropic Academy: Tool use with the Messages API (text editor tool))
Quick summary
- The description is the primary mechanism Claude uses to select tools. It should state inputs, examples, edge cases, when to use the tool, and its boundaries with similar tools.
- Agent picks the wrong tool because of sparse descriptions → the first step is to expand the descriptions, before few-shot examples or routing.
- Overlapping descriptions → rename (
extract_web_results) or split a generic tool into purpose-specific tools. Review the system prompt for keywords that skew selection. - Wrong tool → fix the description. Wrong parameter format → fix the schema and
input_examples. Parameters must always be valid →strict: true. - MCP reports errors with
isError. Four error types: transient, validation, business, permission. IncludeerrorCategory,isRetryable, and a human-readable description. - Distinguish access failures from valid empty results. Never return an empty list when the call actually timed out.
- Subagents retry transient errors themselves. Propagate to the coordinator only errors they can't resolve, along with the query attempted and partial results.
- About 4–5 tools per agent, matched to its role. High-frequency cross-role needs → a scoped tool (
verify_fact). tool_choice:auto(default),any(must call a tool),{"type":"tool","name":...}(force one tool),none..mcp.json(project, committed) for shared tools;~/.claude.jsonfor personal servers. Secrets come from${ENV_VAR}.- Tools from all MCP servers are discovered at connection time and available simultaneously. Resources expose content catalogs and reduce exploratory calls.
- Standard integrations (Jira…) → community servers. Team-specific workflows → write your own server.
- Grep searches content, Glob matches path patterns. Edit needs a unique anchor string; if it fails, use Read + Write.
- Explore a codebase incrementally: Grep for entry points → Read along imports. Wrapper modules: list every exported name, then Grep for each one.