Gmail for AI agents: search, read, download attachments, send, reply, forward, drafts, labels. CLI with --json and an MCP server.
- ✓Open-source license (MIT)
- ✓Actively maintained (<30d)
- ✓Clear description
- ✓Topics declared
- ✓Documented (README)
claude mcp add gmail-agent -- npx -y @gongrzhe/server-gmail-autoauth-mcp{
"mcpServers": {
"gmail-agent": {
"command": "npx",
"args": ["-y", "@gongrzhe/server-gmail-autoauth-mcp"]
}
}
}MCP Servers overview
# gmail-agent [](https://pypi.org/project/gmail-agent/) [](https://pypi.org/project/gmail-agent/) [](https://github.com/dremok/gmail-agent/actions/workflows/ci.yml) [](https://github.com/dremok/gmail-agent/blob/main/LICENSE) Gmail for AI agents and the people who run them: search, read, download attachments, send, reply, forward, drafts, labels and trash. <!-- mcp-name: io.github.dremok/gmail-agent --> `gmail-agent` is one small Python package with two faces: - a **CLI** for agents that have a shell (Claude Code, Codex, Aider, your own scripts), with `--json` output - an **MCP server** over stdio for clients like Claude Desktop and Claude Code It talks directly to the Gmail API from your machine using your own Google Cloud OAuth client, so there is no third-party server in between. You choose how much access it gets when you log in, from read-only up to full. Why another one? A lot of real agent work with mail is about attachments: find last quarter's invoices, save them, read the PDFs. The hosted Gmail connectors can't save files to disk, and the most used open-source Gmail MCP server is archived. gmail-agent handles attachments well, shows you any write before it happens, and only offers the tools your login allows. See [How it compares](https://github.com/dremok/gmail-agent#how-it-compares). ## What it does **Read** - Search with Gmail syntax (`from:`, `has:attachment`, `filename:pdf`, `newer_than:30d`, ...), paginated - Read a message or a whole thread as plain text (HTML mail is converted) - List labels and drafts **Attachments** - List a message's attachments with name, type, size and part id - Download from one message, or every attachment from every message matching a query - Extract text from PDF and text attachments without saving them Downloads never overwrite anything. If `invoice.pdf` exists, the next one becomes `invoice_1.pdf`, and you get the real paths back. Names are sanitized, so a file called `../../.ssh/config` lands as `config` inside the folder you picked. **Write** - Send new mail with attachments, Cc/Bcc, plain text or HTML - Reply and reply-all in the same thread (In-Reply-To, References and thread id are set, the original is quoted) - Forward, including the original attachments - Drafts: create, list, show, update, send, delete - Labels: create, rename, delete, add to and remove from messages or threads - Mark read or unread, star, archive - Trash and untrash; permanent delete behind an explicit flag Every write command takes `--dry-run`, which prints the exact API request and, for mail, the MIME message without changing anything. With `--json`, results include the ids of whatever was sent or created. ## Quick start You need [uv](https://docs.astral.sh/uv/) (or pipx) and Python 3.11+. ```sh uv tool install gmail-agent # or: pipx install gmail-agent ``` For the latest unreleased changes: `uv tool install git+https://github.com/dremok/gmail-agent`. Then set it up once (about 5 minutes, guided): ```sh gmail-agent setup # Google Cloud project, OAuth client and login; default access level is "modify" gmail-agent status # shows the logged-in account and access level gmail-agent search "has:attachment newer_than:7d" ``` Then connect your agent. In Claude Code: `/plugin install gmail-agent --marketplace dremok/gmail-agent`. For Codex, Gemini CLI, VS Code, Cursor and Claude Desktop, see [MCP server](https://github.com/dremok/gmail-agent#mcp-server). ## How it compares Checked against each project's source and docs in October 2026. Corrections are welcome as issues. | | gmail-agent | Claude's Gmail connector | [google_workspace_mcp](https://github.com/taylorwilsdon/google_workspace_mcp) | [GongRzhe Gmail-MCP-Server](https://github.com/GongRzhe/Gmail-MCP-Server) | |---|---|---|---|---| | Setup | Your own OAuth client; `gmail-agent setup` guides you (about 5 minutes) | One click | Your own OAuth client, by hand | Your own OAuth client, by hand | | Runs as | CLI and stdio MCP, on your machine | Hosted (web, desktop, mobile) | stdio or HTTP, multi-user | stdio MCP | | Save attachments to disk | Yes, never overwrites | No | Yes, to its own folder, deleted after an hour | Yes, overwrites files with the same name | | Every attachment matching a search | Yes | No | No | No | | Text of PDF attachments | Yes | No | No | No | | Forward with original attachments | Yes | Not documented | Yes | No forward | | Drafts | Create, update, send, delete | Yes | Create only | Create only | | Dry run of every write, with the MIME message | Yes | No, asks before each write instead | No | No | | Read-only mode | Yes | No, the grant includes sending | Yes | No | | Tool list follows the granted scope | Yes | No | From server flags | No | | Permanent delete | Only with `--allow-delete` and a `full` login | Not offered | Not offered | Offered without a guard | | Drive, Calendar, Docs | No, Gmail only | Separate connectors | Yes | No | | Maintained | Yes | Yes | Yes | Archived in 2025 | Use something else if: - **You want no setup, or use Claude on the web or your phone.** The built-in connector is one click away. - **You need Drive, Calendar and Docs in the same server, or one server for a team over HTTP.** google_workspace_mcp covers all of Workspace. - **You need Gmail filters, sending from an alias, your Gmail signature or inline images in outgoing mail.** gmail-agent does none of these yet. - **You want a plain CLI for all of Google Workspace.** [googleworkspace/cli](https://github.com/googleworkspace/cli) (`gws`) is a good one. It dropped its MCP server in version 0.8.0. ## Coming from GongRzhe/Gmail-MCP-Server? That server is archived. Moving takes a few minutes, and you can keep your Google Cloud project. 1. **Install:** `uv tool install gmail-agent` 2. **Reuse your OAuth client, not your token.** Setup checks the client, installs it and logs you in: ```sh gmail-agent setup --client-file ~/.gmail-mcp/gcp-oauth.keys.json ``` Do not copy GongRzhe's `credentials.json` by hand. Despite the name it is your login token, while gmail-agent's `credentials.json` is the OAuth client, and the token formats differ anyway. gmail-agent needs a **Desktop app** client. If yours is a Web application client, setup says so; create a Desktop client in the same project and pass that file instead. 3. **Point your MCP client at gmail-agent.** Replace `npx @gongrzhe/server-gmail-autoauth-mcp` with `gmail-agent mcp`, for example `claude mcp add gmail --scope user -- gmail-agent mcp`. For Claude Desktop, see [MCP server](https://github.com/dremok/gmail-agent#mcp-server). 4. **Optional cleanup:** revoke the old grant at [myaccount.google.com/permissions](https://myaccount.google.com/permissions) and remove `~/.gmail-mcp`. | GongRzhe tool | gmail-agent tool | Notes | |---|---|---| | `search_emails` | `search_messages` | Adds paging with `page_token` | | `read_email` | `get_message`, `get_thread` | HTML mail comes back as text | | `send_email` | `send_message`, `reply_to_message` | Replies set the threading headers for you | | `draft_email` | `create_draft`, or any send tool with `as_draft` | Drafts can also be updated and sent | | `modify_email`, `batch_modify_emails` | `modify_labels`, `mark_messages` | Labels by name or id | | `delete_email`, `batch_delete_emails` | `trash` | Permanent delete needs `mcp --allow-delete` and a `full` login | | `list_email_labels` | `list_labels` | | | `create_label`, `update_label`, `delete_label` | `create_label`, `rename_label`, `delete_label` | No visibility options | | `get_or_create_label` | `list_labels`, then `create_label` | | | `download_attachment` | `download_attachments` | Picks by filename or part id, never overwrites | | | `download_matching_attachments`, `read_attachment_text`, `forward_message` | New | | `create_filter` and the other filter tools | None | gmail-agent never touches settings, filters or forwarding | Two behaviours differ on purpose: delete means trash unless you opt in, and the tool list shrinks to what your login allows. If tools seem to be missing, check the level with `gmail-agent status`. ## Google Cloud setup Gmail has no API keys for personal mail, so you create your own OAuth client in Google Cloud. It is free and you do it once. `gmail-agent setup` walks you through it and does what Google lets it do for you: 1. **Project and Gmail API.** If [gcloud](https://cloud.google.com/sdk/docs/install) is installed and logged in, setup creates a project called `gmail-agent-` plus six random characters (it asks first) and enables the Gmail API. Without gcloud it opens the two console pages and asks for the project ID. `--project ID` uses a project you already have. 2. **Consent screen and publishing.** Google has no API for these, so setup opens the pages and tells you what to click: app name `gmail-agent`, audience **External**, then **Publish app** so the status is In production. Publishing avoids the 7-day login expiry of Testing mode, and you do not have to add yourself as a test user. Google calls the app unverified, which is expected for your own app and fine for personal use (it is capped at 100 users). 3. **Desktop client.** Setup opens the Clients page. Create a client of type **Desktop app** and click Download JSON (Google shows the secret only then). Setup spots the file in `~/Downloads`, checks that it is a Desktop client from the right project, and installs it as `~/.config/gmail-agent/credentials.json`, readable only by you. You can also pass `--client-file PATH`, or press Ctrl-C and paste the client ID and secret. 4. **Login.** A browser opens; pick your account. Google says **"Google hasn't verified this app"**: click Continue and keep all boxes ticked. Set
What people ask about gmail-agent
What is dremok/gmail-agent?
+
dremok/gmail-agent is mcp servers for the Claude AI ecosystem. Gmail for AI agents: search, read, download attachments, send, reply, forward, drafts, labels. CLI with --json and an MCP server. It has 0 GitHub stars and its last recorded update is dated 2026-10-11.
How do I install gmail-agent?
+
You can install gmail-agent by cloning the repository (https://github.com/dremok/gmail-agent) or following the README instructions on GitHub. ClaudeWave also provides quick install blocks on this page.
Is dremok/gmail-agent safe to use?
+
Our security agent has analyzed dremok/gmail-agent and assigned a Trust Score of 95/100 (tier: Verified). See the full breakdown of passed checks and flags on this page.
Who maintains dremok/gmail-agent?
+
dremok/gmail-agent is maintained by dremok. The last recorded GitHub activity is dated 2026-10-11, with 0 open issues.
Are there alternatives to gmail-agent?
+
Yes. On ClaudeWave you can browse similar mcp servers at /categories/mcp, sorted by popularity or recent activity.
Deploy gmail-agent to your cloud
Ship this repo to production in minutes. Each platform spins up its own environment with editable env vars.
Maintain this repo? Add a badge to your README
Drop the badge into your GitHub README to show it's tracked on ClaudeWave. Each badge links back to this page and reflects the live Trust Score.
[](https://claudewave.com/repo/dremok-gmail-agent)<a href="https://claudewave.com/repo/dremok-gmail-agent"><img src="https://claudewave.com/api/badge/dremok-gmail-agent" alt="Featured on ClaudeWave: dremok/gmail-agent" width="320" height="64" /></a>More MCP Servers
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
User-friendly AI Interface (Supports Ollama, OpenAI API, ...)
Reverse engineer anything with agents, from app behavior down to native binaries.
An open-source AI agent that brings the power of Gemini directly into your terminal.
Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface
🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl! Don't be shy, join here: https://discord.gg/EMgGbDceNQ and follow here for daily tips and tricks: https://x.com/Scrapling_dev