Tools and MCP
Design tools so Claude calls them correctly and gets compact results, build and integrate MCP servers (primitives, transport, auth, scope), and choose the right mechanism among built-in tools, custom tools, Skills, and MCP.
- Tool Design and Response Shaping: schema, description, response shaping, error handling, execution side, approval pattern
- MCP Server Development and Integration: resources, tools, prompts; stdio vs HTTP transport; authentication
- Capability Mechanism Selection: built-in tools, custom tools, Skills, MCP servers
Domain overview
Domain 8, "Tools and MCP", makes up 10% of the exam (about 6 of the 60 scored items) and covers three skills: Tool Design and Response Shaping (schema, description, minimal results, error handling, execution side, approval, assembling the tool set), MCP Server Development and Integration (resources/tools/prompts, stdio or HTTP transport, authentication), and Capability Mechanism Selection (built-in tool, custom tool, Skill, or MCP server: where the capability lives, who maintains it, and how Claude discovers and invokes it).
Items usually present a symptom (Claude picks the wrong tool, passes the wrong format, context bloats, the server doesn't scale) and ask you to fix it at the right layer.
(Source: CCDV-F Exam Guide, Domain 8)
Tool design & response shaping
The three parts of a tool definition
A custom tool has a name, a description, and an input_schema (JSON Schema, with required). You can add input_examples: each example must be valid against input_schema, or the API returns 400.
{
"name": "search_contacts",
"description": "Searches CRM contacts by name or email. Use when the user mentions a specific person. Do not use to list the entire contact directory. Returns at most `limit` results, each with name, company, and contact_id; does not return transaction history.",
"input_schema": {
"type": "object",
"properties": {
"query": {"type": "string", "description": "Name or email, e.g. 'jane@acme.com'"},
"limit": {"type": "integer", "description": "Maximum number of results, default 5"}
},
"required": ["query"]
}
}
The description is what Claude relies on to choose a tool. The "Tool use with the Messages API" course recommends at least 3–4 sentences that state clearly: what the tool does, when to use it and when not to, what each parameter means (with its format), and what the tool does not return. Describe it as you would to a new hire: specialized query formats, terminology, relationships between resources. Give parameters unambiguous names (user_id instead of user).
Fix the right layer
| Symptom | Layer to fix | Fix |
|---|---|---|
| Claude picks the wrong tool, or doesn't call a tool | Description (and the tool set) | State when to use / not use it; merge overlapping tools |
Passes the wrong type or format (0142 instead of MEG-2026-0142) |
Schema and examples | State the format in the parameter description, add input_examples, consider strict |
| Input doesn't match the schema, causing parse errors | Sampling constraints | strict: true + additionalProperties: false |
| Results too long, wasting context | Response shaping | Filter fields, paginate, response_format |
The Meridian case in the course: six overlapping "thin" tools were merged into three (one lookup_project_status tool with a fields parameter). The score rose from 14/30 to 26/30 on the same claude-sonnet-5 model. The "Writing tools for agents" article also recommends building few tools that target high-value workflows: search_contacts instead of list_contacts, and namespacing (asana_search, jira_search) when there are several services.
Exam trap
Claude calls the right tool but passes the ID in the wrong format: fix the schema/examples, don't rewrite the whole system prompt or switch models. Conversely, when Claude confuses two near-identical tools, adding input_examples won't help; you need to fix the descriptions or merge the tools.
Strict tool use
Set "strict": true at the tool level together with "additionalProperties": false to enable grammar-constrained sampling: the input always matches the schema. Generate the schema from the validator (Pydantic model_json_schema(), Zod) so the two never drift apart. In the course demo, inputs rejected by the validator dropped from 79/100 to 0. Limits to remember:
minimum,maximum,minLength,maxLengthin a strict schema return 400; check bounds in the validator and state them in the description.- Per request: up to 20 strict tools, 24 optional parameters, 16 parameters using
anyOfor type arrays. - Input can still deviate after a refusal, on truncation at
max_tokens, or whenenumstrings change case. - Don't put PHI in schemas. Programmatic tool calling cannot use strict tools.
tool_choicecoversauto(default),any,tool, and thedisable_parallel_tool_useflag. Forcing a tool call (any/tool) returns 400 on Claude Fable 5.2, Claude Mythos 5.2, Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5.1, and Claude Mythos 5.1. On these models, keepauto.
Key point
strict guarantees the input's shape, not its truth. If the user hasn't supplied a value, Claude cannot invent a valid one; nullable fields fall back to null. The description should still tell Claude to ask the user when required information is missing.
Response shaping and error handling
Tool results go straight into the context, so they must be minimal and actionable:
- Return high-signal fields (name, status) instead of meaningless technical IDs. When a later step needs the ID, add a
response_formatenum parameter withconcise/detailed. The Slack example in the article: 206 tokens in detailed form versus 72 tokens in concise form. - Paginate, filter, and truncate with sensible defaults. Claude Code caps tool responses at 25,000 tokens by default.
- Errors must help Claude correct itself. Return a
tool_resultwith"is_error": trueand a specific message ("project_id must be in the form MEG-YYYY-NNNN"), instead of an opaque error code or a stack trace.
The tool use loop and parallel tool use
When stop_reason is "tool_use", the application runs the tool and sends back a tool_result with the matching tool_use_id. Claude can return multiple tool_use blocks in one turn:
- Run all the calls; run them in parallel if they are independent and read-only, sequentially if they write or depend on order.
- Send one
tool_resultpertool_use, all in the same user message, and thetool_resultblocks must come before any text block. Splitting them across several messages makes Claude make fewer parallel calls later. The wrong order causes the error "tool_use ids were found without tool_result blocks immediately after". - For at most one call per turn:
disable_parallel_tool_use. - When streaming, tool input arrives incrementally through
input_json_delta(partial_json) betweencontent_block_startandcontent_block_stop.
Exam trap
Three parallel tools, one fails: do not skip the failed tool or send three separate messages. Send all three tool_result blocks in one user message, with the failed block marked is_error: true and including guidance on how to fix it.
Execution side: client tools or server tools
| Type | Who defines the schema | Who executes | Examples, characteristics |
|---|---|---|---|
| Custom (client) tool | You | Your code | Internal business tools; you send the tool_result |
| Client tool with an Anthropic-defined schema | Anthropic | Your code | memory, bash |
| Server tool | Anthropic | Anthropic | web_search_20260209, web fetch, code_execution_20260120; server_tool_use blocks, no handler or tool_result needed; on pause_turn, send the request again to continue |
Choose server tools for general capabilities (web search, code execution; web search can be restricted with allowed_domains). Choose client tools when you need to touch your own systems, or need approval before execution: your code runs the tool, so the loop can pause for human approval on tools with side effects.
Assembling the tool set for performance
- Tool definitions take up context on every request. Put
cache_controlon the last tool in the list to cache the whole list (cache reads 0.1× the input price; writes 1.25×; 1-hour TTL writes 2×). Editing any tool invalidates the cache. - Large tool sets: use tool search with
defer_loading: true; at least one tool must not be deferred. - Programmatic tool calling: mark tools with
allowed_callers: ["code_execution_20260120"]so Claude writes code that calls many tools in bulk inside the container. The course example went from 42 requests, about 1.12 million input tokens, and $2.29 down to 3 requests, 28,486 tokens, and $0.0667. It can't be combined with strict tools ordisable_parallel_tool_use, and Claude Haiku 4.5 does not support it. - Evaluate the tool set with real tasks and a held-out set, not just by feel.
(Sources: Anthropic Academy: Tool use with the Messages API; Anthropic Engineering: Writing effective tools for AI agents; Claude Cookbooks: Tool use)
MCP server development & integration
What MCP solves
Model Context Protocol (MCP) moves tool definition and execution into an MCP server. Your application (the MCP client) asks the server what it offers (ListTools, ListPrompts, reading resources) and invokes it (CallTool). The main benefit is maintenance: Asana, Linear, and Slack publish their own servers and update them when their APIs change; you don't have to maintain a wrapper layer.
The three primitives
| Primitive | Who controls it | Use when | Python SDK |
|---|---|---|---|
| Tools | Model (Claude decides to call) | Actions or queries Claude initiates | @mcp.tool(name=..., description=...) |
| Resources | Application (the app decides what to include) | Read-only data to put into context, e.g., document contents | @mcp.resource("docs://documents/{doc_id}", mime_type=...) |
| Prompts | User (explicitly chosen, e.g., a slash command) | Standardized prompt templates for recurring workflows | @mcp.prompt(...) |
Resources come in two forms: a fixed URI (docs://documents) and templated (docs://documents/{doc_id}). With the Python SDK (v1), you create the server with FastMCP("DocumentMCP"), describe tool parameters with Pydantic Field, and test with the MCP Inspector (mcp dev mcp_server.py).
from mcp.server.fastmcp import FastMCP
from pydantic import Field
mcp = FastMCP("DocumentMCP")
@mcp.tool(name="read_doc_contents", description="Reads the contents of a document by id.")
def read_doc(doc_id: str = Field(description="Id of the document to read")):
...
@mcp.resource("docs://documents/{doc_id}", mime_type="text/plain")
def fetch_doc(doc_id: str) -> str:
...
Exam trap
"Let Claude decide for itself when to fetch data" is a tool; "the application proactively puts a user-selected document into context" is a resource; "the user types a command to trigger a standard workflow" is a prompt. Items often swap these roles.
Transport: stdio or Streamable HTTP
| Criterion | stdio | Streamable HTTP |
|---|---|---|
| Location | The client launches the server as a subprocess on the same machine | Remote server, over the network |
| Good fit | Local tools, development, access to files/CLIs on the user's machine | Vendor-hosted services shared by many clients |
| Server-to-client messages | Naturally bidirectional over stdin/stdout | Uses SSE for server→client messages |
| Scale | One process per client | Scales horizontally behind a load balancer (state needs thought) |
Streamable HTTP has two flags, stateless_http and json_response (both false by default). stateless_http=True allows horizontal scaling behind a load balancer, but you lose session IDs, server→client requests, sampling, progress, and subscriptions. json_response=True disables streaming for POST responses and returns only the final result. Test with the same transport you will use in production.
Key point
The MCP spec 2026-07-28 deprecates sampling, logging, and roots, and drops the initialize handshake and session IDs. The courses still describe the old approach because MCP Python SDK v1 still works that way. Roots are only hints: the SDK does not block access by itself, so the server must check paths itself (for example, an is_path_allowed() function).
Authentication and integration into applications
- Messages API (MCP connector, beta): declare
mcp_servers=[{"type": "url", "url": ..., "name": ..., "authorization_token": ...}], add a{"type": "mcp_toolset", "mcp_server_name": ...}tool, and the beta headermcp-client-2025-11-20. Claude introspects the tool list itself; you don't write schemas. To keep a server read-only:default_config: {"enabled": false}, then enable individual tools inconfigs. - Managed Agents:
mcp_serversin the agent is declared without auth; OAuth credentials (mcp_oauth, auto-refreshing) orstatic_bearerlive in a vault, matched by server URL. An MCP server's OAuth token is different from the same service's REST API key. - Claude Code: add servers with
claude mcp addand manage them with/mcp. Three scopes: Local (current project, only you), User (all your projects), Project (an.mcp.jsonfile committed to version control so the whole team shares it). - In the Agent SDK, MCP tools are named
mcp__<server>__<tool>and can go inallowed_toolsor serve as hook matchers.
Scenario example
A team of 12 developers needs the same access to Linear and an internal documentation server when using Claude Code, without anyone configuring it by hand. Choose the Project scope with .mcp.json committed to the repo. The internal server only needs to run on developer machines, so use stdio; Linear is a vendor's remote service, so use HTTP. Keep tokens out of committed files.
Context cost and reliability
MCP servers add tools to the context even when unused; Claude Code enables tool search by default, but you should still disable servers you don't use. If an equivalent CLI exists (gh, aws), the CLI uses less context. On security, a remote server can change after approval, and server output is untrusted content. MCP tool annotations help declare which tools destroy data or need open-world access.
(Sources: Anthropic Academy: Introduction to Model Context Protocol; Anthropic Academy: Model Context Protocol: Advanced topics — Roots, The STDIO transport, The StreamableHTTP transport, StreamableHTTP in depth, State and the StreamableHTTP transport; Anthropic Academy: Claude Code 101 — MCP; Anthropic Academy: Claude Platform 101 — MCP; Anthropic Skills: claude-api — Managed Agents: Tools & Skills)
Capability mechanism selection
Claude Platform 101 sums it up: "tools are for your stuff, skills are for your processes, and MCP is for everyone else's stuff." Tools tell Claude what to do with a system; Skills teach how to do it according to a process.
| Mechanism | Where the capability lives | Who maintains it | How Claude discovers/invokes it | Choose when |
|---|---|---|---|---|
| Built-in/server tool | Anthropic infrastructure or the harness (Claude Code: Bash, Read, Edit, Grep...) | Anthropic | Declared by type (server tools) or built into the harness | General capabilities: web search, code execution, file operations |
| Custom tool | Your code | You | Schema + description sent in tools on every request |
Internal systems, proprietary APIs |
| Skill | A SKILL.md directory (+ scripts, docs) |
You/your team | name + description are always loaded; the Skill body loads only on a match (progressive disclosure) |
Recurring processes, templates, checklists |
| MCP server | Local process or remote service | The service vendor (or a platform team) | Client introspects ListTools |
Third-party services, or integrations reused across many apps/agents |
Skills: frequently tested details
SKILL.mdhasnameanddescriptionfrontmatter.descriptiondetermines when the Skill is used; when uploading to Claude.ai or the API it is required, with a maximum of 1,024 characters.nameallows only lowercase letters, digits, and hyphens, up to 64 characters.- Locations in Claude Code:
~/.claude/skills(personal),.claude/skills(project); enterprise managed settings take the highest precedence. - Progressive disclosure: metadata, then the Skill body, then linked files. Keep
SKILL.mdunder 500 lines; scripts run without their code being loaded into context. allowed-toolspre-approves tools while the Skill is active; it does not restrict Claude to only those tools.- Subagents don't inherit invoked Skills; declare them through the
skillsfield in the agent file. - On the API: upload with
client.skills.create(...), attach viacontainer={"skills": [{"type": "custom", "skill_id": ..., "version": "latest"}]}, and the code execution tool is required.
Compared with other Claude Code mechanisms: CLAUDE.md is always loaded, Skills load on demand, slash commands are invoked explicitly by the user, hooks run on events, subagents have their own context, and MCP brings in external tools. Use computer use only when there is no MCP, API, or CLI.
Key point
Items ask "who maintains it". Integrating with a frequently changing third-party API whose vendor already offers an MCP server: use MCP; don't write your own custom tool. An internal API that must be reused across many agents or teams: package it as an internal MCP server. Used by only one app: a custom tool is enough.
Scenario example
An analytics team wants Claude to always produce the weekly report from the company template, using data from the internal data warehouse, and post it to Slack. A sensible split: a Skill holds the template and process (loaded when needed); a custom tool or internal MCP server queries the warehouse (your system); Slack's MCP server does the posting (someone else's service, maintained by the vendor). Stuffing the template into the system prompt wastes context on every request; writing your own Slack wrapper means maintaining it yourself.
Exam trap
A Skill is not a mechanism for connecting to systems. It is packaged instructions and scripts. Conversely, a custom tool is not the place for a long multi-step process. And third-party plugins or Skills run with your privileges, so install them only from trusted sources after an audit.
(Sources: Anthropic Academy: Claude Platform 101 — Built-in tools, Skills, MCP; Anthropic Academy: Introduction to agent skills; Anthropic Research: Equipping agents with Agent Skills)
Quick summary
- Tool =
name+description+input_schema;input_examplesmust be valid against the schema, or you get 400. - Descriptions of 3–4 sentences or more: what it does, when to use / not use it, parameter meaning and format, what it doesn't return.
- Wrong tool chosen: fix the description or merge tools; wrong format: fix the schema/examples. Merging 6 tools into 3 raised the score from 14/30 to 26/30.
strict: true+additionalProperties: falseforces input to match the schema; no min/max/length support (400); up to 20 strict tools per request.- Forcing
tool_choiceany/toolreturns 400 on many new models (Claude Opus 5.5, Claude Sonnet 5.5...); keepauto. - Compact tool results: high-signal fields,
response_formatconcise/detailed, pagination; Claude Code caps at 25,000 tokens. - Errors:
is_error: true+ an actionable message. - Parallel tool use: every
tool_resultin one user message, before any text, matched bytool_use_id. - Server tools (web search, web fetch, code execution) are run by Anthropic; client tools are run by you, so you can insert an approval step.
cache_controlon the last tool to cache the tool set;defer_loading+ tool search for large tool sets;allowed_callersfor programmatic tool calling.- MCP primitives: tools are model-controlled, resources application-controlled, prompts user-controlled.
- stdio = local subprocess; Streamable HTTP = remote, SSE;
stateless_http=Truefor horizontal scaling, but you lose sampling/progress/server→client. - Spec 2026-07-28 drops the handshake and session IDs and deprecates sampling/logging/roots; SDK v1 still uses the old approach.
- Claude Code MCP scopes: Local, User, Project (
.mcp.jsoncommitted for the team); manage with/mcp. - Tools for your systems, Skills for your processes, MCP for other people's services.