Tool Use with Claude
Implement tool use with Claude API: define tools, handle tool calls, and build reliable function-calling agents.
Last updated
Tool Use: Giving Claude Superpowers
Tools are how Claude reaches past its training data — to your database, the web, a calculator, an action. This is the exact request/response contract, plus the tool-design skill that separates agents that work from agents that thrash.
Claude never runs your code. When it decides a tool is needed, it emits a structured tool_use block — a JSON request saying “please run get_weather(city="Paris") and tell me the result.” Your code runs the function and hands back a tool_result. That’s the whole mechanism, and it’s a two-message handshake, not a function call. The agent loop (a separate section) just repeats this handshake until Claude is done; here we master the single exchange and, more importantly, how to design the tools so Claude picks the right one.