Method·7 min read·27 August 2026

Claude Tool Use Guide: Schema, Loops, and Production

This claude tool use guide covers tool definition, loop management, error handling, and MCP integration for architects preparing the CCAR-F exam.

By Solomon Udoh · AI Architect & Certification Lead

Claude Tool Use Guide: Schema, Loops, and Production

Tool use is the mechanism by which Claude transforms from a text generator into an active agent. This claude tool use guide walks through every layer of the pattern: how to define tools, how Claude selects them, how to close the agentic loop, and how to make the whole system production-reliable. These are also the patterns tested most heavily in the CCAR-F exam's two highest-weighted domains.

What is tool use in Claude, and how does the loop work?

Tool use lets Claude request the execution of functions you define. The model reads your tool definitions, decides whether to call one, emits a tool_use content block, and waits. Your code runs the function, returns a tool_result block, and the loop continues until Claude emits end_turn rather than tool_use.

The cycle is deterministic on your side: Claude never executes anything itself. It signals intent; you act.

Loading diagram...

Understanding stop_reason field inspection is the first skill the exam tests: architects who treat tool_use and end_turn identically write loops that terminate early or run indefinitely.

How do you define a tool for Claude?

Each tool is a JSON object with three required fields: name, description, and input_schema. The schema follows JSON Schema draft 7. A minimal, well-formed example:

json
{
"name": "search_orders",
"description": "Search the order database by customer ID and optional date range. Returns a list of matching orders sorted by date descending. Use this tool when the user asks about past orders or purchase history.",
"input_schema": {
"type": "object",
"properties": {
"customer_id": {
"type": "string",
"description": "The unique customer identifier."
},
"since_date": {
"type": "string",
"format": "date",
"description": "Optional ISO 8601 date. Only return orders on or after this date."
}
},
"required": ["customer_id"]
}
}

Three things distinguish a reliable tool definition from a problematic one:

  • Description specificity. Claude routes to tools almost entirely on description text. A description that says "searches orders" is underspecified; one that explains when to use the tool, what it returns, and how results are ordered gives the model the signal it needs. See writing effective tool descriptions for patterns that hold up across different request phrasings.
  • Schema precision. Mark every required field in required. Use enum values wherever the field has a fixed domain. Avoid loose string types when you actually expect ISO dates or UUIDs: tighter schemas produce fewer malformed calls.
  • Name uniqueness. When two tools have similar names and overlapping descriptions, Claude will misroute. Tool splitting for specificity covers when to break a broad tool into narrow ones and when that makes things worse.

How does Claude choose which tool to call?

Claude's tool selection is driven by the description field, not the name alone. The model reads all tool descriptions in context and picks the one that best matches its current intent.

Selection factorWhat it controlsCommon mistake
Description textPrimary routing signalToo generic ("manages data")
Parameter namesReinforces intentCryptic abbreviations
required fieldsForces structured inputLeaving all fields optional
tool_choice configForces or disables callingAlways forcing when optional tools exist

The tool_choice parameter lets you override free selection. Setting it to {"type": "tool", "name": "search_orders"} forces that specific tool. Setting it to {"type": "any"} forces some tool call without specifying which. This matters for deterministic pipelines where you know a step must call a tool.

Anthropic's tool use documentation states that the description field is the primary signal Claude uses to select among available tools. Descriptions that explain when to use a tool and what it returns produce more reliable routing than descriptions that only name the tool's function.

Anthropic , Claude Tool Use Documentation

Tool choice configuration options covers the full semantics, including the auto default and edge cases where forcing a tool call conflicts with other constraints.

How do you pass tool results back correctly?

The result turn must append both the assistant's tool_use block and a new user message containing the tool_result block. The structure matters:

python
# After Claude responds with a tool_use block:
tool_use_block = response.content[0] # type: tool_use
messages = [
{"role": "user", "content": original_user_message},
{"role": "assistant", "content": response.content}, # full content, not just text
{
"role": "user",
"content": [
{
"type": "tool_result",
"tool_use_id": tool_use_block.id,
"content": json.dumps(query_result),
}
],
},
]

