# MillionShort: set-up steps for an agent

> For an AI agent setting up MillionShort in a project. Three steps: get a key, connect, make
> one call. A person can read the same steps at https://millionshort.com/docs/set-up-for-agents

MillionShort is a search API and a hosted MCP server on our own independent index: the web
(Billions+ pages) plus news, discussions, podcasts, academic and other specialist sources.

- API base: `https://api.millionshort.com`
- Auth: `Authorization: Bearer ms-...` on every request
- MCP server (streamable HTTP): `https://mcp.millionshort.com/mcp`
- Reference: https://millionshort.com/docs/search/parameters

## 1. Get a key

### A trial key, with no account

For trying the API out. The key lasts 24 hours and carries 25 credits (a search of one source
costs 1 credit). It cannot be renewed or topped up.

```bash
curl -s -X POST https://api.millionshort.com/v1/keys/agent \
  -H "Content-Type: application/json" \
  -d '{"agent": "my-agent", "purpose": "trying search in a project"}'
```

- `agent`: required, up to 60 characters. The name of the agent or tool asking.
- `purpose`: optional, up to 200 characters.

```json
{
  "data": {
    "api_key": "ms-...",
    "tier": "trial",
    "rate_limit": "60/min",
    "expires_in_hours": 24,
    "expires_at": "2026-01-01T00:00:00+00:00"
  },
  "request_id": "req_..."
}
```

The key is shown once. Keep it in the environment variable `MILLIONSHORT_API_KEY`. Do not
write it into a source file, a commit or a log.

Trial keys are limited per network address and per day. A `429` means the limit is reached:
wait for the time in `Retry-After`, or use a dashboard key. Tell the person you are working
for that the key is a 24-hour trial. When a trial key expires or its credits are used up, do
not request another one to carry on: ask the person for a dashboard key.

### A dashboard key, for real use

A person signs in at https://millionshort.com/app and creates a key. The free plan needs a
verified email address and no card. Plans and limits: https://millionshort.com/pricing#api

Ask the person for the key, or ask them to set `MILLIONSHORT_API_KEY` themselves. Do not ask
them to paste it into a chat that is logged.

## 2. Connect

### Over HTTP

No package is needed:

```bash
curl -s https://api.millionshort.com/v1/search \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query": "restoring a cast iron skillet", "num_results": 5}'
```

### Over MCP

The hosted server needs nothing installed. Tools: `search`, `get_domain_info`,
`list_sources`. All three only read.

Claude Code:

```bash
claude mcp add --transport http millionshort https://mcp.millionshort.com/mcp \
  --header "Authorization: Bearer $MILLIONSHORT_API_KEY"
```

Cursor (`.cursor/mcp.json`) and other clients that take `mcpServers` with a header:

```json
{
  "mcpServers": {
    "millionshort": {
      "type": "http",
      "url": "https://mcp.millionshort.com/mcp",
      "headers": { "Authorization": "Bearer ms-YOUR_API_KEY" }
    }
  }
}
```

GitHub Copilot in VS Code (`.mcp.json` at the workspace root; VS Code fills in the variable):

```json
{
  "mcpServers": {
    "millionshort": {
      "type": "http",
      "url": "https://mcp.millionshort.com/mcp",
      "headers": { "Authorization": "Bearer ${MILLIONSHORT_API_KEY}" },
      "tools": ["*"]
    }
  }
}
```

The exact file or command for the client you run in, and how to turn off its own web search, is
on its page: the list is https://millionshort.com/docs/integrations.md (each page has a `.md`
twin, for example https://millionshort.com/docs/integrations/cursor.md). The Claude apps take
the key as a request header of a custom connector; ChatGPT's custom servers cannot send one, so
there the server runs in its no-key mode. Running the server on your own machine:
https://millionshort.com/docs/mcp

## 3. Check it works

A good answer is HTTP `200` with `data.results[]`, a `usage` object and a `request_id`:

