Skip to main content
Add Python functions as tools that agents can execute. There are two ways: pass functions directly (simple) or use the Tool class (advanced).

Quick Start - Simple Function

The easiest way is to pass a function directly to add_tool():
The ADK automatically:
  • Uses the function name as the tool name
  • Uses the docstring as the description
  • Infers parameters from type hints
  • Determines required vs optional from default values

Quick Start - Tool Class

For more control, use the Tool class:

When to Use Each Approach


Simple Function Requirements

For the ADK to auto-infer tool parameters:

Supported Types


Tool Class

Parameters


Defining Parameters

Parameters use JSON Schema format:

Basic Schema

Supported Types

Complete Example


Auto-Infer Parameters

Generate parameters automatically from function signatures:

Type Mapping


Sync and Async Functions

Tools support both synchronous and asynchronous functions:

Synchronous

Asynchronous


Adding Tools to Agents

Single Tool

Multiple Tools

At Creation Time


Tool Registry

Manage collections of tools:

Tool API Format

Convert tools for API registration:

Examples

Database Tool

HTTP API Tool

File System Tool


Best Practices

Clear Descriptions

Detailed Parameter Descriptions

Return Structured Data