Menu

Integrations / Frameworks & SDKs

Haystack

MillionShort search for Haystack agents and pipelines, through the MCP integration or a tool of your own.

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

Haystack's MCP integration (mcp-haystack) loads the MillionShort MCP server's tools into one MCPToolset, which an Agent or a chat generator takes like any other toolset: 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 @tool function that calls the API does the same job.

1Install

Python
pip install mcp-haystack haystack-ai
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY

The examples use OpenAIChatGenerator, which reads your OpenAI key from OPENAI_API_KEY; any Haystack chat generator works the same way. Get a MillionShort key in the dashboard; an agent can ask for a trial key by itself.

2Connect the server

StreamableHttpServerInfo holds the address. Its token is sent as Authorization: Bearer <token>, and Secret.from_env_var reads it from the environment when the connection opens, so the key never sits in your code or in a serialised pipeline.

Python
from haystack.utils import Secret
from haystack_integrations.tools.mcp import MCPToolset, StreamableHttpServerInfo

millionshort = MCPToolset(
    server_info=StreamableHttpServerInfo(
        url="https://mcp.millionshort.com/mcp",
        token=Secret.from_env_var("MILLIONSHORT_API_KEY"),
    ),
)

Without a key, leave token out: the toolset then has search and list_sources.

3Give the tools to an agent

Pass the toolset as the agent's tools. The agent warms it up (connects and lists the tools) before it runs.

Python
from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.utils import Secret
from haystack_integrations.tools.mcp import MCPToolset, StreamableHttpServerInfo

millionshort = MCPToolset(
    server_info=StreamableHttpServerInfo(url="https://mcp.millionshort.com/mcp", token=Secret.from_env_var("MILLIONSHORT_API_KEY")),
)
agent = Agent(
    chat_generator=OpenAIChatGenerator(),
    tools=millionshort,
    system_prompt="Use the millionshort search tool for anything recent or niche, and cite the URLs.",
)
response = agent.run(messages=[ChatMessage.from_user("Find independent blogs about home espresso, without the 1,000 most popular sites.")])
print(response["last_message"].text)

To give the agent fewer tools, name them: MCPToolset(server_info=..., tool_names=["search"]). Haystack agents have no web search of their own, so there is nothing to turn off.

4Check it works

Run the example: the answer should cite pages, and response["messages"] holds the call to search. To see the tools without a model, warm the toolset up yourself and list it:

Python
from haystack.tools import warm_up_tools
from haystack.utils import Secret
from haystack_integrations.tools.mcp import MCPToolset, StreamableHttpServerInfo

millionshort = MCPToolset(
    server_info=StreamableHttpServerInfo(url="https://mcp.millionshort.com/mcp", token=Secret.from_env_var("MILLIONSHORT_API_KEY")),
)
warm_up_tools(millionshort)
print([tool.name for tool in millionshort])  # search, get_domain_info, list_sources, ...
millionshort.close()

If the model answers from memory, say when to search in its system prompt:

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 turns a function into a Haystack Tool, with its parameters and docstring as the description the model reads:

Python
import json
import os
import urllib.request

from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack.dataclasses import ChatMessage
from haystack.tools import tool


@tool
def millionshort_search(query: str, remove_top_sites: int = 1000, num_results: int = 5) -> str:
    """Search the web with MillionShort. remove_top_sites leaves out the N most popular sites."""
    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])


agent = Agent(chat_generator=OpenAIChatGenerator(), tools=[millionshort_search])
print(agent.run(messages=[ChatMessage.from_user("Find independent blogs about home espresso.")])["last_message"].text)

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 Secret.from_env_var and by the function tool. Leave token out for the no-key mode

StreamableHttpServerInfo also takes timeout (seconds, 30 by default). MCPToolset takes connection_timeout and invocation_timeout (30 seconds each by default).

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
"None of the following authentication environment variables are set"Secret.from_env_var is strict: it fails when MILLIONSHORT_API_KEY is missingExport the key, or leave token out for the no-key mode
A chat generator, outside an agent, sees no MillionShort toolsOnly the Agent warms the toolset up by itselfCall warm_up_tools(toolset) from haystack.tools first

This page as Markdown ยท llms.txt