# Send & Receive Emails with Grok (/integrations/frameworks/grok)

<!-- agent-signals: reading_time_min: 2 · est_tokens: 872 · updated: 2026-09-06 -->
Related: [Send & Receive Emails with Claude Cowork](/integrations/frameworks/claude-cowork.md), [Send & Receive Emails with Claude Code](/integrations/frameworks/claude-code.md), [Send & Receive Emails with OpenAI Codex](/integrations/frameworks/codex.md), [Send & Receive Emails with OpenClaw](/integrations/frameworks/openclaw.md), [Send & Receive Emails with Manus](/integrations/frameworks/manus.md), [Send & Receive Emails with Cursor](/integrations/frameworks/cursor.md)



# Connect AgentMail to Grok

Give Grok an email inbox of its own through the hosted AgentMail MCP server at `https://mcp.agentmail.to/mcp`, from the Grok app (custom connector, OAuth) or Grok Build (CLI, API key).

## Do this

Grok Build is the runnable path:

1. Generate an API key at `https://console.agentmail.to/dashboard/api-keys` and export it:

```bash
export AGENTMAIL_API_KEY="<API_KEY>"
```

2. Register the MCP server:

```bash
grok mcp add --transport http agentmail https://mcp.agentmail.to/mcp \
  --header "Authorization: Bearer $AGENTMAIL_API_KEY"
```

3. Confirm with `grok mcp list` (expect `agentmail: https://mcp.agentmail.to/mcp`), then in a `grok` session:

```text
Create an AgentMail inbox and send a hi email from it to you@example.com.
```

## SDK

* Grok app: **Plugins > Connectors > New Connector > Custom**, name `AgentMail`, server URL `https://mcp.agentmail.to/mcp`. The app authenticates over OAuth (Sign in and Allow); no API key.
* Grok Build: `grok mcp add --transport http agentmail https://mcp.agentmail.to/mcp --header "Authorization: Bearer $AGENTMAIL_API_KEY"`. Or write `~/.grok/config.toml` under `[mcp_servers.agentmail]` and start a new session.

## Facts

* Hosted MCP server URL for both surfaces: `https://mcp.agentmail.to/mcp`. Full tool catalog and OAuth details: [MCP and Skills](/integrations/mcp-and-skills).
* The Grok app custom connector takes only a name and server URL, then authenticates over OAuth. No API key.
* Grok Build passes the API key as an `Authorization: Bearer` header. An `x-api-key` header starts an OAuth sign-in instead.
* A running `grok` session does not pick up manual `~/.grok/config.toml` edits. Start a new session.
* `grok mcp doctor agentmail` runs a live handshake with the server.
* Creating an inbox without a username lets AgentMail generate an available one. A taken username makes `create_inbox` return `403` with up to 3 available variants in `suggestions`.

## Not supported

* Grok Build with an `x-api-key` header does not use the key. Pass the key as `Authorization: Bearer`.
* The Grok app custom connector has no API-key field. It authenticates over OAuth.

## Errors

| Error            | Status | Cause                                                                    | Fix                                                                  |
| ---------------- | ------ | ------------------------------------------------------------------------ | -------------------------------------------------------------------- |
| `resource_taken` | 403    | The requested inbox username belongs to another organization.            | Retry with one of the up to 3 variants in `suggestions`.             |
| `already_exists` | 403    | An inbox with the requested username already exists in the organization. | Retry with a username from `suggestions`, or use the existing inbox. |

## Verify

```bash
grok mcp doctor agentmail
```

A live handshake succeeds, and the prompt "Create an AgentMail inbox and send a hi email from it to [you@example.com](mailto:you@example.com)" makes the agent call `create_inbox` and `send_message` and report the new `@agentmail.to` address.

## Related

* [Custom domains](/advanced/custom-domains): an address on your own domain instead of `@agentmail.to`.
* [Agent safety](/advanced/safety): guardrails for an agent that reads untrusted mail and acts on its own.
* [MCP and Skills](/integrations/mcp-and-skills): the full hosted tool catalog and OAuth details.
