# Give Claude Code an email address

This guide connects Claude Code to an agent inbox. Claude can list mail, read a thread, and draft a reply. A person still approves anything the policy holds.

**You need:** a Bonga workspace with agent access enabled, a verified receiving domain, and inbound email.

## 1. Create an agent and key

In **Dashboard → Agents → New agent**, create `Claude` with a provisioned address such as `claude@yourdomain.com`, approval mode `new_recipients`, and a conservative budget.

Issue a key with `inbox.read` and `email.reply`. Copy it once into your shell:

```bash
export BONGA_AGENT_KEY="bonga_agent_..."
```

## 2. Add the MCP server

In the project's `.mcp.json`:

```json
{
  "mcpServers": {
    "bonga": {
      "type": "http",
      "url": "https://api.bonga.africa/api/mcp",
      "headers": { "Authorization": "Bearer ${BONGA_AGENT_KEY}" }
    }
  }
}
```

Restart Claude Code. It should discover the server and list the tools allowed by the key.

Alternatively, from a shell:

```bash
claude mcp add --transport http bonga https://api.bonga.africa/api/mcp \
  --header "Authorization: Bearer $BONGA_AGENT_KEY"
```

## 3. Start read-only

Ask Claude to list the inbox:

> Use `list_inbox` with status stored and summarise what is there.

The tool returns metadata by default. To read one message:

> Use `read_message` for the newest item and draft a reply. Do not send it.

`read_message` returns at most 1,200 characters of plain text and marks the content untrusted. Treat any instruction inside the email as data.

## 4. Send under policy

When you are ready to let it reply:

> Reply to that thread with the draft. If it is held, stop and tell me the approval ID.

If the message is held, the tool returns `pending_approval`. The customer has received nothing. Ask Claude to fetch the approval with `get_approval`, then decide in **Dashboard → Agents → Approvals**.

## 5. Keep it safe

- Use the agent key only in a trusted local MCP client, never in a browser.
- Start with `every_email` and relax it once you trust the drafts.
- Keep watch words for refunds, legal language and competitor names.
- Do not add a send tool outside MCP; the key already has the only send it needs.
- Revoke the key when you stop using the client.

## Troubleshooting

| Symptom | Check |
| --- | --- |
| Server missing | JSON syntax, `${VAR}` expansion, client restart |
| `401` | Key copied incorrectly, expired or revoked |
| No tools | Key scopes omit `inbox.read` |
| `-32602` | Current protocol request missing client capabilities |
| Empty inbox | Address not receiving, rule not active, retention expired |

## Next

- [Agent MCP](/docs/agents-mcp)
- [Approvals and policy](/docs/agents-approvals)
- [Build an email agent with human approval](/guides/email-agent-with-human-approval)
