What Mastra is
Mastra is an open-source TypeScript framework for building AI agents, workflows and the apps around them. It gives you an Agent class with instructions, a model and tools; a workflow engine for multi-step jobs; memory; and local dev tooling for running and inspecting agents while you build. Because it is TypeScript first, it fits teams whose product and backend already live in Node.
Mastra's MCP support lives in the @mastra/mcp package. Its MCPClient takes a map of servers. A local server is described by a command; a remote one by a url plus a requestInit object whose headers are sent on every request. Dizo's MCP server at https://mcp.dizo.ai/mcp is remote and accepts a bearer key, so it needs only those two fields.
Why give a Mastra agent Dizo tools
TypeScript teams building agents into a product often need B2B data the model cannot supply: the right person at an account, a verified email, a company's size and stack. Dizo provides it through a single MCP connection, with 850M professional profiles, 100M+ websites and companies, 800M verified emails and 550M mobiles and direct dials behind it.
The MCP route saves you from writing a createTool wrapper per endpoint. listTools() returns every Dizo tool with its schema and description, and those descriptions include credit costs, so the model knows a count is free and a phone lookup is 10 credits if found. When Dizo adds a parameter, your agent sees it on the next connection without a code change. Lookups that find nothing are free, which matters when an agent is guessing at name spellings.
What your agent can do
These requests map directly to Dizo tools, shown here with Mastra's server-prefixed names:
- "How many VPs of Engineering work at devtools companies with 20 to 200 employees?"
dizo_dizo_count, free. - "Find 15 of them with emails."
dizo_dizo_searchwithinclude: ["email"]; 15 results cost 0.6 credits, plus 1 credit per email found. - "Enrich the company behind this sign-up."
dizo_dizo_domain_to_company, 1 credit if known. - "Who else is on their engineering team?"
dizo_dizo_org_chartfiltered by department. - "Who is this email?"
dizo_dizo_email_to_profile, 2 credits only when found. - "Watch these champions for job changes."
dizo_dizo_watch_job_changes; watching is free, 1 credit per change detected. - "How much budget is left this month?"
dizo_dizo_balance, free.
Setup walkthrough
Install the two packages with npm i @mastra/core @mastra/mcp and add DIZO_API_KEY to your server environment, such as a .env file that is not committed. Mastra agents usually live under src/mastra/agents, which is where the example file sits, but any server-side module works.
Create the client: new MCPClient({ servers: { dizo: { url: new URL("https://mcp.dizo.ai/mcp"), requestInit: { headers: { Authorization: ... } } } } }). Mastra sends static headers on every request to the server. If your token changes per request, for example per end user, Mastra's docs describe passing a custom fetch instead of static headers.
Then choose how the agent gets its tools. tools: await mcp.listTools() on the Agent uses one shared connection for the whole app, which suits an internal agent that always uses the same Dizo key. toolsets: await mcp.listToolsets() passed to generate or stream suits a multi-tenant app, where each customer's request should run with that customer's key. Call await mcp.disconnect() when you shut down.
Sign up for a live key. Work email signups get 250 free credits with no card. While you build, a dz_test_ key returns synthetic data and never spends credits, which is enough to build the agent end to end.
Multi-tenant apps and per-customer keys
If you are building a product where your users' agents look up B2B data, keep each customer's spend separate. Create a Dizo key per customer with the keys endpoint, each with its own daily and monthly caps and endpoint allow-list, and build a per-request MCPClient or custom fetch with that customer's key. Pass the resulting toolsets at call time rather than baking tools into the agent.
This gives you clean accounting: GET /v1/billing reports usage per key, so you can see what each customer consumed and bill or limit accordingly. It also contains failures. If one customer's agent hits its cap, it receives 402 errors while everyone else keeps working. Showing Dizo data to your own users at scale falls under Dizo's embed licence, so talk to Dizo's sales team before you ship that.
Agents or workflows: where Dizo calls belong
Mastra gives you both agents and workflows, and Dizo fits each differently. Use the agent when the request is open-ended and the model must decide what to look up: 'find me people like our last three customers' needs judgement about which tool to call and with what query. The Dizo tool descriptions, with their credit costs, give the model what it needs to choose.
Use a workflow step when the job is fixed. Enriching every new sign-up, verifying a list before a send or refreshing account data on a schedule has no decision in it, so a model in the loop only adds latency and token cost. Call the Dizo REST API at https://api.dizo.ai/v1 from the step directly, send an Idempotency-Key header on every POST so a retried step is never charged twice, and keep the agent for the parts that need reasoning.
Many production setups mix the two: a workflow does the deterministic enrichment, then hands the enriched record to an agent that writes the follow-up or decides the routing.
Controlling spend
Every key can carry a maximum credits per request, a daily cap, a monthly cap and an endpoint allow-list. An agent that should only research companies can be limited to company search, enrichment and domain lookups, and the phone finder will simply refuse it. Above all keys, the account's monthly USD cap stops calls with 402 monthly_cap_reached, with alerts at 50%, 80% and 100% by email or webhook.
In the agent's instructions, set the order: count, then quote, then search. The quote tool returns the exact credit cost of any call and spends nothing. If you script jobs outside the agent, the REST API accepts "dry_run": true and max_credits on every billable endpoint, and responses carry x-dizo-credits-used and x-dizo-credits-remaining headers you can log. Rates by tier are on pricing.
Example workflows
Product-led sign-up enrichment. A Mastra workflow fires on each new sign-up. A step calls the agent, which runs dizo_dizo_email_to_profile (2 credits if found) and dizo_dizo_domain_to_company (1 credit if found). For 300 sign-ups a month with a 70% match rate on both, that is 210 profiles at 2 credits and 210 companies at 1 credit: 630 credits, or $15.75 at $0.025 a credit.
Founder-led outbound. The agent counts a segment for free, searches 100 people (4 credits), finds emails (say 75 found, 75 credits) and drafts a first line for each. 79 credits for a list ready to review, under $2.
Champion tracking. A workflow adds your best customers' champions to a Dizo watchlist through the job-change tool. Watching is free; each detected move costs 1 credit and arrives as a webhook your workflow can route to the right rep.
Troubleshooting
If listTools() returns nothing or throws, check the URL is exactly https://mcp.dizo.ai/mcp and is wrapped in new URL(...), and that the header is Authorization with a Bearer prefix. A 401 means a missing, revoked or mistyped key. If the agent ignores your instructions about a tool, check you used the prefixed name, such as dizo_dizo_quote.
A 402 from a tool means a cap was hit on the request, key or account; the error body includes a plain-English fix. Rate-limit errors mean too many parallel calls on one key. For hundreds or thousands of lookups, call the REST batch endpoint from a workflow step instead of letting the agent loop.
Security practices
Keep the key server-side, in environment variables or your platform's secret store, and never in client bundles. Give each agent, environment and customer its own key so you can revoke one without touching the rest. Agent keys should not hold billing:write; keys are read-only for billing by default and the account owner can lock billing entirely.
Use dz_test_ keys in local dev, previews and CI, and live keys only in production. Dizo returns business-context data only, honours opt-outs within 24 hours and returns Do Not Call flags on phone numbers; the trust page covers the rest.
Frequently asked questions
Which Mastra package connects to Dizo?
@mastra/mcp, which provides MCPClient. Configure a server with the Dizo URL and pass your bearer key in requestInit.headers.
Why are the tool names prefixed?
Mastra names MCP tools serverName_toolName. If you register the server as dizo, the search tool appears as dizo_dizo_search. Use those names in your agent instructions.
Should I use listTools or listToolsets?
listTools() on the agent suits one shared connection and one key. listToolsets() at call time suits multi-tenant apps where each user or customer has their own Dizo key.
Can I run this in the browser?
No. Keep the Dizo key on the server. Call the agent from an API route or server action and return only the results to the client.
What does a lookup cost if nothing is found?
Nothing. Email, phone and profile lookups charge only when data is found, and searches charge 1 credit per 25 results returned.
Is there a Dizo package for Mastra?
No. Mastra's MCP client connects to the Dizo MCP server directly, so the tools and their schemas come from the server itself.
Last reviewed 2026-11-24.