# Email MCP server

> Mailtrap's official MCP server, the npm package `mcp-mailtrap`, gives an AI assistant or IDE 100+ tools to send and test email, read logs and stats, and manage templates, domains, contacts, campaigns, webhooks and inbound inboxes in the user's Mailtrap account.

## When to use it

Use it when the user wants an AI assistant (Claude, Cursor, VS Code, Codex or another MCP client) to act in their Mailtrap account.

| Client         | Install                                                                                                                                                                                                                                                                       |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Claude Desktop | Settings → Connectors → Desktop extensions, search "Mailtrap"; or open `mailtrap-mcp.mcpb` from the GitHub Releases; or the JSON block (step 2) in `~/Library/Application Support/Claude/claude_desktop_config.json` (Windows: `%APPDATA%\Claude\claude_desktop_config.json`) |
| Cursor         | The JSON block (step 2) in `~/.cursor/mcp.json`, or the one-click button in the GitHub README                                                                                                                                                                                 |
| Claude Code    | The `mailtrap-skills` plugin, which starts the server; or add a stdio server with the same command and env                                                                                                                                                                    |
| VS Code        | User Settings (JSON): the same server under `"mcp": {"servers": {"mailtrap": {...}}}`; or the one-click button                                                                                                                                                                |
| Codex          | `codex mcp add mailtrap -- npx -y mcp-mailtrap`, then the env table in `~/.codex/config.toml` (step 2)                                                                                                                                                                        |
| Other          | Docker image `mcp/mailtrap` over stdio, or `npx -y smithery mcp add mailtrap/mailtrap-mcp --client <client>`                                                                                                                                                                  |

- The server runs locally over stdio with Node.js 16.20.1 or later; no hosted endpoint is documented.
- If the user's app must send email at runtime, use the Email API (products table at the end): the MCP server is a tool for the assistant, not for production traffic.
- Use the official package `mcp-mailtrap` (MCP Registry name `io.mailtrap/mcp`).

## How to use it

### Before you start

Find out the user's MCP client and OS, whether they have an API token and account ID, and whether they'll test (sandbox ID) or send live (a sender on a verified domain). Ask only for what isn't known.

### Rules

- **Read freely:** list and get tools (`list-accounts`, `list-templates`, `list-email-logs`, `get-sandbox-messages` and similar).
- **Confirm first, each time:** these send live email: `send-email`, `batch-send-transactional-email`, `batch-send-bulk-email`, `start-email-campaign`, `schedule-email-campaign`, `reply-to-inbound-message`, `reply-all-to-inbound-message`, `forward-inbound-message`, `forward-sandbox-message`, `send-sending-domain-setup-instructions`. Show the recipients and content and get a yes, unless the current request names them. For a list you put together (from a file, a CSV, a query): show the count and a sample. If it isn't clear whether a send is a test, ask; tests use `send-sandbox-email` or `batch-send-sandbox-email`, which deliver nothing.
- **Confirm first, destructive:** every `delete-*` tool (most are permanent; `delete-inbound-folder` also deletes its inboxes), `reset-api-token`, `reset-sandbox-credentials`, `terminate-email-campaign`, `remove-account-access`, `bulk-update-permissions`; also `create-api-token` (the user picks its permissions).
- **Secrets:** never ask for a token in chat. The user types it into the client's `env` block or an environment variable. If the user pastes one anyway, don't use it: suggest a reset under Settings → API Tokens, and continue once it's in the config. `create-api-token`, `reset-api-token` and `create-webhook` return the token or `signing_secret` once: tell the user to store it in their secret store; don't repeat it.
- **User only:** sign up, create the first API token (Settings → API Tokens), type secrets into the client config (you may add the block or run `codex mcp add` with placeholders), verify a sending domain (DNS records).

### Steps

