Now open. Sign up with a work email and get 250 free credits, no card. Get your free API key →
FOR AGENTSSkip the HTML: this page as .md · llms.txt · openapi.json · MCP mcp.dizo.ai/mcp
Integrations / Agent frameworks
// mcp client

Dizo + smolagents

Load the Dizo MCP tools into a smolagents CodeAgent or ToolCallingAgent with MCPClient over streamable HTTP.

No native app needed. This uses the hosted Dizo MCP server at https://mcp.dizo.ai/mcp. Use a dz_test_ key while you build: it returns synthetic data and costs nothing.
Official setup guide

MCPClient / ToolCollection.from_mcp with streamable-http.

https://huggingface.co/docs/smolagents/tutorials/tools#use-tools-from-an-mcp-server

Steps

  1. pip install "smolagents[mcp]" and export DIZO_API_KEY.
  2. Open MCPClient with a dict: the Dizo url, transport: "streamable-http" and an Authorization header.
  3. Pass the tools to CodeAgent (or ToolCallingAgent) and call agent.run(...).
  4. Set structured_output=True so the agent sees the shape of Dizo's JSON results.
import os
from smolagents import CodeAgent, InferenceClientModel, MCPClient

server = {
    "url": "https://mcp.dizo.ai/mcp",
    "transport": "streamable-http",
    "headers": {"Authorization": f"Bearer {os.environ['DIZO_API_KEY']}"},
}

with MCPClient(server, structured_output=True) as tools:
    agent = CodeAgent(tools=tools, model=InferenceClientModel(), max_steps=8)
    agent.run(
        "Use dizo_find_email to find work emails for these 3 people at ledgerline.io "
        "and return only the ones found: Maya Okafor, Jon Ortiz, Priya Shah"
    )
client = MCPClient(server, structured_output=True)
try:
    tools = client.get_tools()
    # build and run agents here
finally:
    client.disconnect()

Notes

Endpoints used

smolagents in brief, and what makes it different

smolagents is Hugging Face's small, open-source Python library for building agents. Its signature idea is the CodeAgent: instead of emitting one JSON tool call at a time, the model writes short Python snippets that call tools as functions, and smolagents executes them. That lets an agent loop over a list, branch on a result or combine several tool calls in a single step. For agents that prefer the classic pattern, ToolCallingAgent makes one structured call per step.

MCP support comes through MCPClient (and the older ToolCollection.from_mcp). For a remote server you pass a dictionary with a url and transport: "streamable-http", and smolagents turns the server's tools into smolagents tools. Pointed at https://mcp.dizo.ai/mcp, that gives a CodeAgent direct access to Dizo's people, company, email and phone tools, callable from the Python it writes.

Why a code-writing agent needs a careful data source

A CodeAgent is efficient precisely because it can write for row in rows: dizo_find_email(...). That is also why spend control matters more here than in a one-call-per-step agent. A single step can make hundreds of tool calls, and a model that misreads a list can loop over far more records than you intended.

Dizo is designed with that caller in mind. Every tool description includes its credit cost, so the model can see that a phone lookup is 10 credits and an email lookup is 1. Lookups that find nothing are free, so retries on missing data do not cost anything. dizo_quote returns the exact cost of any call without spending, and per-key caps stop a runaway loop at a number you chose. Read the MCP server page for the full tool list and prices.

What a smolagents agent can do with Dizo

Jobs that suit a code-writing agent in particular:

  • Find work emails for a CSV of names and domains with dizo_find_email and write back only the rows that returned an address.
  • Search for 200 heads of data engineering with dizo_search, then keep only companies above a headcount threshold, in code.
  • For each of 30 domains, call dizo_enrich_company and compute a simple fit score from headcount and technologies.
  • Find an email for every person in a list, skipping rows that already have one.
  • Call dizo_count on several segment definitions for free and print a comparison table.
  • Check dizo_whoami first and stop early if the remaining budget is below what the job needs.

Connecting with MCPClient step by step

Install the MCP extra: pip install "smolagents[mcp]". Export DIZO_API_KEY, and start with a dz_test_ key. Test keys return synthetic data and never spend credits, which matters with a CodeAgent because early prompts often produce loops you did not expect.

Build the server dictionary with three entries: url set to https://mcp.dizo.ai/mcp, transport set to streamable-http, and headers holding Authorization: Bearer plus the key. The smolagents tutorial explains that this dictionary is passed through to the MCP SDK's streamable HTTP client, which is where headers is read; the reference documents url and transport as the minimum keys. If your installed version does not forward headers, check the smolagents MCP docs for your release.

Open the client as a context manager, with MCPClient(server, structured_output=True) as tools:, and pass tools to CodeAgent(tools=tools, model=InferenceClientModel()). Then call agent.run(...). If you cannot use a with block, call get_tools() and make sure disconnect() runs in a finally clause, as the smolagents docs recommend.

MCPClient also accepts a list of server parameters, so one agent can hold Dizo alongside another MCP server, such as an internal CRM tool. When you do this, be explicit in the task prompt about which server owns which job. An agent told to "look up the account" might otherwise query Dizo for data you already hold in your own system, and pay credits for it. Naming the tools in the prompt, for example dizo_find_email only for rows without an email in the CRM, keeps the boundary clear.

