# PraisonAI

MillionShort search for PraisonAI agents, by giving MCP the server's URL.

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.

PraisonAI's `MCP` class takes the MillionShort MCP server's URL 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](https://millionshort.com/docs/mcp#tools) lists them all). Without MCP, a plain Python function as a tool does the same job.

## 1. Install

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

Install the `mcp` extra. PraisonAI's streamable HTTP client uses a function of the MCP Python SDK that SDK 2.0 removed, and the extra pins `mcp>=1.20.0,<2`. If something else in your environment upgraded `mcp` to 2.x, connecting fails until you run `pip install "mcp<2"`; we checked both with `praisonaiagents` 1.7.24.

With no model set, PraisonAI uses `gpt-4o-mini` when OPENAI_API_KEY is set (OPENAI_MODEL_NAME overrides it), or pass `llm=` to the agent. 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

`MCP` picks the transport from the URL: an address ending in `/mcp` is streamable HTTP. PraisonAI uses the URL exactly as given, so keep the `/mcp` path. The key goes in `headers`; without a key, leave `headers` out.

```python Python
import os

from praisonaiagents import MCP

millionshort = MCP(
    "https://mcp.millionshort.com/mcp",
    headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
    timeout=60,
)
```

## 3. Give the tools to an agent

Pass the `MCP` object as the agent's tools:

```python Python
import os

from praisonaiagents import MCP, Agent

agent = Agent(
    name="Researcher",
    instructions="Use the millionshort search tool for anything recent or niche, and cite the URLs.",
    tools=MCP(
        "https://mcp.millionshort.com/mcp",
        headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
        timeout=60,
    ),
)
agent.start("Find independent blogs about home espresso, without the 1,000 most popular sites.")
```

`allowed_tools=["search"]` on `MCP` limits the agent to the tools you name.

## 4. Check it works

Ask the agent "List the tools you have": it should name `search`, `get_domain_info`, `list_sources` and the tools of the other endpoints ([the MCP page](https://millionshort.com/docs/mcp#tools) lists them); with no key, fewer, `search` and `list_sources` among them. To see them without a model:

```python Python
import os

from praisonaiagents import MCP

millionshort = MCP("https://mcp.millionshort.com/mcp", headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"}, timeout=60)
print([tool["function"]["name"] for tool in millionshort.to_openai_tool()])
```

If the agent 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 plain function with type hints and a docstring works as a PraisonAI tool. This one calls `POST /v1/search`:

```python Python
import json
import os
import urllib.request

from praisonaiagents import Agent


def millionshort_search(query: str, remove_top_sites: int = 1000) -> 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": 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])


agent = Agent(name="Researcher", instructions="Search before you answer, and cite the URLs.", tools=[millionshort_search])
agent.start("Find independent blogs about home espresso.")
```

## 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 |

PraisonAI's debug logs hide credentials in URLs but not in headers, so keep the key in the environment and the logs to yourself.

## 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 fails with "does not provide the Streamable HTTP client" | MCP Python SDK 2.x is installed | `pip install "mcp<2"`, or reinstall `praisonaiagents[mcp]` |
| "Session terminated" | The URL has no `/mcp` path, so the request went to `/` | Use `https://mcp.millionshort.com/mcp` exactly |

## Related

- [Agent tool use](https://millionshort.com/docs/search/guides/agent-tool-use): when to give a model tools, and what to tell it.
- [CAMEL-AI](https://millionshort.com/docs/integrations/camel-ai) and [Langroid](https://millionshort.com/docs/integrations/langroid): the same server in other Python agent frameworks.
- [MCP server](https://millionshort.com/docs/mcp) and [Filters for agents](https://millionshort.com/docs/search/filters).
- PraisonAI's own documentation, read on 2026-11-19: [MCP transports](https://praison.ai/docs/mcp/transports), [MCP](https://praison.ai/docs/features/mcp/).
