The mailbot stdio MCP package lets local clients such as Claude Desktop, Claude Code, Cursor and Codex manage inboxes, send email and track engagement through structured tools. It runs locally with an integration API key.

Hosted Claude and ChatGPT connections require separate registration, routing and
end-to-end verification; they are not announced as live. See
[Remote Connections](/docs/remote-connect) for consent and unavailable states.

:::caution Published and candidate
**Published.** `mailbot-mcp@0.1.0` is the version on npm (`npm view mailbot-mcp version`, 25 Nov 2026). In a test from a new account on 24 Nov 2026 its `tools/list` returned 12 tools: `create_inbox`, `list_inboxes`, `get_inbox`, `send_message`, `list_messages`, `get_message`, `reply_to_message`, `list_threads`, `get_thread`, `replay_event`, `get_usage` and `get_engagement_stats`. Two problems were found in that test: `npx -y mailbot-mcp` exited with code 0 without starting the server, and `create_inbox` failed because that version sends no `Idempotency-Key`.

**Candidate, not published.** The package source in this repository registers more tools (domains, approvals, webhook deliveries, key safeguards) than the published version. None of those, and no fix for the two problems above, is available from npm until a new version is published and checked on a fresh account. Until then, create inboxes with the [REST API](/docs/quick-start), which accepts an `Idempotency-Key` header, and treat the sections below as the candidate behavior.
:::

## Install

```bash
npx mailbot-mcp
```

Or install globally:

```bash
npm install -g mailbot-mcp
```

## Configuration

Set your API key as an environment variable:

```bash
export MAILBOT_API_KEY=mb_your_api_key_here
```

