# Anthropic

MillionShort search for Claude in the Messages API, through the MCP connector or a tool the SDK's tool runner calls, in Python and TypeScript.

MCP · Python and TypeScript · 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.

The MCP connector lets the Messages API connect to the MillionShort MCP server for you: Anthropic's servers list the server's tools ([the MCP page](https://millionshort.com/docs/mcp#tools) lists them) and call them while Claude works, in one request. If you would rather run the search in your own process, the SDK's tool runner calls a plain function for Claude and loops until it is done.

## 1. Install

```bash Python
pip install anthropic requests
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY
```

```bash TypeScript
npm install @anthropic-ai/sdk zod
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY
```

The SDK reads your Anthropic key from ANTHROPIC_API_KEY. 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. `requests` and `zod` are only for the tool runner further down.

## 2. Connect the server

The connector is in beta: call `client.beta.messages.create` with the `mcp-client-2025-11-20` beta. It takes two halves, and both are required: the server in `mcp_servers`, and an `mcp_toolset` in `tools` that names it. The key goes in `authorization_token`, which the connector sends to our server as a bearer token. Without a key, leave `authorization_token` out.

```python Python
import os

import anthropic

client = anthropic.Anthropic()
response = client.beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[{
        "type": "url",
        "url": "https://mcp.millionshort.com/mcp",
        "name": "millionshort",
        "authorization_token": os.environ["MILLIONSHORT_API_KEY"],
    }],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "millionshort"}],
    messages=[{"role": "user", "content": "Find independent blogs about home espresso, without the 1,000 most popular sites."}],
)
print("".join(block.text for block in response.content if block.type == "text"))
```

```ts TypeScript
import Anthropic from '@anthropic-ai/sdk';

const client = new Anthropic();
const response = await client.beta.messages.create({
  model: 'claude-opus-5-5',
  max_tokens: 16000,
  betas: ['mcp-client-2025-11-20'],
  mcp_servers: [
    { type: 'url', url: 'https://mcp.millionshort.com/mcp', name: 'millionshort', authorization_token: process.env.MILLIONSHORT_API_KEY },
  ],
  tools: [{ type: 'mcp_toolset', mcp_server_name: 'millionshort' }],
  messages: [{ role: 'user', content: 'Find independent blogs about home espresso, without the 1,000 most popular sites.' }],
});
for (const block of response.content) if (block.type === 'text') console.log(block.text);
```

Anthropic's servers make the calls, so our server must be reachable from the internet, which it is. The connector speaks streamable HTTP, which is what our server speaks.

## 3. Tell it when to search

Claude's own web search is a server tool that runs only when you list it in `tools`, so leave it out. Claude calls a connected tool when the request maps to what the tool does; to make that reliable, put a line like this in `system`:

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

To offer only some of the tools, turn them all off in the toolset's `default_config` and turn the ones you want back on in its `configs`, keyed by tool name (each with `"enabled": true`).

## 4. Check it works

Each tool call shows up in the response's `content` as an `mcp_tool_use` block, followed by an `mcp_tool_result` block with what our server sent back:

```python Python
import os

import anthropic

response = anthropic.Anthropic().beta.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[{"type": "url", "url": "https://mcp.millionshort.com/mcp", "name": "millionshort", "authorization_token": os.environ["MILLIONSHORT_API_KEY"]}],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "millionshort"}],
    messages=[{"role": "user", "content": "Search MillionShort for home espresso blogs."}],
)
for block in response.content:
    if block.type == "mcp_tool_use":
        print(block.server_name, block.name, block.input)  # millionshort search {...}
    elif block.type == "mcp_tool_result":
        print("error" if block.is_error else "ok")
```

```ts TypeScript
import Anthropic from '@anthropic-ai/sdk';

const response = await new Anthropic().beta.messages.create({
  model: 'claude-opus-5-5',
  max_tokens: 16000,
  betas: ['mcp-client-2025-11-20'],
  mcp_servers: [{ type: 'url', url: 'https://mcp.millionshort.com/mcp', name: 'millionshort', authorization_token: process.env.MILLIONSHORT_API_KEY }],
  tools: [{ type: 'mcp_toolset', mcp_server_name: 'millionshort' }],
  messages: [{ role: 'user', content: 'Search MillionShort for home espresso blogs.' }],
});
for (const block of response.content) {
  if (block.type === 'mcp_tool_use') console.log(block.server_name, block.name, block.input);
  else if (block.type === 'mcp_tool_result') console.log(block.is_error ? 'error' : 'ok');
}
```

To try it, ask:

> Search MillionShort for forum threads about restoring a cast iron skillet, with the 1,000 most popular sites removed. List the five most useful with their links.

## Without MCP: the tool runner

The SDK's tool runner (also in beta) turns a function into a tool, runs it when Claude asks, and loops until Claude stops asking. Your process makes the search, so this works where the connector is not available.

```python Python
import json
import os

import anthropic
import requests
from anthropic import beta_tool


@beta_tool
def millionshort_search(query: str) -> str:
    """Search the web with MillionShort, leaving out the 1,000 most popular sites.

    Args:
        query: What to search for.
    """
    r = requests.post(
        "https://api.millionshort.com/v1/search",
        headers={"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"},
        json={"query": query, "remove_top_sites": 1000, "num_results": 5},
        timeout=30,
    )
    r.raise_for_status()
    return json.dumps([{"title": x["title"], "url": x["url"], "snippet": x.get("snippet")} for x in r.json()["data"]["results"]])


runner = anthropic.Anthropic().beta.messages.tool_runner(
    model="claude-opus-5-5",
    max_tokens=16000,
    tools=[millionshort_search],
    messages=[{"role": "user", "content": "Find independent blogs about home espresso."}],
)
final = runner.until_done()
print("".join(block.text for block in final.content if block.type == "text"))
```

```ts TypeScript
import Anthropic from '@anthropic-ai/sdk';
import { betaZodTool } from '@anthropic-ai/sdk/helpers/beta/zod';
import { z } from 'zod';

const millionshortSearch = betaZodTool({
  name: 'millionshort_search',
  description: 'Search the web with MillionShort, leaving out the 1,000 most popular sites.',
  inputSchema: z.object({ query: z.string().describe('What to search for') }),
  run: async ({ query }) => {
    const res = await fetch('https://api.millionshort.com/v1/search', {
      method: 'POST',
      headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`, 'Content-Type': 'application/json' },
      body: JSON.stringify({ query, remove_top_sites: 1000, num_results: 5 }),
    });
    if (!res.ok) throw new Error(`search failed: ${res.status}`);
    const { data } = (await res.json()) as { data: { results: { title: string; url: string; snippet?: string }[] } };
    return JSON.stringify(data.results.map(({ title, url, snippet }) => ({ title, url, snippet })));
  },
});

