Menu

Integrations / Frameworks & SDKs

Microsoft Agent Framework

MillionShort search for Microsoft Agent Framework agents, as an MCP tool over streamable HTTP or a function tool, in Python.

Copy as MarkdownOpen in ChatGPT (opens in a new tab)Open in Claude (opens in a new tab)

MCPPythonNothing of ours to installWorks with no keyChecked 2026-11-19

Agent Framework's MCPStreamableHTTPTool connects to the MillionShort MCP server and gives an agent its tools: search, get_domain_info, list_sources and the tools of the other endpoints, such as extract, places, map and crawl (the MCP page lists them all). With no MCP at all, a Python function that calls the API does the same job. This page covers the Python package.

1Install

Python
pip install agent-framework
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY

The full package includes MCP support (the MCP Python SDK 2.x). On a minimal install, add "mcp>=2.2.0,<3", as the framework's docs say. The examples use OpenAIChatClient, which reads your OpenAI key from OPENAI_API_KEY and the model name from OPENAI_CHAT_MODEL (for example gpt-4o-mini, as in the framework's docs); any chat client works the same way. Get a MillionShort key in the dashboard; an agent can ask for a trial key by itself.

2Connect the server

The key is fixed, so it goes in static_headers. Passing the tool to the agent and opening the agent with async with connects the tool too, and closes it at the end.

Python
import asyncio
import os

from agent_framework import Agent, MCPStreamableHTTPTool
from agent_framework.openai import OpenAIChatClient


async def main():
    async with Agent(
        client=OpenAIChatClient(),
        name="Researcher",
        instructions="Use the millionshort search tool for anything recent or niche, and cite the URLs.",
        tools=MCPStreamableHTTPTool(
            name="millionshort",
            url="https://mcp.millionshort.com/mcp",
            static_headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
            load_prompts=False,
        ),
    ) as agent:
        result = await agent.run("Find independent blogs about home espresso, without the 1,000 most popular sites.")
        print(result.text)


asyncio.run(main())

Without a key, leave static_headers out: the agent gets search and list_sources.

3Give the tools to an agent

The tool can also be given to a single run instead of to the agent, as the framework's MCP examples do. Open the tool and the agent together, then pass tools to run:

Python
import asyncio
import os

from agent_framework import Agent, MCPStreamableHTTPTool
from agent_framework.openai import OpenAIChatClient


async def main():
    async with (
        MCPStreamableHTTPTool(
            name="millionshort",
            url="https://mcp.millionshort.com/mcp",
            static_headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
            load_prompts=False,
        ) as millionshort,
        Agent(client=OpenAIChatClient(), name="Researcher", instructions="Cite the URLs you use.") as agent,
    ):
        result = await agent.run("Find independent blogs about home espresso.", tools=millionshort)
        print(result.text)


asyncio.run(main())

When the key differs from run to run (one per user), use header_provider instead of static_headers: a function that returns the headers for each run. The agent has only the tools you give it.

4Check it works

Run the example: the answer should cite pages. To see the tools without a model, open the tool and list its functions:

Python
import asyncio
import os

from agent_framework import MCPStreamableHTTPTool


async def main():
    async with MCPStreamableHTTPTool(
        name="millionshort",
        url="https://mcp.millionshort.com/mcp",
        static_headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
        load_prompts=False,
    ) as millionshort:
        print([function.name for function in millionshort.functions])  # search, get_domain_info, list_sources, ...


asyncio.run(main())

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

The @tool decorator names the function for the model; the docstring or description and the type hints say how to call it:

Python
import asyncio
import json
import os
import urllib.request

from agent_framework import Agent, tool
from agent_framework.openai import OpenAIChatClient


@tool(name="millionshort_search", description="Search the web with MillionShort. remove_top_sites leaves out the N most popular sites.")
def millionshort_search(query: str, remove_top_sites: int = 1000, num_results: int = 5) -> str:
    request = urllib.request.Request(
        "https://api.millionshort.com/v1/search",
        data=json.dumps({"query": query, "remove_top_sites": remove_top_sites, "num_results": num_results}).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 = Agent(client=OpenAIChatClient(), name="Researcher", tools=millionshort_search)
    print((await agent.run("Find independent blogs about home espresso.")).text)


asyncio.run(main())

MCP configuration

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

ModeHowWhat the agent gets
API keySend Authorization: Bearer ms-YOUR_API_KEYEvery tool, at your plan's limits; calls use your credits
No keySend no Authorization headersearch, list_sources and a few more; one source and up to 5 results a search, 10 free searches a day

Tools

ToolWhat it doesWithout a keyCost
searchSearches the web and the specialist sources, with the popularity, domain, page-type, topic, site and date filtersYes: one source, up to 5 results1 credit per source searched, first 10 results
get_domain_infoPopularity and risk for up to 25 sitesNo1 credit
list_sourcesThe sources, page types and topics search acceptsYes: source namesFree
The tools of the other endpointsextract, map, crawl, places and more: the MCP page lists themA few, such as placesWhat the API call behind each costs

Settings

VariableMeaning
MILLIONSHORT_API_KEYYour key, read by the examples above. Leave static_headers out for the no-key mode

MCPStreamableHTTPTool also takes request_timeout (seconds, 30 by default), allowed_tools to load only the tools you name, and tool_name_prefix to put a prefix before each tool's name.

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 has the numbers.

When it fails

What you seeWhyFix
The server does not connect, or no tools are listedThe address or the transport is not the one the server speaksUse 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 upAdd a key: it is free in the dashboard
INSUFFICIENT_CREDITSThe plan's credits are used upStop and add credits; retrying does not help
The agent answers from memory, or uses another searchNothing told it when to use this oneTurn off its own search where it can be (this page says how), and add the line for its instructions
"Failed to create MCP session: The API key was not accepted."The key is wrong, or sent without Bearer Check MILLIONSHORT_API_KEY and the header, or leave static_headers out to use the no-key mode
"Model must be specified via the 'model' parameter"OpenAIChatClient() found no model nameSet OPENAI_CHAT_MODEL, or pass model

This page as Markdown ยท llms.txt