Tools and MCP
Tool Design and Response Shaping
Exam objective: Implementing a tool for an integration need: a function schema, a description that drives correct invocation, response shaping so the model receives a minimal and actionable result, error handling, the choice of execution side, and an approval pattern, and assembling the tool set for performance.
What the exam tests
Whether you can turn an integration need into a working tool: a schema, a description that makes Claude call it at the right time with the right input, a small and actionable result, clear errors, the right execution side, an approval step where needed, and a tool set that stays accurate and cheap as it grows.
Key rules
Definition. A user tool has name, description, input_schema and optionally input_examples. The description matters most: what the tool does, when to use it and when not, what each parameter means, and what it does not return. Name parameters unambiguously (user_id, not user).
{
"name": "orders_search",
"description": "Search a customer's orders by status and date. Use for order history or delivery questions, not refund policy. Returns at most 20 orders; no payment data.",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"customer_id": { "type": "string", "description": "ID such as cus_123, not an email" },
"status": { "type": "string", "enum": ["open", "shipped", "returned"] }
},
"required": ["customer_id"],
"additionalProperties": false
}
}
Guarantees. strict: true constrains sampling so inputs match the schema. Descriptions and examples only make correct calls more likely.
Response shaping. Return only what Claude needs for its next step, with meaningful names and stable identifiers. For large outputs use filtering, pagination, range selection or truncation with sensible defaults, and say how to get more. A response_format (concise/detailed) parameter can expose IDs only when needed.
Errors. Answer every tool_use with a tool_result, even on failure. Set is_error: true and say what went wrong and what to try next. Cap retries.
Execution side. Client tools run in your application: private systems, your credentials, your logging, your checks. Server tools (web search, web fetch, code execution, tool search) run on Anthropic's infrastructure with no handler code.
Approval. For client tools, gate in your own loop before executing; a denial returns an error result with the reason. The SDK tool runner docs point to the manual loop for human-in-the-loop approval.
Tool set. Build a few tools around real workflows rather than wrapping every endpoint. Consolidate related operations and namespace by service. With many tools, use tool search with defer_loading, keeping the 3–5 most used loaded. For fan-out calls with bulky results, use programmatic tool calling. Evaluate changes with realistic tasks.
Parallel calls. Run independent reads concurrently; run side-effecting or dependent calls sequentially. Return all results in one user message.
Traps
- "Ask for approval" written in a description or system prompt is guidance, not a gate.
- An empty success result on failure reads as real data.
- Text before
tool_resultblocks is an error. When a server tool call is still pending beside a client call, send results only. defer_loadingstill requires sending every definition; the search tool itself cannot be deferred.allowed_callersis not a security boundary.strict: truetools cannot be used with programmatic calling.- On Claude Opus 5.5 and Sonnet 5.5,
tool_choiceofanyortoolreturns a 400. - Prompt caching lowers cost, not context size.
Decide quickly
| Situation | Choice | Why |
|---|---|---|
| Wrong tool or wrong arguments | Improve the description | Biggest lever on invocation |
| Input types must be guaranteed | strict: true | Schema-constrained sampling |
| Complex or format-sensitive input | Add input_examples | Shows concrete patterns |
| Private database or internal API | Client tool | Your code has access and control |
| Irreversible action | Approval gate before execution | Enforced in code |
| 10+ tools, mostly unused | Tool search | Fewer definitions in context |
| Many calls, large results to filter | Programmatic tool calling | Raw results stay out of context |
| Three calls always chained | One consolidated tool | Fewer turns and less ambiguity |