Domain 2 · Tool Design & MCP Integration
This domain is about the tools Claude calls: how to describe them, how they report errors, how many each agent should get, how MCP servers are configured, and which built-in tool fits which job.
Key terms: Tool: an action Claude can request. MCP (Model Context Protocol): a standard way for programs to offer tools and data to Claude. MCP server: a program that provides those tools. Built-in tools: the ready-made tools in Claude Code (Read, Write, Edit, Bash, Grep, Glob).
2.1 Design effective tool interfaces with clear descriptions and boundaries
What it is: Claude chooses a tool by reading its name and description, so those words are the only guide it has. If two tools sound alike, or a description is one vague line, Claude will pick the wrong one. A good description says what the tool does, when to use it, when not to, and what it returns.
The exam tests: how descriptions drive tool selection, and how to fix a tool that is called wrongly. Video: Ep 06.
Troubleshoot misrouting in this order
Full notes
Rule: Tool descriptions are the main way the model chooses a tool. Minimal descriptions make the choice between similar tools unreliable.
Rule: A strong description says what the tool does, when to call it, what it must not be used for, and what it returns. Add input formats, example queries and edge cases.
Rule: Overlapping descriptions cause misrouting, for example analyze_content next to analyze_document. Rename the tools and rewrite the descriptions to remove the overlap, or split a generic tool into purpose-specific ones with clear input and output contracts.
Rule: A vague role line in the system prompt can bias tool choice. Keep the system prompt and the tool descriptions aligned.
Deep dive
- Ep 06 at 01:51: tool selection depends on the description.
- Ep 06 at 09:43: overlapping tools and misrouting.
- Ep 06 at 13:30: fix the descriptions first. The video calls this exam critical.
- Ep 06 at 14:47: naming and splitting tools.
- Ep 06 at 21:05: how a role line in the system prompt biases tool choice.
2.2 Implement structured error responses for MCP tools
What it is: When a tool fails, it should tell Claude what kind of failure it was and whether trying again can help. MCP uses an isError flag to mark a failed call, and you add details such as the error category and whether it is retryable. A bare "Operation failed" leaves Claude guessing.
The exam tests: how a tool reports failure, and how structured errors let the agent choose a recovery. Video: Ep 07.
{ "tool_result": {
"isError": true,
"content": [...]
}
}| Failure type | Example | Retryable? |
|---|---|---|
| Transient | Timeout, network glitch | Sometimes |
| Validation | Wrong input | Sometimes |
| Business | Outside refund policy | Never |
| Permission | Not authorized | Never |
Full notes
Rule: The MCP isError flag tells the agent a tool call failed.
Rule: Return structured metadata: an errorCategory (transient, validation or permission), an isRetryable boolean, and a readable description. For a business-rule violation, add retriable: false and a customer-friendly explanation.
Rule: Subagents recover from transient failures themselves. They pass up only what they cannot resolve, together with what was attempted and any partial results.
Rule: An access failure needs a retry decision. A valid empty result means the query worked and found nothing.
Deep dive
- Ep 07 at 07:05: transient errors.
- Ep 07 at 08:20: validation errors.
- Ep 07 at 09:45: business logic errors.
- Ep 07 at 11:00: permission errors.
- Ep 07 at 13:30: why generic errors are a dead end.
2.3 Distribute tools appropriately across agents and configure tool choice
What it is: Every tool you give an agent is one more option Claude has to choose from, so too many tools, or tools outside the agent's job, lead to wrong picks. tool_choice is a setting that controls how much freedom Claude has: auto lets it answer in plain text or use a tool, any forces it to use some tool, and a forced tool makes it use one specific tool.
The exam tests: how many tools an agent should have, which ones, and what tool_choice guarantees. Video: Ep 07.
tool_choice: how much freedom Claude has
| Setting | What happens |
|---|---|
"auto" | The model decides. It may reply in plain text or call a tool |
"any" | The model must call a tool, and chooses which one. No text-only replies. This guarantees structured output when the document type is unknown |
| Forced tool | The model must call the named tool, for example {"type": "tool", "name": "extract_metadata"} first |
Full notes
Rule: Too many tools degrade selection. The guide's example is 18 tools instead of 4 or 5.
Rule: An agent given tools outside its specialty misuses them, for example a synthesis agent attempting web searches. Give each agent only what its role needs.
Rule: A narrow cross-role tool is fine for a frequent need, such as a verify_fact tool for the synthesis agent. Complex cases still go through the coordinator.
Rule: Replace a broad tool with a constrained one, such as load_document, which validates document URLs, instead of a general fetch_url.
Rule: With tool_choice set to "auto", Claude may answer in text. With "any", it must call a tool but chooses which, which guarantees structured output. With a forced tool, a named tool runs first (for example extract_metadata before enrichment), and later steps follow in further turns.
Deep dive
- Ep 07 at 23:32: the tool overload problem.
- Ep 07 at 27:18: scoped tool access.
- Ep 07 at 31:01:
tool_choice. - Ep 07 at 35:29: forcing a tool to run.
2.4 Integrate MCP servers into Claude Code and agent workflows
What it is: MCP servers are separate programs that offer tools and data to Claude through a standard protocol. A settings file tells Claude Code which servers to connect to: a project file shared with the team, or a personal file only you use. Secrets such as tokens are kept out of the file by pointing to environment variables.
Why use MCP?
- New tools can be discovered at runtime.
- One server can be reused across agents and apps.
- Tool descriptions and metadata help Claude understand what each tool does.
- It separates concerns: the host runs the agent, the client speaks the protocol, and the server provides the tools.
| Server type | How it runs |
|---|---|
| Local (stdio) | Runs on your machine and is used like a function |
| Remote | Reached over HTTP and SSE |
The exam tests: where MCP servers are configured, how secrets are kept out of the repo, and what MCP resources are for. Video: Ep 08.
A host reaches a server through an MCP client
Agent communication with MCP runs in six steps:
.mcp.json | ~/.claude.json | |
|---|---|---|
| Scope | Project | Personal / user |
| Location | Repo root | Home directory |
| Sharing | Committed | Never shared |
| Use for | Team-wide tools | Personal and experimental servers |
Full notes
Rule: Put shared servers in the project's .mcp.json. Put personal or experimental ones in ~/.claude.json.
Rule: Use environment variable expansion, such as ${GITHUB_TOKEN}, so credentials are never committed.
Rule: Tools from every configured MCP server are discovered when Claude connects, and all are available at the same time.
Rule: MCP resources expose content catalogs (issue summaries, documentation hierarchies, database schemas), so the agent makes fewer exploratory tool calls.
Rule: Write detailed MCP tool descriptions. Otherwise the agent may prefer a built-in tool such as Grep over a more capable MCP tool.
Rule: Prefer an existing community MCP server for a standard integration like Jira. Keep custom servers for team-specific workflows.
Deep dive
- Ep 08 at 00:11:
.mcp.json. - Ep 08 at 06:54: resources and prompts.
- Ep 08 at 47:46: community servers.
- Ep 08 at 59:52: user-level configuration.
- Ep 08 at 1:07:44: keeping secrets out of shared files.
- Ep 08 at 1:08:32: environment variable expansion.
2.5 Select and apply built-in tools (Read, Write, Edit, Bash, Grep, Glob)
What it is: Claude Code and agents built with the Agent SDK come with a few ready-made tools. Read opens a file, Write creates or replaces one, Edit changes a specific piece of text, Bash runs a command, Grep searches inside files, and Glob finds files by name. Choosing the right one, and exploring step by step, keeps the work fast and accurate.
The exam tests: which built-in tool fits which job, and how to explore a codebase step by step. Video: Ep 09.
Discover, understand, create, fix: one tool per step
Incremental exploration loads only what you need: Grep, then Read the target, then trace the dependency, and repeat.
| Tool | Job |
|---|---|
| Read | Loads a full file |
| Write | Creates or overwrites a file |
| Edit | Targeted change using unique text matching |
| Bash | Runs shell commands |
| Grep | Searches file contents |
| Glob | Finds files by path pattern |
Full notes
Rule: Use Grep to search inside files (function names, error messages, imports). Use Glob to find files by name pattern, such as **/*.test.tsx.
Rule: Edit needs a unique piece of text to match. When it fails because the text is not unique, fall back to Read followed by Write.
Rule: Build understanding step by step. Grep for entry points, then Read to follow imports and trace the flow.
Rule: To trace usage through wrapper modules, list the exported names first, then search for each name across the codebase.
Deep dive
- Ep 09 at 03:14: Glob.
- Ep 09 at 03:29: Grep.
- Ep 09 at 17:12: the fallback when Edit fails.
- Ep 09 at 24:25: incremental exploration.