# Semantic Kernel

MillionShort search for Semantic Kernel agents, as an MCP plugin over streamable HTTP or a plugin of your own, in Python.

MCP · Python · Nothing of ours to install · Works with no key · Checked 2026-11-19

> **For agents.** Read the API key from the `MILLIONSHORT_API_KEY` environment variable. Never print it; where a client needs it in a settings file, use a file that is not committed.
> The MCP address is https://mcp.millionshort.com/mcp (streamable HTTP; send `Authorization: Bearer <key>`, or no header for the no-key mode).
> On `INSUFFICIENT_CREDITS` stop and ask a person; on `RATE_LIMITED` or `CAPACITY` wait the `Retry-After` seconds, then retry once.
> Set-up steps written for agents: https://millionshort.com/docs/auth.md. Every integration: https://millionshort.com/docs/integrations.md.

Semantic Kernel turns an MCP server into a plugin: `MCPStreamableHttpPlugin` connects to the MillionShort MCP server and its tools become the plugin's functions: `search`, `get_domain_info`, `list_sources` and the tools of the other endpoints, such as `extract`, `places`, `map` and `crawl` ([the MCP page](https://millionshort.com/docs/mcp#tools) lists them all). Give the plugin to a `ChatCompletionAgent` or add it to a kernel. With no MCP at all, a plugin class whose `kernel_function` calls the API does the same job. This page covers Python: Semantic Kernel's MCP documentation for .NET and Java is not published yet.

## 1. Install

```bash Python
pip install "semantic-kernel[mcp]"
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY
```

