# Google Agent Development Kit + Dizo

> Give a Google ADK agent the Dizo tools with McpToolset and StreamableHTTPConnectionParams, then test it in adk web.

Type: MCP client — server URL `https://mcp.dizo.ai/mcp`. No native app needed.

## Steps
1. `pip install google-adk` and export `DIZO_API_KEY`.
2. Create a folder with `__init__.py` and `agent.py` that defines `root_agent`.
3. Add an `McpToolset` with `StreamableHTTPConnectionParams` pointing at Dizo, plus a `tool_filter`.
4. Run `adk web` from the parent folder and pick the agent in the UI.

## Where to go
`McpToolset` with a remote HTTP connection.

Open the ADK MCP docs: https://adk.dev/tools-custom/mcp-tools/#example-remote-http-sse-transport-google-maps-grounding-lite

## dizo_agent/agent.py
```
import os
from google.adk.agents import LlmAgent
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams

root_agent = LlmAgent(
    model="gemini-flash-latest",
    name="prospector",
    instruction="Size the market with dizo_count first. Quote with dizo_quote before any job over 100 credits.",
    tools=[
        McpToolset(
            connection_params=StreamableHTTPConnectionParams(
                url="https://mcp.dizo.ai/mcp",
                headers={"Authorization": f"Bearer {os.environ['DIZO_API_KEY']}"},
                timeout=30,
            ),
            tool_filter=["dizo_count", "dizo_company_search", "dizo_org_chart",
                         "dizo_find_email", "dizo_quote", "dizo_whoami"],
        )
    ],
)
```

## Layout and run
```
dizo_agent/
  __init__.py      # from . import agent
  agent.py         # defines root_agent

export DIZO_API_KEY=dz_test_...
adk web            # run from the folder that contains dizo_agent/
```

## Notes
- `tool_filter` keeps the model's tool list short and doubles as a second allow-list on top of the key's own endpoint allow-list.
- ADK needs `__init__.py` next to `agent.py` to discover the agent.