Structured output and why to turn it on

smolagents supports MCP output schemas when you pass structured_output=True. With it enabled, the agent's system prompt includes the JSON shape of each tool's output, so the model knows ahead of time that a search returns records with fields it can index into, rather than an opaque string it has to parse. That makes the generated code shorter and less error-prone.

The docs note that structured_output currently defaults to False for backwards compatibility, with a plan to change the default later, and recommend setting it explicitly. With Dizo, set it to True. Results such as people records, company profiles and email confidence scores are structured JSON, and an agent that can see the fields will filter and join them in code more reliably.

Controlling spend in a code-writing loop

Start with instructions in the task prompt: call dizo_whoami first, call dizo_quote before any job likely to exceed about 100 credits, process at most a stated number of rows, and stop on a 402. Also cap the agent's steps with max_steps, which limits how many think-and-act cycles it gets.

Then make the key the real boundary. Create a key with data:read scope, max_credits_per_request, a daily cap, a monthly cap and an endpoint allow-list. MCP connections default to data:read and a 500-credit per-call limit unless changed. A daily cap is the most useful guard for CodeAgents, because it bounds the total cost of a bad loop no matter how many small calls it makes. The account monthly cap returns 402 monthly_cap_reached for everything once hit. Field details are in the keys reference.

For lists larger than about 50 records, consider asking the agent to call dizo_batch once instead of looping. A batch runs up to 10,000 lookups asynchronously at the same per-item price, and it accepts max_credits as a ceiling for the whole job.

Worked examples with costs

Bounce recovery before a send. A marketer hands the agent 1,000 contacts whose emails bounced. Dizo does not verify existing lists, so the agent re-identifies people instead: dizo_enrich_person on each (2 credits if matched), then dizo_find_email at the current employer (1 credit if found). If 600 match and 450 new emails come back, that is 1,200 plus 450, or 1,650 credits: $41.25 at the $0.025 pay-as-you-go rate, or $34.65 at the $0.021 Builder rate. Unmatched contacts are free and go to the suppression list. The email finder docs explain the response.

Search and filter in code. The agent calls dizo_search for 1,000 RevOps leaders at US software companies: 1,000 results at 1 credit per 25 is 40 credits, or $1.00 at $0.025. It then filters to companies with 200 to 2,000 employees in Python and finds emails for the 300 that remain. Assume 255 are found: 255 credits, since misses are free. The whole job is 295 credits, about $7.38 at $0.025. See pricing for the volume tiers.

Troubleshooting

Problems you may hit and what they usually mean:

  • Auth errors on connect: headers is missing, lacks the Bearer prefix, or the key is not set in the running process.
  • Tools load but calls fail with permission errors: the key's endpoint allow-list does not include that tool's endpoint.
  • The agent loops over far more rows than intended: lower max_steps, state a row limit in the task and rely on the key's daily cap.
  • The agent struggles to parse results: set structured_output=True on the client.
  • Connections left open after errors: use the context manager, or disconnect() in a finally block.
  • 402 monthly_cap_reached or rate limits: stop on the 402; for rate limits, retry only when error.retryable is true, after error.retry_after seconds.

Security practices

smolagents' own docs warn to connect only to MCP servers you trust and to proceed with care even with remote ones. On the Dizo side, keep the key in the environment, never in the task prompt, since a CodeAgent may echo prompt text into the code it writes and its logs. Give each agent its own key so usage is separable and revocable. Agent keys should never hold billing:write.

Run development against dz_test_ keys and switch to live keys only in production. Sign up for a live key. Work email signups get 250 free credits and no card is needed.

Frequently asked questions

Should I use MCPClient or ToolCollection.from_mcp?

Both load tools from an MCP server. MCPClient is the newer interface and gives you control over the connection lifecycle. ToolCollection.from_mcp requires trust_remote_code=True to load tools.

How do I pass my Dizo key to smolagents?

Add a headers entry with Authorization: Bearer and your key to the server dictionary, alongside url and transport. The dictionary is passed through to the MCP SDK's streamable HTTP client.

Is CodeAgent or ToolCallingAgent better with Dizo?

CodeAgent is efficient for list work because it can loop and filter in code, but it can also make many calls in one step, so set tight key caps. ToolCallingAgent makes one call per step, which is easier to follow and audit.

Does the agent pay for lookups that find nothing?

No. Email, phone and profile lookups are free when nothing is found, and searches charge only for results returned. Count is always free, and person enrich charges only when a person is matched.

How do I stop a loop from draining the balance?

Set a daily cap and max_credits_per_request on the key, limit max_steps on the agent, and set an account monthly cap. Once the cap is reached, calls return 402 monthly_cap_reached.

Is there a Dizo tool on the Hugging Face Hub?

No. There is no native Dizo tool or Hub listing. You connect smolagents to the hosted Dizo MCP server with its standard MCP support.

Last reviewed 2026-11-24.

Related integrations