Agents that act on the web keep running into email. They sign up for services and need the verification code, wait for a password reset link, read a support request or reply to a customer. Giving an agent a shared personal mailbox is risky, and writing a custom email integration for every framework is slow.

MailSlurp runs a hosted [Model Context Protocol](https://modelcontextprotocol.io) server that gives an agent scoped access to MailSlurp inboxes and phone numbers. Most agent frameworks can call a remote MCP server, so the same MailSlurp tools work in each of them with a few lines of setup. This page shows that setup for the Claude API, the OpenAI Agents SDK, the Vercel AI SDK and LangChain.

For desktop and coding clients such as Claude Code, Codex and Cursor, follow [Install in your AI client](/docs/mcp/#install-in-your-ai-client) instead. Those clients can sign in with OAuth and need no key.

## Before you start

Every example connects to the same endpoint over Streamable HTTP:

```text
https://api.mailslurp.com/mcp
```

Server-side frameworks authenticate with a scoped agent key rather than OAuth:

1. Open [Create a scoped agent key](https://app.mailslurp.com/agents/keys/new/) in MailSlurp.
2. Choose the least-privileged role that fits the task. A read-only role is enough for reading verification codes and links; choose a responder or support role only if the agent must draft or send replies.
3. Select the inboxes or phone numbers the agent may use.
4. Copy the key and store it as `MAILSLURP_AGENT_KEY` in the environment where the agent runs.

The server accepts the key in an `x-api-key` header or as `Authorization: Bearer <key>`. Use a dedicated agent key for each agent rather than an account API key, so that each agent's access, activity and revocation stay separate. [Create a scoped agent key](/docs/mcp/#create-a-scoped-agent-key) explains roles and scopes in more detail.

## Claude API

The Claude Messages API connects to remote MCP servers for you. Pass MailSlurp in `mcp_servers` and enable its tools with an `mcp_toolset` entry of the same name:

```bash
pip install anthropic
```

```python

const mailslurp = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://api.mailslurp.com/mcp',
    headers: { 'x-api-key': process.env.MAILSLURP_AGENT_KEY! },
  },
});

try {
  const tools = await mailslurp.tools();
  const result = await generateText({
    model: 'anthropic/claude-opus-5-5',
    tools,
    stopWhen: stepCountIs(5),
    prompt: 'Find the newest email in my MailSlurp inbox and return the verification code.',
  });
  console.log(result.text);
} finally {
  await mailslurp.close();
}
```

`stopWhen` lets the model call several MailSlurp tools in sequence, for example listing inboxes and then reading the latest email, before it writes the answer. Use any model your AI SDK project is configured for.

## LangChain

LangChain loads MCP tools through its MCP adapter and passes them to any LangChain agent:

```bash
pip install "langchain[mcp]"
```

```python