const final = await new Anthropic().beta.messages.toolRunner({
  model: 'claude-opus-5-5',
  max_tokens: 16000,
  tools: [millionshortSearch],
  messages: [{ role: 'user', content: 'Find independent blogs about home espresso.' }],
});
for (const block of final.content) if (block.type === 'text') console.log(block.text);
```

In Python you can also iterate the runner (`for message in runner:`) to see each turn as it happens.

## 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 `authorization_token` out for the no-key mode |
| ANTHROPIC_API_KEY | Your Anthropic key, read by the SDK |

## 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 |
| `400` naming `mcp_servers` or the toolset | One half is missing, or `mcp_server_name` does not match the server's `name` | Send both, with the same name, and the `mcp-client-2025-11-20` beta |
| The connector fails, the tool runner works | Anthropic's servers could not reach ours, or the connector is not offered where you call Claude | Try again, or use the tool runner |

## Related

- [Agent tool use](https://millionshort.com/docs/search/guides/agent-tool-use): when to give a model tools, and what to tell it.
- [Claude](https://millionshort.com/docs/integrations/claude) and [Claude Code](https://millionshort.com/docs/integrations/claude-code): the same server in Anthropic's apps.
- Other model APIs: [OpenAI](https://millionshort.com/docs/integrations/openai), [Gemini](https://millionshort.com/docs/integrations/gemini), [Groq](https://millionshort.com/docs/integrations/groq), [xAI](https://millionshort.com/docs/integrations/xai).
- [MCP server](https://millionshort.com/docs/mcp) and [Filters for agents](https://millionshort.com/docs/search/filters).
- Anthropic's own documentation, read on 2026-11-19: [MCP connector](https://platform.claude.com/docs/en/agents-and-tools/mcp-connector), [Tool use](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview).