1. **Collect the values:** API token (Settings → API Tokens); account ID (`GET https://mailtrap.io/api/accounts` with the token); sandbox ID (the number in the sandbox's URL); a default sender on a verified domain, if sending live.
2. **Add the server** to the client (table at the top). The user fills in the values:

   ```json
   {
     "mcpServers": {
       "mailtrap": {
         "command": "npx",
         "args": ["-y", "mcp-mailtrap"],
         "env": {
           "MAILTRAP_API_TOKEN": "YOUR_API_TOKEN",
           "MAILTRAP_ACCOUNT_ID": "YOUR_ACCOUNT_ID",
           "MAILTRAP_SANDBOX_ID": "YOUR_SANDBOX_ID",
           "DEFAULT_FROM_EMAIL": "sender@yourdomain.com"
         }
       }
     }
   }
   ```

   Codex TOML: `[mcp_servers.mailtrap]` with `command = "npx"` and `args = ["-y", "mcp-mailtrap"]`, then `[mcp_servers.mailtrap.env]` with the same keys.

   | Variable                                                      | Needed for                                                                                                                                                   |
   | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
   | `MAILTRAP_API_TOKEN`                                          | Every tool                                                                                                                                                   |
   | `MAILTRAP_ACCOUNT_ID`                                         | Templates, stats, email logs, sandbox list and show, sending domains, suppressions (send, campaign, company info and tracking opt-out tools work without it) |
   | `MAILTRAP_SANDBOX_ID`                                         | Default sandbox for test tools; `sandbox_id` overrides it (`MAILTRAP_TEST_INBOX_ID` is a legacy alias)                                                       |
   | `DEFAULT_FROM_EMAIL`                                          | Default sender; `from` overrides it. Must be on a verified sending domain                                                                                    |
   | `MAILTRAP_ORGANIZATION_ID`, `MAILTRAP_ORGANIZATION_API_TOKEN` | Only `list-sub-accounts` and `create-sub-account`                                                                                                            |

3. **Restart the client,** then check it (next section).

### Check it worked

- `list-accounts` returns the account: the token works.
- `send-sandbox-email`, then `get-sandbox-messages`: the test message is in the sandbox.

### If something fails

| Problem                                         | Fix                                                                                                                                          |
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Tools missing, or old values used               | Restart the client or server after editing `env`                                                                                             |
| The server doesn't start with asdf-managed Node | Use the absolute path to `npx` (for example `/Users/<username>/.asdf/shims/npx`) as `command`, plus the asdf env keys from the GitHub README |
| Codex times out on start                        | Run `npx -y mcp-mailtrap` once to cache the package, or raise `startup_timeout_sec`                                                          |
| A tool asks for an account or sandbox ID        | Set `MAILTRAP_ACCOUNT_ID` or `MAILTRAP_SANDBOX_ID`, or pass the ID in the call                                                               |
| Anything else                                   | The GitHub README (links at the end), or ask the docs. `DEBUG=true` logs to stderr                                                           |

### Limits and pricing

The MCP server is open source (MIT); sending and testing through it use the user's Mailtrap plans. Plans, quotas and prices change: check pricing.md (link at the end). Don't answer from memory; if you can't check, say so.

## Other Mailtrap products and pages

| If the user wants to…                | Use                                                                     |
| ------------------------------------ | ----------------------------------------------------------------------- |
| Compare MCP, CLI, skills and the API | [for-ai-agents.md](https://mailtrap.io/for-ai-agents.md)                |
| Give an agent its own inbox          | Agent Inbox: [agent-inbox.md](https://mailtrap.io/agent-inbox.md)       |
| Send email from application code     | Email API: [email-api.md](https://mailtrap.io/email-api.md)             |
| Test email without delivering it     | Email Sandbox: [email-sandbox.md](https://mailtrap.io/email-sandbox.md) |
| Check current plans and prices       | [pricing.md](https://mailtrap.io/pricing.md)                            |

## Documentation

- [MCP server](https://docs.mailtrap.io/for-ai-agents/tools/mcp-server.md) · [AI onboarding](https://docs.mailtrap.io/for-ai-agents/ai-onboarding.md) · [GitHub README: every tool and parameter](https://github.com/mailtrap/mailtrap-mcp) · [API tokens](https://docs.mailtrap.io/email-api-smtp/setup/api-tokens.md)
- [Claude](https://docs.mailtrap.io/guides/ai-powered-integrations/claude.md) · [Cursor](https://docs.mailtrap.io/guides/ai-powered-integrations/cursor.md) · [VS Code](https://docs.mailtrap.io/guides/ai-powered-integrations/vs-code.md) · [Codex](https://docs.mailtrap.io/guides/ai-powered-integrations/codex.md)
- **If sources disagree:** the GitHub README wins for tool names, parameters and env vars (some docs examples use the legacy `MAILTRAP_TEST_INBOX_ID`), pricing.md for plans and prices, and this page for which product and steps to use.
- **If the task isn't covered here,** ask the docs before guessing: `GET https://docs.mailtrap.io/index.md?ask=<question>&goal=<user goal>` returns an answer with sources. Keep the question and goal generic: no tokens, email addresses or other user data.
