# LiteLLM

MillionShort search as an MCP server in the LiteLLM proxy, for every model behind it.

MCP · Proxy config, Python and TypeScript clients · 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 LiteLLM proxy connects to the MillionShort MCP server for you. You add it once to the proxy's `config.yaml`, with the key; then any client of the proxy can give any model behind it the server's tools ([the MCP page](https://millionshort.com/docs/mcp#tools) lists them), without seeing the key. The LiteLLM Python SDK can also load the tools straight from the server, with no proxy.

## 1. Install

```bash Python
pip install 'litellm[proxy]' openai mcp
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY
```

```bash TypeScript
npm install openai
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY
```

The proxy needs `litellm[proxy]` (Python 3.10 or later). The clients below use the OpenAI SDK pointed at the proxy, so the TypeScript side needs only `openai`. 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. Add the server to the proxy

Add an entry under `mcp_servers`. The name you give it (`millionshort`) is the server's alias. `auth_type: "bearer_token"` sends `Authorization: Bearer <auth_value>`, so put the key alone in `auth_value`, without the word Bearer. `os.environ/` reads it from the proxy's environment.

```yaml config.yaml
model_list:
  - model_name: gpt-6.1-sol
    litellm_params:
      model: openai/gpt-6.1-sol
      api_key: os.environ/OPENAI_API_KEY

mcp_servers:
  millionshort:
    url: "https://mcp.millionshort.com/mcp"
    transport: "http"
    description: "MillionShort web search"
    auth_type: "bearer_token"
    auth_value: "os.environ/MILLIONSHORT_API_KEY"
```

Without a key, leave `auth_type` and `auth_value` out. Set `transport: "http"` (streamable HTTP) explicitly: it is the default in `config.yaml`, but LiteLLM's management API defaults to SSE. Then start the proxy:

```bash
litellm --config config.yaml
```

In the Admin UI you can do the same under **MCP Servers**, **Add New MCP Server**: the URL, transport Streamable HTTP, then the authentication.

## 3. Use it from a client

Send a request to the proxy's Responses API with an `mcp` tool whose `server_url` is `litellm_proxy/mcp/millionshort`. That tells the proxy to use the server from its config; do not put the proxy's own address there. With `require_approval: "never"` the proxy runs the tool calls itself. Authenticate with your LiteLLM key (LITELLM_API_KEY here), not the MillionShort key.

```python Python
import os

from openai import OpenAI

client = OpenAI(base_url="https://your-litellm-proxy.example.com", api_key=os.environ["LITELLM_API_KEY"])

response = client.responses.create(
    model="gpt-6.1-sol",
    instructions="Use the millionshort search tool for anything recent or niche, and cite the URLs.",
    input="Find independent blogs about home espresso, without the 1,000 most popular sites.",
    tools=[
        {
            "type": "mcp",
            "server_label": "millionshort",
            "server_url": "litellm_proxy/mcp/millionshort",
            "require_approval": "never",
        }
    ],
)
print(response.output_text)
```

```ts TypeScript
import OpenAI from 'openai';

const client = new OpenAI({ baseURL: 'https://your-litellm-proxy.example.com', apiKey: process.env.LITELLM_API_KEY });

const response = await client.responses.create({
  model: 'gpt-6.1-sol',
  instructions: 'Use the millionshort search tool for anything recent or niche, and cite the URLs.',
  input: 'Find independent blogs about home espresso, without the 1,000 most popular sites.',
  tools: [
    {
      type: 'mcp',
      server_label: 'millionshort',
      server_url: 'litellm_proxy/mcp/millionshort',
      require_approval: 'never',
    },
  ],
});
console.log(response.output_text);
```

`server_url: "litellm_proxy"` gives the model every MCP server the key may use. The proxy's `/v1/chat/completions` endpoint takes the same `mcp` tool definition. MCP clients that connect directly (an IDE, an agent framework) use the proxy's gateway address for one server, `https://your-litellm-proxy.example.com/millionshort/mcp`, with the header `x-litellm-api-key: Bearer <your LiteLLM key>`.

## 4. Check it works

List the server's tools through the proxy, without a model:

```bash
curl -s "https://your-litellm-proxy.example.com/mcp-rest/tools/list?server_id=millionshort" \
  -H "Authorization: Bearer $LITELLM_API_KEY"
```

You should see `search`, `get_domain_info`, `list_sources` and the tools of the other endpoints (with no key, fewer, `search` and `list_sources` among them). In the Admin UI, **MCP Servers** lists `millionshort`. When a model sees tools from several servers, LiteLLM prefixes each with the server's name and a hyphen: `millionshort-search`. 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 the proxy: the Python SDK

The LiteLLM Python SDK can load MCP tools from a session in OpenAI's format, so any model LiteLLM calls can use them. You run the tool calls with `call_openai_tool`. This uses the MCP Python SDK 2.x client:

```python Python
import asyncio
import os

import httpx2
import litellm
from litellm import mcp_client
from mcp import ClientSession
from mcp.client.streamable_http import streamable_http_client


async def main():
    headers = {"Authorization": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}"}
    async with httpx2.AsyncClient(headers=headers, timeout=httpx2.Timeout(30.0, read=300.0)) as http:
        async with streamable_http_client("https://mcp.millionshort.com/mcp", http_client=http) as (read, write):
            async with ClientSession(read, write) as session:
                await session.initialize()
                tools = await mcp_client.load_mcp_tools(session=session, format="openai")
                messages = [{"role": "user", "content": "Find independent blogs about home espresso."}]
                response = await litellm.acompletion(model="gpt-6.1-sol", messages=messages, tools=tools)
                message = response.choices[0].message
                messages.append(message)
                for call in message.tool_calls or []:
                    result = await mcp_client.call_openai_tool(session=session, openai_tool=call)
                    messages.append({"role": "tool", "tool_call_id": call.id, "content": result.content[0].text})
                final = await litellm.acompletion(model="gpt-6.1-sol", messages=messages, tools=tools)
                print(final.choices[0].message.content)


asyncio.run(main())
```

Without a key, create the `httpx2.AsyncClient` with no headers. `litellm.experimental_mcp_client` is the older, deprecated name of `litellm.mcp_client`.

## 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. The proxy reads it through `os.environ/MILLIONSHORT_API_KEY`; the SDK example reads it directly. Leave it out for the no-key mode |

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

Every search a model makes through the proxy counts against the one key in `config.yaml`, whoever sent the request.

## 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 |
| The model gets no MillionShort tools | `server_url` is the proxy's own address, or the alias does not match | Use `litellm_proxy/mcp/millionshort`, with the name from `mcp_servers` |
| The server shows no tools, or fails to connect | `transport` is SSE (the management API's default) | Set `transport: "http"` |
| A virtual key gets no tools that the master key gets | LiteLLM limits MCP servers per key and team | Give the key or its team access to `millionshort` in the Admin UI |

## Related

- [Agent tool use](https://millionshort.com/docs/search/guides/agent-tool-use): when to give a model tools, and what to tell it.
- [OpenAI](https://millionshort.com/docs/integrations/openai) and [OpenAI Agents SDK](https://millionshort.com/docs/integrations/openai-agents): the same server with OpenAI's own clients.
- [MCP server](https://millionshort.com/docs/mcp) and [Filters for agents](https://millionshort.com/docs/search/filters).
- LiteLLM's own documentation, read on 2026-11-19: [MCP Gateway](https://docs.litellm.ai/docs/mcp), [MCP REST API](https://docs.litellm.ai/docs/mcp_rest_api), [Proxy quick start](https://docs.litellm.ai/docs/proxy/docker_quick_start).