## Related API docs
- [/docs/count](https://dizo.ai/docs/count.md)
- [/docs/company-search](https://dizo.ai/docs/company-search.md)
- [/docs/org-chart](https://dizo.ai/docs/org-chart.md)


## Google ADK in brief, and where Dizo fits

The Agent Development Kit (ADK) is Google's open-source framework for building agents in code. In Python you define an `LlmAgent` with a model, a name, an instruction and a list of tools, expose it as `root_agent` in an `agent.py` file, and run it locally with the `adk web` developer UI. ADK is model-agnostic in principle but is most at home with Gemini models, and the MCP examples in its docs use a model string such as `gemini-flash-latest`.

ADK talks to MCP servers through `McpToolset`. For a remote server, you give it `StreamableHTTPConnectionParams` with a URL and headers, and the server's tools appear in the agent's tool list. That is all Dizo needs: the hosted server at `https://mcp.dizo.ai/mcp` speaks streamable HTTP and accepts an `Authorization: Bearer` header, so a Gemini-powered agent can search for accounts, map buying committees and find verified work emails without any custom wrapper code.

## Why give an ADK agent Dizo

Agents that plan GTM work are good at reasoning about segments, titles and messaging, but they have no reliable knowledge of who works where today. Asking a model to name the head of finance at a mid-size logistics company produces a confident answer that may be out of date or invented. Connecting a data tool replaces that guess with a lookup, and Dizo's email finder returns a work email only when it validates, researched when you ask.

Dizo was built for this kind of caller. Every MCP tool description carries its credit cost, `dizo_count` sizes a market for free, and `dizo_quote` returns the exact cost of any call without spending anything. Lookups that find nothing are free. Those properties let you hand an ADK agent a real budget while keeping the worst case predictable, which is the difference between a demo and something you leave running.

## Jobs an ADK agent can do with Dizo

Some prompts that map cleanly onto Dizo tools:

- "How many US fintech companies have 200 to 1,000 employees?" answered with `dizo_count`, at no cost.
- "List 100 of them headquartered in Texas" with `dizo_company_search`.
- "Who runs finance and RevOps at these 20 accounts?" with `dizo_org_chart`, filtered by department and seniority.
- "Get work emails for the five most senior people at each" with `dizo_find_email`.
- "Who is this person?" for an inbound address, with `dizo_email_to_profile`.
- "How much budget do I have left?" with `dizo_whoami` or `dizo_balance`, both free.

## Building the agent folder

Install ADK with `pip install google-adk` and export `DIZO_API_KEY`. Use a `dz_test_` key while you develop: it returns synthetic data and never spends credits. Then create a folder for the agent, for example `dizo_agent/`, containing two files. ADK's docs note that `__init__.py` must sit next to `agent.py` for the agent to be discovered; it usually contains `from . import agent`.

In `agent.py`, import `LlmAgent` from `google.adk.agents`, `McpToolset` from `google.adk.tools.mcp_tool`, and `StreamableHTTPConnectionParams` from `google.adk.tools.mcp_tool.mcp_session_manager`. Define `root_agent` as an `LlmAgent` with a model, a name and an instruction, and put one `McpToolset` in its `tools` list. The connection parameters take `url="https://mcp.dizo.ai/mcp"`, a `headers` dictionary with the bearer key read from the environment, and an optional `timeout`.

From the parent folder, run `adk web`, pick the agent in the browser UI and send it a prompt. The UI shows each tool call and its result, which is the quickest way to see whether the agent is calling `dizo_count` before it searches, as your instruction asked.

## Using tool_filter as a second allow-list

`McpToolset` accepts a `tool_filter` list, and ADK's docs recommend using one to limit what the model sees. With Dizo this does two jobs. It keeps the model's context small, which tends to improve tool choice, and it means the agent cannot even attempt a tool you left out. The example on this page exposes only `dizo_count`, `dizo_company_search`, `dizo_org_chart`, `dizo_find_email`, `dizo_quote` and `dizo_whoami`.

The filter is a client-side convenience, so pair it with a server-side limit. Give the key an endpoint allow-list that matches the filter: `/v1/count`, `/v1/companies/search`, the org chart endpoint and `/v1/email/find`. If someone later edits the filter to add the phone finder, the key still refuses the call until a human changes the allow-list in the console. The [keys reference](/docs/keys) shows how to set it.

## Controlling spend

Write the spending rules into the agent's `instruction`: size the job with `dizo_count` first, call `dizo_quote` before anything likely to exceed about 100 credits, and stop and report on a 402. Those rules guide the model. The hard limits sit on the key and the account.

On the key, set `data:read` scope, a `max_credits_per_request`, a daily cap and a monthly cap. MCP connections already default to `data:read` and a 500-credit per-call limit unless you change them in the console. On the account, a monthly spend cap in USD stops every call with `402 monthly_cap_reached` once reached, and alerts go out at 50%, 80% and 100% of any cap. Auto-refill never pushes the month past the cap. The billing endpoints are covered in the [billing docs](/docs/billing).

Give the agent a habit of checking its own budget. `dizo_whoami` returns the key's scopes, allow-list, remaining monthly budget and rate limits, and it is free, so an instruction such as "call dizo_whoami once at the start of each session and plan within the remaining budget" costs nothing and prevents the most common failure, which is an agent starting a large job it cannot finish. For long sessions, a mid-run `dizo_balance` check is also free.

## Worked example: a territory plan in one session

A rep asks the agent to plan a Texas fintech territory. The agent calls `dizo_count` for two or three segment definitions, which costs nothing, and picks the one with enough companies. It then calls `dizo_company_search` for 500 accounts. At 1 credit per 25 results, that is 20 credits.

Next it picks 20 priority accounts and calls `dizo_org_chart` for finance and RevOps at each. Assume about 30 people come back per account: 600 results, or 24 credits. Finally it finds emails for the three most senior people at each account, 60 lookups. Assume 50 are found; the 10 misses are free, so that step is 50 credits.

The session totals 94 credits. At the $0.025 pay-as-you-go rate that is $2.35. If the credits came from a $2,000 to $9,999 purchase at $0.017, it is about $1.60. The free count at the start is what keeps this cheap: the agent never searches a segment that turns out to be too small or too large. See [pricing](/pricing) for every tier.

## Telling the agent what an empty result means

Not every lookup finds someone, and an agent that treats an empty result as a failure will retry, rephrase and waste turns. Dizo does not charge for a lookup that returns no email, phone or person, so an empty result costs nothing, but the model still needs to be told what it means.

Add three rules to the `instruction`. If `dizo_find_email` finds no address, record the person as having no validated email and move on; do not guess an address from the company domain. If `dizo_email_to_profile` finds no person, treat the sender as unknown and carry on with the company, using `dizo_domain_to_company` on the domain. If a tool returns an error, read `error.code` and `error.fix`, and retry only when `error.retryable` is true, after `error.retry_after` seconds.

Ask the agent to report the misses too. A summary such as 60 emails requested, 51 found, 9 not found tells the rep what coverage looked like for that territory, and it makes the bill easy to check: 51 found emails are 51 credits and the nine misses are free. The tool-call view in `adk web` shows whether the agent stopped after one attempt per person.

## Troubleshooting

Common issues when wiring Dizo into ADK:

- Agent not listed in `adk web`: run the command from the parent of the agent folder and check that `__init__.py` exists and imports `agent`.
- Auth failure on connect: `DIZO_API_KEY` is not set in the shell that started `adk web`, or the header lacks the `Bearer ` prefix.
- A tool the agent should have is missing: check `tool_filter` spelling against the Dizo tool names, then check the key's endpoint allow-list.
- Timeouts on large searches: raise `timeout`, or move big jobs to `dizo_batch`, which runs asynchronously.
- 402 `monthly_cap_reached`: the account cap is hit; the agent should stop and tell the user.
- Rate limits: follow `error.retryable` and wait `error.retry_after` seconds before retrying.

## Security practices

Keep the key in the environment or a secrets manager and read it in `agent.py`; never hard-code it in a file that ships with the agent. Give each deployed agent its own key with its own caps so usage is visible per agent in `dizo_balance` and a single key can be revoked without disruption. Agent keys should never hold `billing:write`; billing changes need that scope and the account owner can lock billing entirely.

Develop and test against `dz_test_` keys and switch to a live key only where the agent is deployed. Anyone can [sign up](/signup) for a live key, and work email signups get 250 free credits with no card required.

## FAQ

### Which ADK classes connect to the Dizo MCP server?
`McpToolset` with `StreamableHTTPConnectionParams`. Set `url` to `https://mcp.dizo.ai/mcp` and put `Authorization: Bearer` plus your key in `headers`, then add the toolset to your `LlmAgent` tools.

### Do I have to use a Gemini model?
The ADK MCP examples use Gemini model strings such as `gemini-flash-latest`. Dizo does not care which model calls it; check ADK's docs for the models your version supports.

### Why use tool_filter if the key already has an allow-list?
The filter keeps the model's tool list short, which helps it choose well, and the allow-list enforces the limit on Dizo's side. Using both means a config edit alone cannot unlock a new endpoint.

### How do I test without spending credits?
Use a `dz_test_` key. It returns synthetic data and never spends credits, so you can iterate in `adk web` freely. The playground shows the same sandbox data.

### What happens when the agent hits the monthly cap?
Calls return `402 monthly_cap_reached`. The agent should treat that as a stop signal, not retry. Alerts at 50%, 80% and 100% of the cap warn a human beforehand.

### Is there an official Dizo integration in ADK?
No. ADK connects to Dizo through its standard MCP support for remote streamable HTTP servers. There is no Dizo-specific package or listing.
