Software Engineeringunpacked

LLM tool calling with Claude: how tool use works, from definition to result

Tool calling (Anthropic calls it tool use, others say function calling) lets a model ask your code to do something it can't do itself: look up a record, call an API, run a query. You describe each tool with a name, a description and a JSON input schema. Claude answers with a tool_use block naming a tool and its arguments; your code runs it and sends the result back in a tool_result block.

What is LLM tool calling?

A language model only produces text. Tool calling gives it hands: you describe functions your application can run, and the model can ask for one of them, with arguments, when a request needs it. Anthropic's docs: tool use (also called function calling) "lets Claude call functions that you define or that Anthropic provides. Claude determines when to call a tool based on the user's request and the tool's description."

The model never runs anything itself. It returns a structured request; your application decides whether and how to execute it.

How Claude tool use works: the round trip

  1. Define the tool in the request: name, description, input_schema (a JSON Schema).
  2. Claude decides. If the request needs the tool, the response stops with stop_reason: "tool_use" and contains a tool_use block: an id, the tool name and the input.
  3. Your code runs it with that input.
  4. Send the result back in the next request: append Claude's message, then a user message with a tool_result block carrying the same tool_use_id.
  5. Claude answers using the result, or asks for another tool.

json { "name": "lookup_booking", "description": "Returns one bike rental booking by its ID: bike, dates, status, amount paid and deposit state. Use it when the customer gives a booking ID or after find_customer returned their latest booking. Does not return payment card details.", "input_schema": { "type": "object", "properties": {"booking_id": {"type": "string", "description": "Booking ID such as B-1042"}}, "required": ["booking_id"] } }

Claude's call comes back as a block like {"type": "tool_use", "id": "toolu_...", "name": "lookup_booking", "input": {"booking_id": "B-1042"}}, and your reply is {"type": "tool_result", "tool_use_id": "toolu_...", "content": "..."}. Repeating this until Claude stops asking for tools is the agentic loop.

Client tools vs server tools

Who runs it Examples What you do
Your own tools Your application lookup_booking, a database query Run it, return a tool_result
Anthropic-schema client tools Your application bash, text_editor, memory Anthropic publishes the schema; you still execute
Server tools Anthropic web_search, web_fetch, code_execution, tool search Nothing: results arrive in the same response

Write descriptions Claude actually follows

The docs call detailed descriptions "by far the most important factor in tool performance". Say what the tool does, when to use it and when not to, what each parameter means, and what it does not return; they suggest at least 3 to 4 sentences per tool. Group related operations into fewer tools with an action parameter, namespace tool names when you have many services (github_list_prs), and return only the fields Claude needs for its next step. For complex inputs, input_examples shows schema-valid examples.

Controlling when Claude calls a tool: tool_choice

tool_choice Behavior
auto (default with tools) Claude decides whether to call a tool
any Claude must call one of the tools
tool Claude must call the named tool
none No tool calls (default without tools)

Forcing has limits today: on Claude Opus 5.5, Sonnet 5.5, Fable 5.1 and Mythos 5.1, any and tool return a 400 error, and with manual extended thinking they are not supported either. The docs recommend auto with strict tool use (strict: true on the tool, so inputs always match your schema) or structured outputs when you need a fixed JSON shape.

Parallel tool calls and tool errors

Claude can ask for several tools in one response; run them and return every tool_result in one user message. When a tool fails, don't hide it: return the error in the tool_result (with is_error: true) and say what went wrong, so Claude can retry, try another path or hand the case to a person. An empty "no results" for a lookup that actually timed out is the worst case, because Claude will believe it.

Tool use with MCP and the Agent SDK

You don't have to define every tool in each request. An MCP server exposes tools once for any MCP client, and the Messages API can reach remote servers through the MCP connector. The Claude Agent SDK comes with built-in tools and runs the loop for you; the client SDKs also offer a beta tool runner that executes your tools and returns results automatically.

Tool use on the Claude Certified Architect exam

Domain 2, Tool Design & MCP Integration, is 18% of the CCAR-F exam: tool descriptions that separate similar tools, structured error responses, distributing tools across agents and tool_choice, MCP servers, and the built-in tools. Domain 4 adds tool use with JSON schemas for structured output. Expect questions where Claude picks the wrong tool; the first fix is almost always a clearer description, not more tools or a forced choice.

More in all articles.

Sources: Tool use with Claude; Define tools; Handle tool calls; Strict tool use; Claude Certified Architect Foundations exam guide v1.0, domain 2.

FAQ

What is LLM tool calling?

A way for a model to request actions from your application. You define tools with a name, description and input schema; the model returns a structured call with arguments; your code executes it and returns the result for the model to use.

Is Claude tool use the same as function calling?

Yes. Anthropic's docs say tool use is also called function calling: Claude decides when to call a tool from the request and the tool's description, and returns a structured call.

Who runs the tool, Claude or my code?

For tools you define (client tools), your code runs them. Server tools such as web search, web fetch and code execution run on Anthropic's infrastructure and return their results in the same response.

How do I force Claude to call a tool?

tool_choice set to any or to a named tool forces a call on models that support it. On Claude Opus 5.5, Sonnet 5.5, Fable 5.1 and Mythos 5.1 those values return a 400 error; use auto with strict tools, or structured outputs.