Semantic Kernel keeps the MCP Python SDK below version 2, so install it in its own environment, apart from packages that need the SDK 2.x. The examples use `OpenAIChatCompletion`, which reads your OpenAI key from OPENAI_API_KEY and the model name from OPENAI_CHAT_MODEL_ID (or a `.env` file); any chat completion service works the same way. Get a MillionShort key in the [dashboard](https://millionshort.com/app/); an agent can ask for a [trial key](https://millionshort.com/docs/api-reference/agent-key) by itself.

## 2. Connect the server

`async with` opens the connection and loads the tools as functions; the plugin closes when the block ends. `load_prompts=False` skips asking for prompts, which the server does not offer.

```python Python
import asyncio
import os

from semantic_kernel import Kernel
from semantic_kernel.connectors.mcp import MCPStreamableHttpPlugin


async def main():
    async with MCPStreamableHttpPlugin(
        name="millionshort",
        description="MillionShort web search",
        url="https://mcp.millionshort.com/mcp",
        headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
        load_prompts=False,
    ) as millionshort:
        kernel = Kernel()
        kernel.add_plugin(millionshort)
        print(list(kernel.plugins["millionshort"].functions))


asyncio.run(main())
```

Without a key, leave `headers` out: the plugin has `search` and `list_sources`.

## 3. Give the tools to an agent

A `ChatCompletionAgent` takes the plugin in `plugins` and calls its functions when the model asks for them:

```python Python
import asyncio
import 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="millionshort",
        url="https://mcp.millionshort.com/mcp",
        headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
        load_prompts=False,
    ) as millionshort:
        agent = ChatCompletionAgent(
            service=OpenAIChatCompletion(),
            name="Researcher",
            instructions="Use the millionshort search tool for anything recent or niche, and cite the URLs.",
            plugins=[millionshort],
        )
        response = await agent.get_response(messages="Find independent blogs about home espresso, without the 1,000 most popular sites.")
        print(response.content)


asyncio.run(main())
```

The agent has only the plugins you give it, so nothing else competes with MillionShort for its searches.

## 4. Check it works

Run the example in step 2: it prints the plugin's functions: `search`, `get_domain_info`, `list_sources` and the tools of the other endpoints ([the MCP page](https://millionshort.com/docs/mcp#tools) lists them). Then run step 3: the answer should cite pages. If the model answers from memory, say when to search in its instructions:

> Use the MillionShort `search` tool for anything recent, niche, or that needs a source. To reach lesser-known sites, set `remove_top_sites` (for example 1000). Cite the URLs it returns.

## Without MCP: a function tool

A class with a `kernel_function` method is a plugin; its description and the `Annotated` hint tell the model how to call it:

```python Python
import asyncio
import json
import os
import urllib.request
from typing import Annotated

from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel.functions import kernel_function


class MillionShort:
    @kernel_function(name="search", description="Search the web with MillionShort, without the 1,000 most popular sites.")
    def search(self, query: Annotated[str, "What to search for"]) -> str:
        request = urllib.request.Request(
            "https://api.millionshort.com/v1/search",
            data=json.dumps({"query": query, "remove_top_sites": 1000, "num_results": 5}).encode(),
            headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"], "Content-Type": "application/json"},
        )
        with urllib.request.urlopen(request, timeout=30) as response:
            results = json.load(response)["data"]["results"]
        return json.dumps([{"title": r["title"], "url": r["url"], "snippet": r.get("snippet")} for r in results])


async def main():
    agent = ChatCompletionAgent(service=OpenAIChatCompletion(), name="Researcher", plugins=[MillionShort()])
    print((await agent.get_response(messages="Find independent blogs about home espresso.")).content)


asyncio.run(main())
```

## MCP configuration

The same address for every client: `https://mcp.millionshort.com/mcp`, streamable HTTP.

| Mode | How | What the agent gets |
|---|---|---|
| API key | Send `Authorization: Bearer ms-YOUR_API_KEY` | Every tool, at your plan's limits; calls use your credits |
| No key | Send no `Authorization` header | `search`, `list_sources` and a few more; one source and up to 5 results a search, 10 free searches a day |

## Tools

| Tool | What it does | Without a key | Cost |
|---|---|---|---|
| `search` | Searches the web and the specialist sources, with the popularity, domain, page-type, topic, site and date filters | Yes: one source, up to 5 results | 1 credit per source searched, first 10 results |
| `get_domain_info` | Popularity and risk for up to 25 sites | No | 1 credit |
| `list_sources` | The sources, page types and topics `search` accepts | Yes: source names | Free |
| The tools of the other endpoints | `extract`, `map`, `crawl`, `places` and more: [the MCP page](https://millionshort.com/docs/mcp#tools) lists them | A few, such as `places` | What the API call behind each costs |

## Settings

| Variable | Meaning |
|---|---|
| `MILLIONSHORT_API_KEY` | Your key, read by the examples above. Leave `headers` out for the no-key mode |

`MCPStreamableHttpPlugin` also takes `request_timeout` (seconds), so a server that does not answer cannot hold your app.

## Costs and limits

A tool call costs what the API call behind it costs: 1 credit per source searched for the first 10 results, 1 credit for a domain lookup, nothing for the list of sources, the price of the endpoint for the other tools, and nothing at all in the no-key mode. An agent that loops can make many calls: give it a step limit, and ask for fewer results when a few will do. [Credits and limits](https://millionshort.com/docs/credits-and-limits) has the numbers.

## When it fails

| What you see | Why | Fix |
|---|---|---|
| The server does not connect, or no tools are listed | The address or the transport is not the one the server speaks | Use exactly `https://mcp.millionshort.com/mcp` and the streamable HTTP transport (often called `http`), not SSE |
| `401` or "unauthorized" | The key is wrong, or it was sent without `Bearer ` | Send `Authorization: Bearer ms-...`, or leave the header out to use the no-key mode |
| "10 free searches a day without a key" | The no-key mode's daily searches are used up | Add a key: it is free in the [dashboard](https://millionshort.com/app/) |
| `INSUFFICIENT_CREDITS` | The plan's credits are used up | Stop and add credits; retrying does not help |
| The agent answers from memory, or uses another search | Nothing told it when to use this one | Turn off its own search where it can be (this page says how), and add the line for its instructions |
| Connecting hangs | Loading prompts can hang on a server that has none, as Semantic Kernel's docs note | Pass `load_prompts=False`, as above |
| Installing beside another framework downgrades or breaks the MCP SDK | Semantic Kernel needs the MCP Python SDK below 2, and some packages need 2.x | Give Semantic Kernel its own virtual environment |
| "The OpenAI model ID is required." | `OpenAIChatCompletion()` found no model id | Set OPENAI_CHAT_MODEL_ID, or pass `ai_model_id` |

## Related

- [Agent tool use](https://millionshort.com/docs/search/guides/agent-tool-use): when to give a model tools, and what to tell it.
- [Microsoft Agent Framework](https://millionshort.com/docs/integrations/microsoft-agent-framework): Microsoft's agent framework, with the same server.
- [Haystack](https://millionshort.com/docs/integrations/haystack): the same server in another Python framework.
- [MCP server](https://millionshort.com/docs/mcp) and [Filters for agents](https://millionshort.com/docs/search/filters).
- Semantic Kernel's own documentation, read on 2026-11-19: [Give agents access to MCP servers](https://learn.microsoft.com/en-us/semantic-kernel/concepts/plugins/adding-mcp-plugins), [ChatCompletionAgent](https://learn.microsoft.com/en-us/semantic-kernel/frameworks/agent/agent-types/chat-completion-agent).