Two common mistakes here:

  1. Dropping the assistant content. Some implementations extract only the text from the assistant response and discard the tool_use block. Without it, Claude loses the record of which tool it called, and the next response may be incoherent.
  2. Returning errors silently. If tool execution fails, return a tool_result with is_error: true and a structured error description. An empty success response causes Claude to continue as though the tool ran successfully, compounding the failure.

Tool result appending documents the exact message array structure the API requires.

How do you handle tool errors without breaking the loop?

Error handling is where most naive agentic loops fail. There are four error categories worth treating differently:

CategoryExampleRecommended response
Access failurePermission denied, 401Return is_error: true, surface to model with context
Valid empty resultZero rows returnedReturn success with empty array, not an error
Transient failureNetwork timeoutRetry with back-off, then surface error
Schema violationModel passed wrong typeValidate before calling, return descriptive error

The critical distinction is between access failure and a valid empty result. An empty database query is not a failure; marking it is_error: true teaches Claude that empty results indicate a broken tool. See access failure vs valid empty result for the decision rule.

For multi-agent systems, error propagation compounds: a subagent that silently returns empty results will cause the coordinator to synthesise a response with no data. Error propagation in multi-agent systems covers how to surface structured error metadata upward through the hierarchy.

How do you design tools for MCP and multi-agent contexts?

When tools are served via the Model Context Protocol, the same description-first principles apply, but deployment scope adds a second design dimension. MCP servers can be scoped globally, per-project, or per-conversation. Choosing the wrong scope exposes tools to agents that should not access them.

json
{
"mcpServers": {
"order-db": {
"command": "node",
"args": ["./mcp/order-server.js"],
"env": {
"DB_URL": "${ORDER_DB_URL}"
}
}
}
}

In a multi-agent architecture, the coordinator typically holds a broad tool palette and delegates specific tasks to subagents with narrower tool sets. This reduces the risk of a subagent calling a destructive tool by mistake and keeps each agent's decision space small enough to be reliable.

The CCAR-F exam's Domain 1 (Agentic Architecture and Orchestration, weighted at 27% of the exam) and Domain 2 (Tool Design and MCP Integration, weighted at 18%) together cover the majority of tool use scenarios. The tool design and MCP integration concept library maps every task statement in both domains.

What prompt structure produces the most reliable tool use?

Prompt structure affects whether Claude uses tools at the right moment. Several patterns hold up at production scale.

System prompt:

  • Define the agent's role and permitted actions in the first paragraph.
  • List any tools Claude must always use for specific request types.
  • Keep the system prompt stable across turns so it can be prompt-cached, reducing latency and cost in high-volume systems.

User message ordering:

  • Put documents and data before the question, not after. The document-first pattern keeps the task frame visible at the end of a long context window.
  • For structured extraction tasks, include one or two worked examples showing the tool call and result you expect. Concrete examples within the user message outperform longer natural-language instructions for format stability.

Tool use vs. structured output:

ApproachBest when
Tool callYou need to execute real logic or fetch live data
response_format JSONPure transformation with no side effects
System-prompt-instructed JSONSimple extraction, single-turn, no external calls

The prompt engineering and structured output concept domain covers when to reach for each pattern and how to avoid format mixing that degrades reliability.

How do you debug a failing tool use loop?

Debugging tool use requires inspecting the full message array at each turn, not just the final response. Three diagnostic questions:

  1. Is stop_reason what you expected? If it is end_turn on the first response, Claude chose not to call a tool. Check whether the description matches the user's phrasing.
  2. Did Claude call the right tool? Log tool_use_block.name and tool_use_block.input at each turn. Misrouting almost always traces to a description that overlaps with another tool or is too generic.
  3. Did the loop terminate correctly? A loop that never terminates usually means stop_reason is never checked, or tool_use is being returned but the result is not being appended. See agentic loop anti-patterns for the canonical failure modes.

The CCAR-F exam rewards architects who trace failures to root causes rather than applying blanket fixes. Candidates who have worked through the concept library, which covers 174 atomic concepts mapped to the five exam domains, report that tool use debugging scenarios appear across both Domain 1 and Domain 2 sections of the exam.