Get your API key from the [dashboard](https://getmail.bot/dashboard): create an **integration key** on the Billing page. It is shown once, so copy it and confirm in the dashboard that you saved it. The **Dashboard sign-in** entry in the key list only keeps your browser signed in and expires on its own; it does not work as `MAILBOT_API_KEY`. If you lose an integration key, create a new one and revoke the old one.

## Claude Desktop

Add this to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "mailbot": {
      "command": "npx",
      "args": ["mailbot-mcp"],
      "env": {
        "MAILBOT_API_KEY": "mb_your_api_key_here"
      }
    }
  }
}
```

## Claude Code

```bash
claude mcp add mailbot -- npx mailbot-mcp
```

Then set your API key in your environment.

## Cursor

Go to **Settings > MCP Servers > Add Server** and use the same config as Claude Desktop above.

## Included Tools

This list describes the candidate source (`packages/mailbot-mcp/src/tools`), not the published 0.1.0 package, which has only the 12 tools named at the top of this page. Parameters marked `?` are optional.

Tools that create something or start a delivery take a required `idempotency_key`, a stable string of 8 to 255 characters. Generate it once per logical action and reuse it when you retry that action. The same key with the same payload returns the original result; the same key with a different payload is refused with `IDEMPOTENCY_CONFLICT`. Without a valid key the API answers `400 IDEMPOTENCY_KEY_REQUIRED`.

| Tool | What it does | Parameters |
|---|---|---|
| `create_inbox` | Create an inbox for sending and receiving | `username`, `display_name?`, `domain?`, `idempotency_key` |
| `list_inboxes` | List inboxes in the account | `page?`, `limit?` |
| `get_inbox` | Get one inbox | `inbox_id` |
| `send_message` | Send an email from an inbox | `inbox_id`, `to[]`, `subject`, `body`, `cc[]?`, `bcc[]?`, `idempotency_key` |
| `reply_to_message` | Reply in the same thread | `inbox_id`, `message_id`, `body`, `idempotency_key` |
| `list_messages` | List messages in an inbox | `inbox_id`, `since?`, `limit?`, `page?` |
| `get_message` | Get one message with its state | `inbox_id`, `message_id` |
| `list_threads` | List conversations in an inbox | `inbox_id`, `limit?`, `page?` |
| `get_thread` | Get a thread with all its messages | `inbox_id`, `thread_id` |
| `get_usage` | Outbound emails used this month | none |
| `get_engagement_stats` | Opens, clicks and bounces | `inbox_id?`, `period?` |
| `replay_event` | Legacy engagement replay; see [limitations](/docs/concepts/replay-mechanics#legacy-engagement-replay) | `event_id`, `target_url?`, `idempotency_key` |
| `list_domains` | List domains and verification freshness | none |
| `get_domain` | Get a domain with its verification expiry and missing DNS records | `domain_id` |
| `add_domain` | Add a custom domain | `domain`, `idempotency_key` |
| `verify_domain` | Refresh DNS verification for a domain | `domain_id` |
| `list_message_approvals` | List outbound drafts waiting for approval | none |
| `get_message_approval` | Read one approval draft | `message_id` |
| `approve_message` | Approve and dispatch a held draft | `message_id`, `reason?`, `idempotency_key` |
| `reject_message` | Reject a held draft | `message_id`, `reason?`, `idempotency_key` |
| `get_message_status_history` | Inspect a message's delivery status history | `message_id` |
| `list_webhook_deliveries` | Inspect webhook delivery outcomes | `webhook_id`, `status?`, `limit?`, `offset?` |
| `replay_webhook_delivery` | Replay one failed webhook delivery | `webhook_id`, `delivery_id`, `idempotency_key` |
| `get_api_key_safeguards` | Read the safeguards of an API key you own | `key_id` |
| `update_api_key_safeguards` | Replace the safeguards of an API key you own | `key_id`, `safeguards` (canonical: `{ allowlist, budget, approval }`; see below) |
| `stop_api_key` | Stop sending for an API key you own | `key_id` |
| `resume_api_key` | Resume sending for an API key you own | `key_id` |

`update_api_key_safeguards` takes the canonical nested `safeguards` object. Flat top-level `allowlist`, `budget` and `approval` are accepted by stdio and remote as compatibility aliases only; new integrations should use `safeguards`.

```json
{
  "key_id": "00000000-0000-4000-8000-000000000000",
  "safeguards": {
    "allowlist": { "enforced": true, "emails": [], "domains": ["example.com"] },
    "budget": { "per_hour": 100, "per_day": 1000 },
    "approval": "required"
  }
}
```

Remote clients need the `mcp:write` scope for every tool that is not a read.

Rules for agents:

- Report an email as delivered only when `get_message` shows it delivered.
- If a call got no answer, repeat the exact same call with the same `idempotency_key`: it returns the first result and never sends twice.
- If a call came back with a server error (`5xx`), that key is locked. Check with `get_message` or `list_messages`. Send again, with a new `idempotency_key`, only if the message is not there.
- If a call was refused (`4xx`), do not repeat it. The error names what to change. See [Reading a Send Failure](/docs/concepts/error-language).
- Engagement statistics can contain zero counts when signals are unavailable. Sandbox exposes delivered events only; missing opens or clicks do not prove zero engagement.

## Example Usage

Once connected, you can ask your AI assistant:

- "Create an inbox called support@mydomain.com"
- "Send an email from my inbox to user@example.com"
- "Show me all threads in my support inbox"
- "Did the invoice email to user@example.com actually arrive?"
- "How many outbound emails have I used this month?"

Adding and verifying a domain is available as tools. The DNS records themselves
still have to be created at your DNS provider: see [Custom Domain Setup](./custom-domain.mdx).

## Error Handling

Every failed tool call returns the same lines, so an agent can read them without
guessing:

```text
The domain you send from is not verified yet.
Code: DOMAIN_NOT_VERIFIED (HTTP 400)
Where it stopped: sender domain, before anything was created
Retry: Do not retry yet. The same request fails again until you fix this.
Request ID: 3f9c1d2e
Next: Publish the DNS records for the domain, then run verify.
```

`Retry` is one of five answers: safe, wait, fix first, check first, or never. A
server error or a dropped connection always says to read the message back before
sending again. A request that got no answer says the same, because it may have
arrived. The full list is in [Reading a Send Failure](/docs/concepts/error-language).

## Environment Variables

| Variable | Required | Default | Description |
|----------|----------|---------|-------------|
| `MAILBOT_API_KEY` | Yes | — | Your mailbot API key (starts with `mb_`) |
| `MAILBOT_API_URL` | No | `https://getmail.bot` | API base URL |
