# Semantic Kernel + Dizo

> Add the Dizo MCP server to a Semantic Kernel agent as a plugin with MCPStreamableHttpPlugin, then call its tools like any kernel function.

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

## Steps
1. `pip install "semantic-kernel[mcp]"` and export `DIZO_API_KEY` plus your model provider key.
2. Open `MCPStreamableHttpPlugin` with the Dizo URL and an `Authorization` header.
3. Pass it to `ChatCompletionAgent(plugins=[...])`, or add it to a `Kernel` with `add_plugin`.
4. Call `await agent.get_response(...)` and the agent picks the Dizo functions it needs.

## Where to go
Adding MCP servers as plugins, including `MCPStreamableHttpPlugin`.

Open the Semantic Kernel MCP docs: https://learn.microsoft.com/en-us/semantic-kernel/concepts/plugins/adding-mcp-plugins

## agent.py
```
import asyncio, os
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.connectors.mcp import MCPStreamableHttpPlugin

async def main():
    async with MCPStreamableHttpPlugin(
        name="dizo",
        url="https://mcp.dizo.ai/mcp",
        description="B2B people, company, email and phone data",
        headers={"Authorization": f"Bearer {os.environ['DIZO_API_KEY']}"},
        load_prompts=False,
    ) as dizo:
        agent = ChatCompletionAgent(
            service=OpenAIChatCompletion(ai_model_id="gpt-4o"),
            name="Prospector",
            instructions="Count first. Call dizo_quote before any job over 100 credits.",
            plugins=[dizo],
        )
        response = await agent.get_response(messages="Who runs finance at ledgerline.io? Include a verified email.")
        print(response)

asyncio.run(main())
```

## Kernel instead of an agent
```
from semantic_kernel import Kernel

kernel = Kernel()
kernel.add_plugin(dizo)   # dizo = the connected MCPStreamableHttpPlugin
```

## Notes
- Dizo exposes tools, not prompts, so `load_prompts=False` skips a call you do not need.
- The example is Python. Check Microsoft's Semantic Kernel docs for the current MCP support in .NET and Java.
- Use a `dz_test_` key while building: synthetic data, no credits spent.

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


## What Semantic Kernel is

Semantic Kernel is Microsoft's open-source SDK for building AI agents and adding model-driven features to existing applications, with SDKs for Python, .NET and Java. Its central idea is the kernel: a container that holds AI services, such as a chat completion model, and plugins, which are groups of functions the model can call. Agents such as `ChatCompletionAgent` sit on top and handle conversation, threads and tool calling.

Plugins are how outside capabilities get in, and Semantic Kernel can build a plugin directly from an MCP server. In Python, the `semantic_kernel.connectors.mcp` module provides `MCPStdioPlugin` for local servers, `MCPSsePlugin` for SSE and `MCPStreamableHttpPlugin` for streamable HTTP. Dizo's [MCP server](/mcp) at `https://mcp.dizo.ai/mcp` uses streamable HTTP, so one plugin object gives an agent every Dizo tool as a kernel function.

## Why add Dizo to a Semantic Kernel app

Semantic Kernel is often chosen by teams already building on Microsoft's stack, adding agents to internal tools, CRMs and line-of-business apps. Those apps frequently need outside business data: who a contact is, what a company does, whether an email is real. Dizo supplies that with 850M professional profiles, 100M+ websites and companies, 800M verified emails and 550M mobiles and direct dials.

As a plugin, Dizo slots into whatever else the kernel already holds. An agent can call your own native plugin to read an account from your database, call a Dizo function to fill missing fields, and call another of your plugins to write the result back, all inside one `get_response`. Each Dizo tool description includes its credit cost, which the model reads alongside the function schema, and lookups that find nothing cost nothing.

## What you can ask the agent to do

Once the plugin is attached, these requests map cleanly to Dizo functions:

- "Who runs finance at ledgerline.io?" `dizo_org_chart` filtered by department, 1 credit per 25 people returned.
- "Include a verified email." `dizo_find_email`, 1 credit only when found.
- "Fill in this account's industry, headcount and HQ." `dizo_enrich_company`, 1 credit if matched.
- "Who is this caller?" `dizo_phone_to_profile`, 2 credits only when found, with line type and DNC flag.
- "How many IT directors work at Canadian universities?" `dizo_count`, free.
- "Build a list of 200 RevOps leaders at Series B SaaS companies with emails." `dizo_create_list`, billed at search and lookup rates for data found.
- "What is this key allowed to do?" `dizo_whoami`, free.

## Setup walkthrough

Install Semantic Kernel with the MCP extra: `pip install "semantic-kernel[mcp]"`. Without the extra, the MCP connector module is not available. Export `DIZO_API_KEY` and whatever your chat completion service needs; the example uses `OpenAIChatCompletion`, which reads the OpenAI key from the environment. Any other chat completion service Semantic Kernel supports works the same way.

Create the plugin with `MCPStreamableHttpPlugin(name="dizo", url="https://mcp.dizo.ai/mcp", headers={...})`. The `headers` argument is where the `Authorization: Bearer` value goes. Use it as an async context manager so the connection opens and closes cleanly, or call `await plugin.connect()` and `await plugin.close()` yourself. Set `load_prompts=False`: Dizo publishes tools, not prompts, and Microsoft's docs note that loading prompts from a server without any can hang. You can also set `request_timeout` if your network is slow.

Pass the connected plugin to `ChatCompletionAgent(plugins=[dizo])`, or add it to a `Kernel` with `kernel.add_plugin(dizo)` if you build agents from a shared kernel. Then call `await agent.get_response(messages=...)`. For multi-turn conversations, pass the returned `response.thread` into the next call. [Sign up](/signup) for a live key, with 250 free credits on a work email, and `dz_test_` keys work now with synthetic data.

