advancedChapter 11 of 12

Tool Use (Function Calling)

Tool/function definitions · Structured tool inputs · Tool result handling

Giving Claude Tools

Claude can call external tools (functions) when given their definitions. This lets Claude interact with APIs, databases, calculators, or any external system.

How Tool Use Works

  1. You define tools with a name, description, and input schema.
  2. Claude decides when to call a tool based on the user's request.
  3. Your system executes the tool and returns the result.
  4. Claude incorporates the result into its response.

Defining Good Tools

{
  "name": "get_weather",
  "description": "Get the current weather for a specific city.",
  "input_schema": {
    "type": "object",
    "properties": {
      "city": {
        "type": "string",
        "description": "The city name, e.g., 'San Francisco'"
      }
    },
    "required": ["city"]
  }
}

Key Takeaways

  • Tool descriptions should be clear and unambiguous — they guide Claude's decision to use the tool.
  • Parameter descriptions matter as much as the tool description.
  • Claude picks the right tool based on matching the user's intent to tool descriptions.

Exercises