Purpose
gmail-mcp is a self-hosted Gmail MCP connector used to let MCP clients such as Claude, Codex, Claude Code, and Antigravity access multiple Gmail mailboxes through a unified endpoint. Each deployment supports only one owner but can bind multiple Gmail accounts (such as personal and work).
Key capabilities
- Every tool requires an explicitly specified account alias, which corresponds to a separately registered mailbox.
- Supports cross-account search, reading emails, and creating drafts.
- Sending emails and modifying labels can optionally be enabled; draft mode omits the send and label modification tools.
- Email bodies are capped at 60,000 characters (200,000 characters for a single conversation thread), with a truncation marker shown when exceeded; attachments are capped at 5 MB, images are returned as image content, and other files are returned as embedded resources.
- Credentials and authorization state are stored in encrypted SQLite storage on the server, and the service runs under systemd as a dedicated non-root user.
- Provides an entry point for directory inspection only, which can expose the same nine tool definitions as full mode, but all calls return an inspection_only error, do not read private configuration, and do not make Gmail requests.
Usage
- Build the server and configure mailbox aliases.
- Provide a public information page and connect the HTTPS domain (the information page must be available before Google OAuth setup).
- Create a Google Cloud project and enable the Gmail API, then configure OAuth clients: Desktop app for mailbox registration, Web application for owner interactive login, with the callback address being https://你的域名/login/google/callback。
- Keep the client JSON file outside Git (directory 0700, file 0600), and create ~/.config/gmail-mcp/config.json.
- Run the registration command; the CLI will write the credentials encrypted to ~/.local/share/gmail-mcp/state.db. Registration requires a browser on the server or a computer with SSH forwarding, and cannot be completed with only a phone.
- Add a custom Web connector in Claude, with the address being https://你的域名/mcp,使用连接器自身的 OAuth client (such as claude-gmail), not a Google OAuth client ID.
- Codex, Claude Code, and Antigravity each have independent public clients and callback configurations, and must be configured and logged in separately according to their respective instructions.
Applicable scenarios
Suitable for technical users who need to uniformly search, read, and draft emails across multiple Gmail mailboxes within an AI client, and are willing to maintain their own server, domain, and Google OAuth project.
Limitations
- Early version, aimed at experienced self-hosters; requires Node 24, Linux + systemd, an HTTPS hostname, and a self-owned Google OAuth project.
- Only one owner is supported per deployment.
- Forwarding addresses can only be read through the target mailbox; forwarding itself does not support sending from these addresses.
- In draft mode, Google's gmail.compose permission still includes sending capability at the Google level; in full mode, sending a specific draft requires client approval, and the server does not provide a separate manual approval interface.
- Connector authorization expires 30 days after creation and requires reconnection and approval; this is independent of mailbox registration.
- Email content is treated as untrusted input, and its trust boundaries, logging rules, and backup restrictions in its security policy must be followed.
- The installation script does not modify firewall, router, or tunnel configurations.
- Specific fees, pricing, and other information are not yet provided.