## Seeing what the agent called

When you are tuning an agent that spends real credits, you want to see each function call, not just the final answer. Semantic Kernel's `ChatCompletionAgent` supports an `on_intermediate_message` callback on `invoke` and `invoke_stream`. It receives `FunctionCallContent` items with the function name and arguments, and `FunctionResultContent` items with what came back.

Log those during development. You will quickly see whether the agent counts before it searches, whether it asks for 25 results or 1,000, and whether it calls the phone finder when you only wanted emails. Function names arrive prefixed with the plugin name, so Dizo calls are easy to filter. Logging the `credits_used` value from each result gives you per-run cost without touching billing.

Once behaviour is right, keep a lighter version of the callback in production that records function name, arguments and credits. That gives you an audit trail of what each agent bought and why, which pairs well with the per-key usage Dizo reports in `GET /v1/billing`.

## Mixing Dizo with your own plugins

The strength of Semantic Kernel is that Dizo is one plugin among several. A typical internal agent holds a native plugin that reads and writes your CRM or database, the Dizo plugin for outside data, and perhaps a third for email or calendar. The model sees all of their functions together and chains them, so 'complete this account and add the CFO as a contact' becomes a read, two Dizo calls and a write.

Keep the boundary clear in your instructions. Tell the agent to check your own data first and call Dizo only for gaps, so it never pays to look up a contact you already hold. Add existing customers and open opportunities to the free [suppression list](/docs/suppression), which drops them from every Dizo search and lookup before billing. That way even a careless prompt cannot buy records you own.

## Controlling spend

Give the Semantic Kernel app its own Dizo key, created in the console or through the [keys endpoint](/docs/keys). Set a maximum credits per request, a daily cap, a monthly cap and an endpoint allow-list. If the app only needs company enrichment and email finding, allow just those paths, and the plugin's other functions return an error instead of spending. The account-level monthly USD cap stops every key with `402 monthly_cap_reached`, and alerts go out at 50%, 80% and 100%.

In the agent's instructions, state the budget rules: count with `dizo_count` before searching, call `dizo_quote` before anything over 100 credits, and stop if `dizo_balance` shows spend near the cap. The REST API also accepts `max_credits` and `"dry_run": true` on every billable call if you script jobs outside the agent. Tier prices are on [pricing](/pricing).

## Example workflows

**CRM record completion.** Your native plugin reads 50 accounts with missing firmographics. The agent calls `dizo_enrich_company` on each; if 46 match, that is 46 credits, or $1.15 at $0.025 a credit. Your plugin writes the fields back. For thousands of records, run the same thing through the REST batch endpoint on a schedule instead.

**Meeting prep inside an internal tool.** A user opens an account page and asks for the finance team. The agent calls `dizo_org_chart` for 25 people in finance (1 credit) and `dizo_find_email` for the top two (2 credits if both are found), then summarises. About 3 credits per brief.

**Inbound call lookup.** A support or sales app receives a phone number. The agent calls `dizo_phone_to_profile` (2 credits if found), gets the person, employer, line type and DNC flag, and shows the rep who is calling before they pick up.

## Troubleshooting

If the plugin has no functions, check the URL is exactly `https://mcp.dizo.ai/mcp`, that `headers` includes `Authorization` with the `Bearer ` prefix, and that you are using the plugin inside its `async with` block or after `connect()`. A 401 means a missing or wrong key. If startup hangs, set `load_prompts=False` as in the example.

A `402` result means a cap was hit on the request, the key or the account; the error includes a plain-English `fix`. Rate-limit errors mean too many concurrent calls on one key. If the agent picks the wrong function, make the instructions more explicit about order, and log intermediate messages to see its reasoning.

## Security practices

Load the Dizo key from the environment, Azure Key Vault or another secrets store, never from source. One key per application or agent makes spend visible and revocation painless. Keys are hashed at rest on Dizo's side and the secret is shown once at creation, so store it immediately.

Keep `dz_test_` keys for development and tests, and live keys for production only. Agent keys should not hold `billing:write`; MCP and new keys are read-only for billing by default, and the account owner can lock billing completely. Dizo handles business-context data only and honours opt-outs within 24 hours; see the [trust page](/trust) for details.

## FAQ

### Which Semantic Kernel class connects to Dizo?
`MCPStreamableHttpPlugin` from `semantic_kernel.connectors.mcp`, installed with the `semantic-kernel[mcp]` extra. It takes a name, the Dizo URL and an optional `headers` dict.

### Can I use it with a Kernel instead of an agent?
Yes. Call `kernel.add_plugin(dizo)` on the connected plugin and the Dizo tools become kernel functions. Agents built from that kernel can then call them.

### Does this work in .NET or Java?
This page covers the Python SDK, where the MCP plugin classes are documented. Check Microsoft's Semantic Kernel docs for the current state of MCP support in .NET and Java.

### Why set load_prompts to False?
Dizo's server exposes tools, not prompts. Microsoft's docs note that loading prompts from a server without any can hang, so turning it off avoids a wasted call.

### How do I stop the agent overspending?
Use a dedicated key with per-request, daily and monthly caps and an endpoint allow-list, and set an account monthly cap. Tell the agent to quote with `dizo_quote` before large jobs.

### Is there a Dizo plugin package for Semantic Kernel?
No. Semantic Kernel builds the plugin from the Dizo MCP server at runtime, so the functions and their descriptions always match what the server offers.
