# Multi-Account Gmail MCP server

> Allows an AI client to read, search, draft, and label emails across multiple Gmail accounts through a single connection.

- Repository: https://github.com/cunicopia-dev/gmail-mcp
- Page: https://hostedmcp.org/servers/cunicopia-dev/gmail-mcp
- Transport: stdio
- Stars: 6
- License: MIT
- Latest version: 0.3.0

## Install

### Claude Code

```sh
claude mcp add gmail-mcp -- uvx multi-account-gmail-mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "gmail-mcp": {
      "command": "uvx",
      "args": [
        "multi-account-gmail-mcp"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "gmail-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "multi-account-gmail-mcp"
      ]
    }
  }
}
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "gmail-mcp": {
      "command": "uvx",
      "args": [
        "multi-account-gmail-mcp"
      ]
    }
  }
}
```

### Codex (`~/.codex/config.toml`)

```toml
[mcp_servers.gmail-mcp]
command = "uvx"
args = ["multi-account-gmail-mcp"]
```

### Gemini CLI (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "gmail-mcp": {
      "command": "uvx",
      "args": [
        "multi-account-gmail-mcp"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `GMAIL_MCP_CLIENT_SECRET` | no | no | Path to the Google OAuth "Desktop app" client-secret JSON. Defaults to ~/.gmail-mcp/client_secret.json. |
| `GMAIL_MCP_DB` | no | no | Path to the SQLite token store holding per-account refresh tokens. Defaults to ~/.gmail-mcp/tokens.db. |
| `GMAIL_MCP_OAUTH_PORT` | no | no | Localhost port for the OAuth redirect during account authorization. Defaults to 8765. |

## Tools (18)

- `list_accounts`
- `search_messages`
- `read_message`
- `read_thread`
- `download_attachments`
- `search_all_accounts`
- `create_draft`
- `list_drafts`
- `list_labels`
- `create_label`
- `modify_labels`
- `trash`
- `bulk_action`
- `read_messages`
- `count_messages`
- `list_filters`
- `create_filter`
- `delete_filter`

## FAQ

### Can this server send emails automatically?

No, the server is designed to create drafts rather than send mail directly as a security measure.

### How does the server handle multiple Gmail accounts?

It uses a single Google Cloud client to authorize any number of accounts, storing their tokens in a local SQLite database.

### Is it possible to search all my inboxes at once?

Yes, the `search_all_accounts` tool allows you to run a single query across every authorized account.

### Does the server require a browser for authentication?

It supports a headless auth path that works on machines without a browser by providing a consent URL for SSH forwarding.
