# OpenClaw and MCPmailer

OpenClaw agents connect to MCPmailer over MCP and get a persistent email identity.

OpenClaw agents already run long-lived sessions. With an MCPmailer inbox they gain a durable identity the outside world can reach: email in, email out, threads preserved.

## Setup

1. **Create a mailbox** One per agent, so its address and its key are the same identity.
1. **Run openclaw mcp add** With --auth oauth there is no token to store anywhere.
1. **Check it** openclaw mcp doctor mcpmailer --probe connects and lists what it found.
1. **Restart the gateway** The tool list is read when the server connects.

## openclaw.json

```json
{
  "mcp": {
    "servers": {
      "mcpmailer": {
        "url": "https://connect.mcpmailer.com/mcp",
        "transport": "streamable-http",
        "requestTimeoutMs": 320000,
        "headers": {
          "Authorization": "Bearer ${MCPMAILER_KEY}"
        }
      }
    }
  }
}
```

## Add it from the terminal

OAuth is the route their docs recommend, and ours supports it. The second form is for a key you already hold: keep it in the environment rather than in the file.

```bash
# OAuth: a browser opens once, nothing is written to disk
openclaw mcp add mcpmailer \
  --url https://connect.mcpmailer.com/mcp \
  --transport streamable-http \
  --auth oauth \
  --timeout 320000

# Or with a key you already have
openclaw mcp add mcpmailer \
  --url https://connect.mcpmailer.com/mcp \
  --transport streamable-http \
  --header "Authorization: Bearer \$MCPMAILER_KEY" \
  --timeout 320000

openclaw mcp doctor mcpmailer --probe
```

## Worth knowing

### Set transport explicitly

Without "transport": "streamable-http" the server is treated as the older SSE style and the connection does not come up. The CLI writes the field for you; a hand-edited config is where it goes missing.

### Interpolate the token, do not paste it

Headers expand ${VAR} from the environment, which is how their docs suggest avoiding a literal bearer token in a file you might commit.

### Raise the request timeout past the wait

wait_for_reply can block for 300 seconds. requestTimeoutMs is in milliseconds and has no documented default, so set it to 320000 or the gateway may give up before the reply lands.

### Or let mail wake the gateway

A session that is already running does not have to wait on a tool call. Turn on hooks in the OpenClaw config, then register a webhook pointing at its /hooks/wake route to interrupt the main session, or /hooks/agent to run an isolated turn beside it. The hooks token goes in an Authorization header and the body template takes the shape that route expects. /docs/openclaw has both templates, along with the timeouts, the tool filter, and running one gateway against several mailboxes.


Docs: https://mcpmailer.com/docs.md