# Claude Agent SDK + Dizo

> Pass Dizo as an HTTP MCP server in the Claude Agent SDK options and allow its tools with mcp__dizo__* to build prospecting agents in Python or TypeScript.

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

## Steps
1. Install the SDK: `pip install claude-agent-sdk` or `npm install @anthropic-ai/claude-agent-sdk`, and export `DIZO_API_KEY`.
2. Add a `dizo` entry to `mcp_servers` (Python) or `mcpServers` (TypeScript) with `type: "http"`, the Dizo URL and a bearer header.
3. Allow the tools with `mcp__dizo__*` in `allowed_tools`, or list only the specific Dizo tools the agent needs.
4. Check the `system` init message: the `dizo` server should report `connected`.

## Where to go
How to add an HTTP MCP server to `mcpServers`, including headers for remote servers.

Open the Claude Agent SDK MCP docs: https://code.claude.com/docs/en/agent-sdk/mcp#http/sse-servers

## agent.py
```
import asyncio, os
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage

async def main():
    options = ClaudeAgentOptions(
        mcp_servers={
            "dizo": {
                "type": "http",
                "url": "https://mcp.dizo.ai/mcp",
                "headers": {"Authorization": f"Bearer {os.environ['DIZO_API_KEY']}"},
            }
        },
        allowed_tools=["mcp__dizo__*"],
    )
    async for message in query(
        prompt="Find the VP of Sales at 10 US fintechs with 200-1000 employees, with emails. Quote first.",
        options=options,
    ):
        if isinstance(message, ResultMessage) and message.subtype == "success":
            print(message.result)

asyncio.run(main())
```

## agent.ts
```
import { query } from "@anthropic-ai/claude-agent-sdk";

for await (const message of query({
  prompt: "Who runs RevOps at ledgerline.io? Get a verified email.",
  options: {
    mcpServers: {
      dizo: {
        type: "http",
        url: "https://mcp.dizo.ai/mcp",
        headers: { Authorization: `Bearer ${process.env.DIZO_API_KEY}` }
      }
    },
    allowedTools: ["mcp__dizo__dizo_org_chart", "mcp__dizo__dizo_find_email", "mcp__dizo__dizo_quote"]
  }
})) {
  if (message.type === "result" && message.subtype === "success") console.log(message.result);
}
```

## .mcp.json (project)
```
{
  "mcpServers": {
    "dizo": {
      "type": "http",
      "url": "https://mcp.dizo.ai/mcp",
      "headers": { "Authorization": "Bearer ${DIZO_API_KEY}" }
    }
  }
}
```

## Notes
- MCP tools need explicit permission: without `allowed_tools`, Claude sees the Dizo tools but cannot call them.
- The SDK does not run an interactive OAuth flow, so pass a Dizo API key in `headers`.
- List individual tools instead of the wildcard to keep an agent away from tools it does not need, such as the 10-credit phone finder.

