Files
adk-python/contributing/samples/toolbox_agent
Google Team Member 7dc6adf4e5 feat: migrate ToolboxToolset to use toolbox-adk and align validation
### Description of Change

**Problem:**
The `ToolboxToolset` was relying on the legacy `toolbox-core` package. Users wanting to use the Toolbox features were forced to install the heavy `[extensions]` group, lacking a granular installation option. Additionally, `ToolboxToolset` had a validation check enforcing either `toolset_name` or `tool_names` to be present, preventing the default behavior of loading all tools (which `toolbox-adk` supports).

**Solution:**
* Refactored `ToolboxToolset` to delegate to `toolbox-adk`.
* Added a new `toolbox` optional dependency group in `pyproject.toml`.
  * Users can now run `pip install google-adk[toolbox]` to install only the necessary dependencies.
* Updated the `extensions` dependency group to replace `toolbox-core` with `toolbox-adk`.
  * This ensures existing users of `[extensions]` are not broken upon upgrade.
* Removed the restrictive validation check to allow default loading of all tools.
* Updated the `ImportError` message to guide users toward the new granular installation command.

### Testing Plan

**Unit Tests:**
- [x] I have added or updated unit tests for my change.
- [x] All unit tests pass locally.

**Manual End-to-End (E2E) Tests:**
- Verified that the sample agent runs correctly with `toolbox-adk` locally.
- Verified that `ToolboxToolset` can now be instantiated without arguments to load all tools.

### Checklist

- [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.
- [x] I have manually tested my changes end-to-end.
- [x] Any dependent changes have been merged and published in downstream modules.

PiperOrigin-RevId: 857171811
2026-01-16 08:27:16 -08:00
..
2025-05-16 14:01:53 -07:00
2025-05-16 14:01:53 -07:00
2025-11-05 15:43:25 -08:00

Toolbox Agent

This agent utilizes MCP toolbox for database to assist end users based on information stored in a database.

Follow the steps below to run this agent.

Prerequisites

Before starting, ensure you have Python installed on your system.

Installation Steps

1. Install Toolbox

Run the following command to download and install the toolbox:

export OS="linux/amd64" # one of linux/amd64, darwin/arm64, darwin/amd64, or windows/amd64
curl -O https://storage.googleapis.com/genai-toolbox/v0.5.0/$OS/toolbox
chmod +x toolbox

2. Install SQLite

Install SQLite from https://sqlite.org/

3. Install Required Python Dependencies

Important: The ADK's ToolboxToolset class requires the toolbox-adk package, which is not automatically installed with the ADK. Install it using:

pip install google-adk[toolbox]

4. Create Database (Optional)

Note: A database instance is already included in the project folder. Skip this step if you want to use the existing database.

To create a new database:

sqlite3 tool_box.db

Run the following SQL commands to set up the hotels table:

CREATE TABLE hotels(
  id            INTEGER NOT NULL PRIMARY KEY,
  name          VARCHAR NOT NULL,
  location      VARCHAR NOT NULL,
  price_tier    VARCHAR NOT NULL,
  checkin_date  DATE    NOT NULL,
  checkout_date DATE    NOT NULL,
  booked        BIT     NOT NULL
);

INSERT INTO hotels(id, name, location, price_tier, checkin_date, checkout_date, booked)
VALUES 
  (1, 'Hilton Basel', 'Basel', 'Luxury', '2024-04-22', '2024-04-20', 0),
  (2, 'Marriott Zurich', 'Zurich', 'Upscale', '2024-04-14', '2024-04-21', 0),
  (3, 'Hyatt Regency Basel', 'Basel', 'Upper Upscale', '2024-04-02', '2024-04-20', 0),
  (4, 'Radisson Blu Lucerne', 'Lucerne', 'Midscale', '2024-04-24', '2024-04-05', 0),
  (5, 'Best Western Bern', 'Bern', 'Upper Midscale', '2024-04-23', '2024-04-01', 0),
  (6, 'InterContinental Geneva', 'Geneva', 'Luxury', '2024-04-23', '2024-04-28', 0),
  (7, 'Sheraton Zurich', 'Zurich', 'Upper Upscale', '2024-04-27', '2024-04-02', 0),
  (8, 'Holiday Inn Basel', 'Basel', 'Upper Midscale', '2024-04-24', '2024-04-09', 0),
  (9, 'Courtyard Zurich', 'Zurich', 'Upscale', '2024-04-03', '2024-04-13', 0),
  (10, 'Comfort Inn Bern', 'Bern', 'Midscale', '2024-04-04', '2024-04-16', 0);

5. Create Tools Configuration

Create a YAML file named tools.yaml. See the contents in the agent folder for reference.

6. Start Toolbox Server

Run the following command in the agent folder:

toolbox --tools-file "tools.yaml"

The server will start at http://127.0.0.1:5000 by default.

7. Start ADK Web UI

Follow the ADK documentation to start the web user interface.

Testing the Agent

Once everything is set up, you can test the agent with these sample queries:

  • Query 1: "What can you do for me?"
  • Query 2: "Could you let me know the information about 'Hilton Basel' hotel?"