# Letta

MillionShort search for Letta agents, registered as an MCP server in Python or 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.

Letta connects to MCP servers in two ways. With the Letta API client (the V1 SDK, Python and TypeScript), you register the MillionShort server once, and Letta's servers call it for any agent you attach its tools to. With the newer Letta Agent SDK (TypeScript only), your Node.js process connects to the server for one session. Either way the agent gets the server's tools ([the MCP page](https://millionshort.com/docs/mcp#tools) lists them).

Letta marks the V1 SDK as legacy and recommends the Agent SDK for new work; the V1 SDK is the one with a Python client.

## 1. Install

```bash Python
pip install letta-client
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY
```

```bash TypeScript
npm install @letta-ai/letta-client
npm install @letta-ai/letta-agent-sdk
export MILLIONSHORT_API_KEY=ms-YOUR_API_KEY
```

The second npm line is only for the Agent SDK session in step 3. The Letta clients read your Letta key from LETTA_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.

## 2. Register the server

Register MillionShort as a streamable HTTP server, then list its tools. Letta stores the key with the server and sends it as the `Authorization` header. Without a key, leave `auth_header` and `auth_token` out.

```python Python
import os

from letta_client import Letta

client = Letta()  # reads LETTA_API_KEY

server = client.mcp_servers.create(
    server_name="millionshort",
    config={
        "mcp_server_type": "streamable_http",
        "server_url": "https://mcp.millionshort.com/mcp",
        "auth_header": "Authorization",
        "auth_token": f"Bearer {os.environ['MILLIONSHORT_API_KEY']}",
    },
)
tools = client.mcp_servers.tools.list(server.id)
for tool in tools:
    print(tool.name)  # search, get_domain_info, list_sources, ...
```

```ts TypeScript
import Letta from '@letta-ai/letta-client';

const client = new Letta(); // reads LETTA_API_KEY

const server = await client.mcpServers.create({
  server_name: 'millionshort',
  config: {
    mcp_server_type: 'streamable_http',
    server_url: 'https://mcp.millionshort.com/mcp',
    auth_header: 'Authorization',
    auth_token: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
  },
});
const tools = await client.mcpServers.tools.list(server.id!);
for (const tool of tools) console.log(tool.name); // search, get_domain_info, list_sources, ...
```

Letta's MCP page writes the tool list as `mcp_servers.list_tools` / `mcpServers.listTools`; in the current clients (1.12) it is `mcp_servers.tools.list` / `mcpServers.tools.list`, as above.

## 3. Give the tools to an agent

Attach the tool ids when you create the agent, then send it a message:

```python Python
from letta_client import Letta

client = Letta()
server = next(s for s in client.mcp_servers.list() if s.server_name == "millionshort")
tools = client.mcp_servers.tools.list(server.id)

agent = client.agents.create(
    name="researcher",
    model="openai/gpt-4.1",
    system="Use the millionshort search tool for anything recent or niche, and cite the URLs.",
    tool_ids=[tool.id for tool in tools],
)
response = client.agents.messages.create(agent.id, input="Find independent blogs about home espresso.")
for message in response.messages:
    print(message)
```

```ts TypeScript
import Letta from '@letta-ai/letta-client';

const client = new Letta();
const server = (await client.mcpServers.list()).find((s) => s.server_name === 'millionshort');
if (!server?.id) throw new Error('register the millionshort server first');
const tools = await client.mcpServers.tools.list(server.id);

const agent = await client.agents.create({
  name: 'researcher',
  model: 'openai/gpt-4.1',
  system: 'Use the millionshort search tool for anything recent or niche, and cite the URLs.',
  tool_ids: tools.map((tool) => tool.id),
});
const response = await client.agents.messages.create(agent.id, { input: 'Find independent blogs about home espresso.' });
for (const message of response.messages) console.log(message);
```

### Or: a session in the Agent SDK

The Agent SDK (TypeScript only) takes MCP servers per session. Your process holds the connection, and the tools are named `mcp__millionshort__search` and so on:

```ts TypeScript
import { LettaAgentClient } from '@letta-ai/letta-agent-sdk';

const client = new LettaAgentClient({ backend: 'cloud', apiKey: process.env.LETTA_API_KEY });
const agentId = await client.createAgent();

const session = client.resumeSession(agentId, {
  mcpServers: {
    millionshort: {
      type: 'http',
      url: 'https://mcp.millionshort.com/mcp',
      headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
    },
  },
});
try {
  await session.send('Find independent blogs about home espresso, and cite the URLs.');
  for await (const message of session.stream()) {
    if (message.type === 'assistant') process.stdout.write(message.content);
  }
} finally {
  await session[Symbol.asyncDispose](); // closes the MCP connection
  await client.close();
}
```

Letta's docs write this with `await using session = ...`, which does the same disposal where your runtime supports it.

If you pass `allowedTools`, include `mcp__millionshort__*` in it, or the tools are hidden.

## 4. Check it works

The tool list in step 2 should print `search`, `get_domain_info`, `list_sources` and the tools of the other endpoints (with no key, fewer, `search` and `list_sources` among them). Then run step 3: the agent's messages should include a call to `search` and an answer that cites pages. If the agent 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.

## 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 the auth fields or header 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.

## 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 |
| `list_tools` is not found on `mcp_servers` | The docs' method name is older than the client | Use `client.mcp_servers.tools.list(server.id)` |
| The agent never calls the tools | The tool ids were not attached, or `allowedTools` leaves them out | Pass `tool_ids` when creating the agent, or add `mcp__millionshort__*` to `allowedTools` |

## 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 Agents SDK](https://millionshort.com/docs/integrations/openai-agents) and [Genkit](https://millionshort.com/docs/integrations/genkit): the same server in other frameworks.
- [MCP server](https://millionshort.com/docs/mcp) and [Filters for agents](https://millionshort.com/docs/search/filters).
- Letta's own documentation, read on 2026-11-19: [MCP tools (V1 SDK)](https://docs.letta.com/v1-sdk/tools/mcp-tools), [MCP and client tools (Agent SDK)](https://docs.letta.com/agent-sdk/mcp/), [V1 SDK quickstart](https://docs.letta.com/v1-sdk/).