```json
{
  "data": {
    "results": [
      {
        "title": "...",
        "url": "https://example.org/page",
        "site": "example.org",
        "source": "web",
        "snippet": "...",
        "highlights": ["..."],
        "published_date": null,
        "page_type": "articles",
        "topic": "home",
        "popularity": { "rank": null, "bucket": "long-tail" },
        "risk": null,
        "position": 1,
        "score": 1.0,
        "extra": {}
      }
    ],
    "summary": {
      "returned": 5,
      "removed": { "popularity": 0, "blocked": 0, "duplicates": 1, "risk": 0, "safe_search": 0 }
    },
    "warnings": []
  },
  "usage": { "credits": 1, "cost_usd": 0.001 },
  "request_id": "req_..."
}
```

| Status | `error.code` | What to do |
|---|---|---|
| 400 | `INVALID_PARAM`, `UNSUPPORTED_OPTION` | Fix the request; `error.message` names the field. Do not resend it unchanged. |
| 401 | `AUTH_MISSING_KEY`, `AUTH_INVALID_KEY` | Send a valid key. A trial key stops working after 24 hours. |
| 429 | `RATE_LIMITED`, `CAPACITY` | Wait for `Retry-After` seconds, then try once more. If the wait is longer than the task can spare, stop and tell the person. |
| 429 | `INSUFFICIENT_CREDITS` | The balance does not cover the call. Do not retry: tell the person, who adds credits in the dashboard. |
| 502 | `SEARCH_UNAVAILABLE` | Wait for `Retry-After` seconds, then try once more. |

Three codes share the status `429`, so read `error.code` before deciding to retry. A call that
fails is not charged.

Quote the `request_id` when reporting a problem.

## 4. Verify and hand off

Before you tell the person it is done:

1. Over MCP, the client lists the tools: `search`, `get_domain_info` and `list_sources` with a
   key, `search` and `list_sources` without one. Over HTTP, one search returned `200`.
2. One search returned results, and you read its `usage.credits`.
3. The key is in `MILLIONSHORT_API_KEY` or in a settings file that is not committed. It is not
   in a source file, a commit, a log or your reply. Never print it.
4. Run one or two searches to check, not more: each one spends the person's credits. Ask before
   a task that will search many times.

Then tell the person, in a few lines: what you added and where (the file or command), whether it
uses a key or the no-key mode, what one search cost, and how to remove it.

## The request, in short

`POST /v1/search`

| Field | Type | Meaning |
|---|---|---|
| `query` | string, 1 to 400 characters | Required. |
| `sources` | array, up to 5, default `["web"]` | `web`, `news`, `smallweb`, `discussions`, `hn`, `social`, `communities`, `podcasts`, `academic`, `medical`, `law`, `finance`, `contracts`. |
| `num_results` | integer 1 to 50, default 10 | |
| `remove_top_sites` | integer 0 to 1,000,000 | Leaves out results from the N most popular sites. |
| `only_top_sites` | integer 0 to 1,000,000 | Keeps only results from the N most popular sites. Not together with `remove_top_sites`. |
| `include_domains`, `exclude_domains`, `boost_domains`, `bury_domains` | arrays, up to 25 each | |
| `page_types`, `topics` | arrays | Values come from `GET /v1/sources`. |
| `safe_search` | `off`, `moderate`, `strict` | Default `moderate`. |
| `max_chars_per_result` | integer 0 to 2000, default 800 | Snippet length. |
| `explain` | boolean, default false | Adds the reasons each result matched. |

`GET /v1/sources` lists sources, page types and topics, and is free. `POST /v1/domain` takes
`{"domains": [...]}` (up to 25) and returns popularity and risk for each; it costs 1 credit.

Cost: 1 credit per source searched for up to 10 results, and 0.5 credits for each further 10.
One credit is $0.001. Every response states what it cost in `usage`.

## More

- Quickstart: https://millionshort.com/docs/quickstart
- Every integration (coding agents, chat apps, frameworks, model APIs, low-code): https://millionshort.com/docs/integrations.md
- A block for a project's `AGENTS.md`: https://millionshort.com/docs/snippets/AGENTS.md
- A Cursor rule: https://millionshort.com/docs/snippets/millionshort.mdc
- Every docs page in one file: https://millionshort.com/docs/llms-full.txt