## Related API docs
- [/docs/search](https://dizo.ai/docs/search.md)
- [/docs/org-chart](https://dizo.ai/docs/org-chart.md)
- [/docs/email-find](https://dizo.ai/docs/email-find.md)
- [/docs/keys](https://dizo.ai/docs/keys.md)


## The Claude Agent SDK and where Dizo plugs in

The Claude Agent SDK lets you build agents in Python or TypeScript on the same agent loop that powers Claude Code. You call `query()` with a prompt and an options object, and the SDK streams back messages as Claude plans, calls tools and produces a result. MCP servers are first-class in that options object: you can declare local stdio servers, remote HTTP or SSE servers, or in-process SDK servers you write yourself.

Dizo is a remote MCP server at `https://mcp.dizo.ai/mcp` using streamable HTTP, which the SDK configures with `type: "http"`. Once declared, every Dizo tool shows up with a name of the form `mcp__dizo__` followed by the tool name, for example `mcp__dizo__dizo_find_email`. That gives your agent people and company search, the decision-maker finder, org charts, email and phone finders, enrichment, reverse lookups, and free tools for counting, quoting and checking the key's budget.

## Why connect Dizo to an Agent SDK agent

Agents built on the SDK often run headless: in a CI job, a backend worker or a scheduled task with no one watching the transcript. That is where data quality and spend control matter most. Dizo returns a work email only when it validates on request, with a 0–1 `confidence`, and phone numbers typed by line with a confidence score and Do Not Call flags. Lookups that find nothing are free, so an agent that tries a long list of names pays only for what it gets.

The SDK's permission model fits well with Dizo's own controls. You decide in `allowed_tools` exactly which Dizo tools the agent may call, and the key you put in the header decides how much it may spend. The two layers are independent, so a mistake in one is caught by the other. The [agent instructions page](/agents) lists the habits Dizo recommends for any autonomous caller, from quoting large jobs to reading credit headers.

## What you can build

A few agent shapes that use Dizo tools directly:

- A meeting-prep worker that takes a calendar invite domain, calls `dizo_domain_to_company` and `dizo_org_chart`, and writes a one-page brief.
- An inbound router that runs `dizo_email_to_profile` on each new signup and tags it by seniority and company size.
- A list builder that sizes a segment with `dizo_count` (free), then calls `dizo_create_list` with a `max_credits` ceiling.
- A CRM hygiene job that re-identifies bounced contacts with `dizo_enrich_person` and reports bad data with `dizo_report_bad_data`.
- An account-based agent that uses `dizo_best_contact` to pick one person per target account from a ranked list of titles.
- A champion tracker that registers contacts once with `dizo_watch_job_changes` and handles the webhooks in a separate service.

## Configuring the server, step by step

Install the SDK with `pip install claude-agent-sdk` for Python or `npm install @anthropic-ai/claude-agent-sdk` for TypeScript, and export your Dizo key as `DIZO_API_KEY`. In Python, build a `ClaudeAgentOptions` object whose `mcp_servers` dictionary has a `dizo` entry with three keys: `type` set to `http`, `url` set to the Dizo endpoint, and `headers` holding `Authorization: Bearer` plus the key from the environment. In TypeScript the option is `mcpServers` with the same shape.

Next, grant permission. MCP tools in the SDK require explicit permission, and without it Claude can see the tools but cannot call them. Add `mcp__dizo__*` to `allowed_tools` to allow every Dizo tool, or list individual names such as `mcp__dizo__dizo_org_chart` and `mcp__dizo__dizo_find_email` for a tighter agent. The SDK docs recommend `allowedTools` over broad permission modes for MCP access, because a wildcard grants exactly one server and nothing more.

You can also declare the server in a `.mcp.json` file at the project root. The SDK loads it when the project setting source is enabled, which it is by default, and `${DIZO_API_KEY}` in the file expands from the environment at runtime so the key stays out of the file.

If you register the server under another key, such as `dizo-prod`, the tool names change with it, so update `allowed_tools` to match. Characters such as dots and spaces in the key are replaced by underscores, which is one more reason to keep the key short and plain. A good habit is to log the `mcp__` tool names from the init message once, copy them into your allow-list, and keep that list in version control next to the agent's prompt.

## Authentication choices

Dizo supports OAuth 2.1 for MCP clients that run a browser sign-in, and a bearer key for everything else. The Agent SDK does not open a browser or run an interactive OAuth flow. If a server asks for authorization and the SDK has no token, it reports the server as `needs-auth` and the run continues without those tools. For Dizo, the simple path is an API key in `headers`.

Create a dedicated key for each agent in the console. Give it the `data:read` scope, a `max_credits_per_request`, daily and monthly credit caps, and an endpoint allow-list. If the agent only maps org charts and finds emails, allow just those endpoints. The [keys reference](/docs/keys) lists every field. Keys are read-only for billing by default, and only a key with `billing:write` can top up or change refills.

## Costing an agent run

Consider the TypeScript example: find who runs RevOps at one company and get a verified email. The agent calls the org chart for that domain filtered to the relevant department. Say it returns 6 people; org chart charges 1 credit per 25 results, so that is 0.24 credits. It then finds one email for 1 credit. The run costs 1.24 credits, about $0.03 at the $0.025 pay-as-you-go rate.

Scale it up. The Python example asks for the VP of Sales at 10 fintechs with emails. Using the decision-maker finder, 10 people returned cost 0.4 credits. If 8 emails are found, that adds 8 credits, and the 2 misses are free. Total 8.4 credits, about $0.21. Run the same job across 1,000 accounts with an 80 percent email hit rate and you get 40 credits for the finder plus 800 for emails: 840 credits, $21.00 at pay-as-you-go or $8.40 at the $0.010 top tier. The [pricing page](/pricing) has every tier.

## Two complete workflows

**Nightly enrichment worker.** A Python job pulls new CRM leads that have only an email address. For each one it runs `query()` with a narrow prompt asking Claude to identify the person and company and return JSON. `allowed_tools` contains only `mcp__dizo__dizo_email_to_profile` and `mcp__dizo__dizo_domain_to_company`. Email to profile is 2 credits only if found, domain to company 1 credit only if found, so 500 leads with a 70 percent match rate cost at most 350 × 3 = 1,050 credits.

**Sales-engineer assistant.** A TypeScript service exposes an internal chat endpoint. Each question becomes a `query()` with the Dizo server and the wildcard permission, but the key behind it has a 200-credit daily cap and no phone endpoint on its allow-list. The engineer can ask anything about accounts and people, and the worst day costs 200 credits, about $5.00 at the entry rate.

## Troubleshooting

Read the `system` message with subtype `init` at the start of each query. It lists each MCP server's status. `connected` means the key worked. `failed` usually means the URL is wrong or the network blocks it. `needs-auth` means the header was missing, so the SDK fell back to looking for an OAuth token. `pending` is not a failure on its own; the server may still be connecting.

If Claude says it cannot use a Dizo tool, check `allowed_tools` first, and remember that names follow the server key, then the tool name, joined by double underscores, so a server keyed as `dizo` gives `mcp__dizo__dizo_search`. A `402` from Dizo means a cap or the balance was reached; the error carries a plain-English `fix`. For rate limits, follow `error.retry_after` before retrying. Call `dizo_whoami`, which is free, to see what the key can do.

## Security practices

Keep the key in the environment or a secrets manager, and use the `${DIZO_API_KEY}` expansion in `.mcp.json` rather than pasting the value. Develop against a `dz_test_` key, which returns synthetic data and never spends credits, so you can iterate on prompts freely. Use one key per agent so usage is visible per workload and you can revoke one without touching the rest.

Prefer named tools over the wildcard in production. An agent that only needs emails has no reason to call the phone finder at 10 credits a number. [Sign up](/signup) for a live key, and use test keys while you build.

## FAQ

### What server type do I use for Dizo in the Agent SDK?
Use `type: "http"`, which is the streamable HTTP transport. The SDK's config type declares only `http` for code, while JSON config files also accept `streamable-http` as an alias.

### Why can Claude see the Dizo tools but not call them?
MCP tools need explicit permission in the SDK. Add `mcp__dizo__*` or specific tool names such as `mcp__dizo__dizo_find_email` to `allowed_tools`.

### Can the Agent SDK sign in to Dizo with OAuth?
The SDK does not run an interactive OAuth flow. Pass a Dizo API key in the `Authorization` header instead, or complete OAuth in your own app and pass the resulting token in `headers`.

### How do I keep an SDK agent from overspending?
Set caps on the key: max credits per request, a daily cap and a monthly cap, plus an endpoint allow-list. Add an account-level monthly cap too. When a cap is reached, calls return a 402 and nothing more is charged.

### Is a failed lookup charged?
No. Email, phone and profile lookups are charged only when they return a result, and searches charge per result returned. Counts and dry-run quotes are free.

### Can I share the Dizo config with my team?
Yes. Put the server in a project `.mcp.json` with `${DIZO_API_KEY}` as the header value. Each developer sets their own key in the environment, ideally a `dz_test_` key for local work.