Frequently asked questions

How do I force Claude to use a specific tool every time?
Set `tool_choice` to `{"type": "tool", "name": "your_tool_name"}` in the API request. This overrides the model's free selection and guarantees the named tool is called. Use this pattern in deterministic pipeline steps where a tool call is not optional and you cannot rely on description-based routing alone.
What should I return in a tool_result when the tool fails?
Return a `tool_result` block with `is_error: true` and a plain-text or structured error description in the `content` field. This signals to Claude that the tool did not succeed, allowing it to respond appropriately rather than continuing as if the call had succeeded and producing a response built on missing data.
What is the difference between tool use and asking Claude for structured JSON output?
Tool use is for fetching data or executing actions at runtime: the model emits a `tool_use` block, your code runs, and the result flows back into the conversation. Structured JSON output is for transforming input to output in a single response with no external calls. Use tool use when you need live data or side effects; use structured output when you need only a formatted response.
How do I prevent Claude from calling tools when I do not want it to?
Set `tool_choice` to `{"type": "none"}` to disable all tool calls for that request. Alternatively, omit the `tools` parameter entirely. Both approaches return a text-only response. Use this pattern for reasoning or summarisation steps in a pipeline where tool calls would be premature or incorrect.
How many tools should I pass to Claude in a single API call?
There is a per-request tool limit in the API, but practical reliability degrades as the tool count grows because descriptions compete for the model's attention. The recommended pattern is to scope tools by agent role: give each subagent the smallest set of tools it needs rather than passing every available tool to every agent in the system.
Does tool use on the CCAR-F exam appear in a specific domain?
Tool use appears across two of the five CCAR-F domains. Domain 2, Tool Design and MCP Integration, is weighted at 18% and covers definition, description quality, and error handling. Domain 1, Agentic Architecture and Orchestration, is weighted at 27% and covers loop construction, stop_reason handling, and multi-agent tool routing.

People also ask

What is Claude tool use?
Claude tool use is the API mechanism that lets the model request the execution of functions you define. Claude emits a `tool_use` content block, your code runs the function, and the result is returned as a `tool_result` block. Claude never executes code itself; it only signals which tool to call and with what parameters.
How does Claude decide which tool to call?
Claude selects a tool primarily based on the description field in the tool definition. The model reads all available tool descriptions in context and routes to the one that best matches its current intent. Descriptions that explain when to use a tool, what it returns, and what inputs it expects produce far more reliable routing than short or generic descriptions.
Does Claude run tools itself or just request them?
Claude only requests tools; it never executes them. When Claude decides to use a tool, it pauses generation, returns a `stop_reason` of `tool_use`, and waits. Your application code is responsible for running the tool and returning the result. This design keeps tool execution entirely within your control and makes behaviour auditable.
What happens when a tool fails in a Claude agent?
When a tool fails, the correct response is to return a `tool_result` block with `is_error: true` and a descriptive error message. Claude will then acknowledge the failure and decide how to proceed, whether by retrying, requesting more information, or completing the task differently. Never return a success response for a failed tool call.
How is Claude tool use different from OpenAI function calling?
Both follow a similar request-pause-execute-resume pattern, but Claude's tool definitions use an `input_schema` key (JSON Schema draft 7) rather than `parameters`, and results return in a `tool_result` content block inside a `user` role message. The description field in Claude's definitions plays a stronger routing role than in most other implementations.

About the author

Solomon Udoh

AI Architect & Certification Lead

Solomon Udoh is an AI Architect who designs and ships production agent systems on the Claude API and Claude Code. He built AI Skill Certs' adaptive engine and authored its 174-concept knowledge graph, mapping every Claude Certified Architect - Foundations objective to hands-on, exam-aligned practice.

  • Designs production multi-agent systems on the Claude API and Agent SDK
  • Author of the AI Skill Certs knowledge graph (174 mapped exam concepts)
  • Builds with MCP, Claude Code, structured outputs, and agentic loops daily
  • Reviews every concept page against the official Anthropic exam guide

You might also like

Ready to put it into practice?

Study every exam concept with an adaptive tutor.

Start studying