gmail-mcp
A multi-account Gmail MCP server for searching, reading, drafting, replying, forwarding and sending mail — with a human confirmation step before anything is sent.
Account management: list connected accounts (email, alias, group); link a new account via browser sign-in; assign or clear an account's group; disconnect an account (revokes and deletes the token).
Search: query one account, a group of accounts, or all accounts at once using Gmail search syntax; every result row carries the account it came from, with per-account errors reported.
Read: fetch a full thread (headers, plain-text body, attachment names).
Drafts: list drafts; create new drafts or threaded reply drafts (optionally reply-all) — nothing is sent.
Send (confirmed): send a new email, reply in-thread, forward with attachments, or send an existing draft. Each returns a preview + single-use
confirm_token(or a client confirmation dialog) that must be supplied to actually send.Multi-account targeting: address a specific account by email or alias; send/reply/forward require exactly one account.
Safety switches: drafts-only mode removes the send tools entirely; auto-send mode disables confirmation for trusted autonomous agents.
Provides multi-account Gmail access for searching and reading emails and threads, listing and creating drafts and reply drafts, forwarding emails, and sending emails with a two-step confirmation flow.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@gmail-mcp search my work account for unread emails from this week"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
gmail-mcp
Multi-account Gmail MCP server (stdio). Read, search, draft, reply, forward and send, with a human confirmation before anything is sent.
Setup
Requires Python 3.11+ and uv. Each user brings their own Google OAuth client; nothing secret ships in this repo.
Google Cloud: create a project, enable the Gmail API, and create an OAuth client of type "Desktop app". Download the JSON to
~/.gmail-mcp/credentials.json(or setGMAIL_MCP_CREDENTIALS). If the consent screen is in Testing mode, add each Gmail address as a test user. Note: Google expires Testing-mode tokens after 7 days; the server tells the agent to re-link when that happens, or publish the app to production to stop it.Install:
git clone https://github.com/Shravanth007/Gmail-MCP.git cd Gmail-MCP uv syncLink accounts (repeat per account):
uv run gmail-mcp add-account --alias workAdd a shared group too:uv run gmail-mcp add-account --alias work1 --group work. Change it any time:gmail-mcp assign EMAIL_OR_ALIAS GROUP(use-as GROUP to clear). Also:gmail-mcp list-accounts(email, alias, group),gmail-mcp remove-account EMAIL.An alias is a unique nickname for one account. A group is a label several accounts can share (e.g.
work,personal). Aliases and groups share one namespace, so a name can't be both.Connect a client
Claude Desktop (
claude_desktop_config.json):{ "mcpServers": { "gmail": { "command": "uv", "args": ["--directory", "C:\\path\\to\\Gmail-MCP", "run", "gmail-mcp"] } } }Claude Code:
claude mcp add gmail -- uv --directory "C:\path\to\Gmail-MCP" run gmail-mcp
Related MCP server: Gmail Sender MCP Server
Configuration
Optional environment variables:
Variable | Default | Effect |
|
| Directory for |
|
| Path to the Google OAuth client JSON |
| off |
|
| off |
|
Claude Code: claude mcp add gmail -e GMAIL_MCP_AUTO_SEND=1 -- uv --directory "C:\path\to\Gmail-MCP" run gmail-mcp
Claude Desktop: add an "env" key next to "args" in claude_desktop_config.json:
"env": { "GMAIL_MCP_AUTO_SEND": "1" }Security
OAuth tokens live in the OS keychain (Windows Credential Manager / macOS Keychain / Secret Service), encrypted by the OS credential store (DPAPI on Windows), never in plain files.
accounts.jsonholds only emails and aliases.Scopes are least privilege:
gmail.readonlyandgmail.compose(read, draft, send; no delete or modify).The account email comes from Google's
getProfile, never from user input.Replying to your own message addresses the original recipients, as Gmail does. Forwards carry every named attachment, including ones nested in signed mail.
Sends and account removal confirm through a client dialog (MCP elicitation, supported by Claude Code 2.1.76+). The dialog shows from/to/cc/bcc, bare recipient addresses (so display names can't hide the destination), subject, attachments and body. On clients without elicitation the server falls back to a preview plus a single-use
confirm_token(5 min TTL, bound to account and action); changed arguments are rejected, and forsend_draftthe token is bound to the draft's message id, so a draft edited after the preview cannot be sent with the old token.GMAIL_MCP_DRAFTS_ONLY=1removes the four send tools entirely (drafts can still be created).GMAIL_MCP_AUTO_SEND=1turns OFF the confirmation for the four send tools so an autonomous agent can send on its own. Off by default. Only enable it for an agent you trust with the mailbox, in a session without other outbound tools; a prompt-injected agent can then send or forward anything.remove_accountstill confirms. Cannot be combined with drafts-only.Linking uses
prompt=consentso a refresh token is always issued; nothing is stored if Google omits it.remove-accountrevokes the token with Google and deletes it from the keychain.Logs go to stderr and never include tokens or message bodies.
Threat model
Protects against: the AI sending mail without a human click, and cross-account mix-ups.
Does not protect against malware running as your user (Credential Manager is per-user, not per-app).
Does not protect against a manipulated AI leaking mail through OTHER tools in the same session.
Does not protect against stolen refresh tokens until revoked (
gmail-mcp remove-accountor myaccount.google.com/permissions).
Recommended: never "always allow" the send tools, use the server in a session without web/browser tools when handling sensitive mail, and keep disk encryption and 2-step verification on.
Tools
list_accounts: connected accounts (email, alias, group) and agroupsmap.remove_account: unlink an account (confirmed through a dialog, orconfirm_tokenfallback). Linking is CLI-only (gmail-mcp add-account).assign_account: set or clear an account's group.search_emails: Gmail search syntax.accountmay be an email, alias or group (or omitted for all accounts); every result row carries theaccountit came from, and per-account failures are reported undererrors. All other tools, including send/reply/forward, need exactly one account (email or alias).get_thread: read a thread.list_drafts: list drafts.create_draft/create_reply_draft: save a draft; nothing is sent.send_email,reply_to_email,forward_email,send_draft: confirmed send (dialog, orconfirm_tokenfallback). Not registered whenGMAIL_MCP_DRAFTS_ONLY=1.
Available Tools
13 toolsadd_accountB
Connect a new Gmail account. Opens a browser window on the machine running this server
and waits up to 3 minutes for sign-in. Prefer the CLI: gmail-mcp add-account --alias NAME --group GROUP.
Inputs: alias, group.
assign_accountA
Assign an account to a group such as 'work' or 'personal' (None clears it). Many accounts may share a group.
Inputs: account (required), group.
create_draftB
Create a draft (does not send). account is an email or alias.
Inputs: to (required), body (required), subject (required), cc, +2 more.
create_reply_draftB
Create a threaded reply draft to a message (does not send). account is an email or alias.
Inputs: body (required), message_id (required), account, reply_all.
forward_emailA
Forward a message with its attachments. Two-step: first call returns a preview + confirm_token; call again
with it to send. account is an email or alias.
Inputs: to (required), message_id (required), body, account, +1 more.
get_threadA
Read all messages in a thread (headers, plain-text body, attachment names). account is an email or alias.
Inputs: thread_id (required), account.
list_accountsA
List connected Gmail accounts (email, alias, group).
Inputs: no named parameters.
list_draftsC
List drafts with subject and recipients. account is an email or alias.
Inputs: account, max_results.
remove_accountA
Disconnect a Gmail account (email or alias): revokes and deletes its stored token. Two-step: first call returns a confirm_token; call again with it to remove.
Inputs: account (required), confirm_token.
reply_to_emailB
Reply in-thread to a message. Two-step: first call returns a preview + confirm_token; call again with it
to send. account is an email or alias.
Inputs: body (required), message_id (required), account, reply_all, +1 more.
search_emailsA
Search messages using Gmail search syntax (e.g. 'from:bob is:unread'). account is an email, alias or group;
omit it to search all accounts. Each result row has the account it came from.
Inputs: query (required), account, max_results.
send_draftA
Send an existing draft. Two-step: first call returns a preview + confirm_token; call again with it to send.
account is an email or alias.
Inputs: draft_id (required), account, confirm_token.
send_emailB
Send a new email. Two-step: first call returns a preview + confirm_token; call again with it to send.
account is an email or alias.
Inputs: to (required), body (required), subject (required), cc, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool maps to a distinct resource/action, and the account-scoped vs. mail-scoped tools are clearly separated. The only mild overlap is create_draft vs. create_reply_draft, but the descriptions make the threaded-reply distinction explicit.
All 13 tools follow a strict snake_case verb_noun pattern (list_accounts, add_account, search_emails, create_draft, send_email, forward_email). Action verbs are chosen consistently from a small, predictable vocabulary.
13 tools is well within the ideal range and each one covers a real workflow step (account management, search/read, drafts, sending). Nothing appears redundant or padded.
Read and send coverage is strong, but there are notable gaps: no delete/update draft, no way to trash, archive, label, or mark messages read/unread, and attachments are only listed by name with no download. These omissions will block common inbox-management workflows.
Related MCP Connectors
Read, send, file and search email in any Gmail, Microsoft 365 or IMAP mailbox, plus its calendar.
Permissioned access to Gmail, Drive and Calendar via the user's own Google account
Give AI agents their own email inboxes: list, read and send mail via scoped, revocable OAuth grants.
Gmail, Outlook, Hotmail, Microsoft 365, Yahoo, iCloud and other IMAP mailboxes: search, read, send.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables reading, sending, archiving, and managing Gmail emails and labels through Google OAuth authentication, acting as an OAuth proxy to the Gmail API.313 npm12MIT
- AlicenseAqualityDmaintenanceEnables sending emails and creating drafts through the Gmail API with OAuth 2.0 authentication.2MIT
- AlicenseAqualityBmaintenanceManages email accounts via IMAP/SMTP, enabling reading, searching, sending, replying, forwarding, and folder management with multi-user and OAuth support.222MIT
- AlicenseBqualityBmaintenanceSafely searches, reads, flags, and drafts email through IMAP, with no send, delete, or move capabilities. Uses a local broker and OS credential store for secure authentication.18121 PyPIApache 2.0