# Multi-Account Gmail

An MCP server that keeps several Gmail accounts authorized at once, so your agent can read, search, label and draft across all of them.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed, Gemini CLI · ★ 5
- Author: cunicopia-dev
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/cunicopia-dev/gmail-mcp
- Updated: 2026-08-28
- HTML: https://affpapa.org/en/nevibecode/mcp/multi-account-gmail

## What it does

Most Gmail connectors tie one mailbox to one OAuth grant. Connect a second address and the first stops working. This server takes a different route: a single Google Cloud client authorizes any number of accounts, each one saved as a record in a local SQLite file, and every tool accepts an `account` argument that picks the mailbox. The `search_all_accounts` tool queries all of them in one pass and tags each hit with its account.

It runs over stdio. Tokens sit in one file under `~/.gmail-mcp/`, which you can copy, open in any SQLite viewer, or edit to revoke an account. Four narrow scopes are requested — `gmail.readonly`, `gmail.compose`, `gmail.modify`, `gmail.settings.basic` — never full mailbox access. Sending is out of scope by design: `create_draft` leaves a draft behind and you send it yourself.

You need Python 3.12+ and a `client_secret.json` from a Google Cloud project. Auth assumes the machine may have no browser: the CLI prints a consent link, listens on a fixed port, and you forward the redirect over SSH. That port comes from `GMAIL_MCP_OAUTH_PORT`; if something else already holds it, the login will not finish.

## Requirements
- Needs: Python and uv (commands run via uvx)
- Environment variables: `GMAIL_MCP_CLIENT_SECRET`, `GMAIL_MCP_DB`, `GMAIL_MCP_OAUTH_PORT` — keys and tokens: ask the human for the values, never commit them or put them in shared files.
- Works with: Gmail

## Install

### Claude Code (native platform)

**Platform CLI**
```bash
claude mcp add --env GMAIL_MCP_CLIENT_SECRET=<GMAIL_MCP_CLIENT_SECRET> --env GMAIL_MCP_DB=<GMAIL_MCP_DB> --env GMAIL_MCP_OAUTH_PORT=<GMAIL_MCP_OAUTH_PORT> --transport stdio multi-account-gmail -- uvx multi-account-gmail-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from multi-account-gmail-mcp <command>

### Codex

**Platform CLI**
```bash
codex mcp add multi-account-gmail --env GMAIL_MCP_CLIENT_SECRET=<GMAIL_MCP_CLIENT_SECRET> --env GMAIL_MCP_DB=<GMAIL_MCP_DB> --env GMAIL_MCP_OAUTH_PORT=<GMAIL_MCP_OAUTH_PORT> -- uvx multi-account-gmail-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from multi-account-gmail-mcp <command>

### Cursor

**Config file**
File `.cursor/mcp.json`:
```json
{
    "mcpServers": {
        "multi-account-gmail": {
            "command": "uvx",
            "args": [
                "multi-account-gmail-mcp"
            ],
            "env": {
                "GMAIL_MCP_CLIENT_SECRET": "<GMAIL_MCP_CLIENT_SECRET>",
                "GMAIL_MCP_DB": "<GMAIL_MCP_DB>",
                "GMAIL_MCP_OAUTH_PORT": "<GMAIL_MCP_OAUTH_PORT>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from multi-account-gmail-mcp <command>

### GitHub Copilot

**Config file**
File `.vscode/mcp.json`:
```json
{
    "servers": {
        "multi-account-gmail": {
            "type": "stdio",
            "command": "uvx",
            "args": [
                "multi-account-gmail-mcp"
            ],
            "env": {
                "GMAIL_MCP_CLIENT_SECRET": "<GMAIL_MCP_CLIENT_SECRET>",
                "GMAIL_MCP_DB": "<GMAIL_MCP_DB>",
                "GMAIL_MCP_OAUTH_PORT": "<GMAIL_MCP_OAUTH_PORT>"
            }
        }
    }
}
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from multi-account-gmail-mcp <command>

### Gemini CLI

**Platform CLI**
```bash
gemini mcp add -e GMAIL_MCP_CLIENT_SECRET=<GMAIL_MCP_CLIENT_SECRET> -e GMAIL_MCP_DB=<GMAIL_MCP_DB> -e GMAIL_MCP_OAUTH_PORT=<GMAIL_MCP_OAUTH_PORT> multi-account-gmail uvx multi-account-gmail-mcp
```
Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from multi-account-gmail-mcp <command>

## When to use it
- find an invoice email across every connected inbox
- pull a full thread by its id
- save a message's attachments to disk and get their paths
- clear the INBOX label from a batch matched by a query
- count matches before a bulk change so nothing extra gets touched

## Example prompts
- Search all accounts for messages with "invoice" from the last 30 days
- Read thread `19a...` in the work account and summarize what was agreed
- Draft a reply to message `18f...` saying the payment has gone out

## Similar
- [multi-gmail-mcp](https://affpapa.org/en/nevibecode/mcp/multi-gmail-mcp.md) — MCP server · ★ 19
- [gmail-skill](https://affpapa.org/en/nevibecode/skills/gmail-skill.md) — skill · 3600 installs
- [gmail](https://affpapa.org/en/nevibecode/skills/sanjay3290-gmail.md) — skill · 516 installs
- [gmail-mcp](https://affpapa.org/en/nevibecode/mcp/gmail-mcp.md) — MCP server · ★ 9
- [gws-gmail](https://affpapa.org/en/nevibecode/skills/gws-gmail.md) — skill · 82100 installs
- [gws-gmail-send](https://affpapa.org/en/nevibecode/skills/gws-gmail-send.md) — skill · 74800 installs

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
