Skip to main content
Glama
gmail-mcp

gmail-mcp

by Shravanth007

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.

  1. 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 set GMAIL_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.

  2. Install:

    git clone https://github.com/Shravanth007/Gmail-MCP.git
    cd Gmail-MCP
    uv sync
  3. Link accounts (repeat per account): uv run gmail-mcp add-account --alias work Add 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.

  4. 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

GMAIL_MCP_HOME

~/.gmail-mcp

Directory for accounts.json and default credentials location

GMAIL_MCP_CREDENTIALS

~/.gmail-mcp/credentials.json

Path to the Google OAuth client JSON

GMAIL_MCP_DRAFTS_ONLY

off

1 removes the four send tools

GMAIL_MCP_AUTO_SEND

off

1 sends without confirmation (see Security)

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.json holds only emails and aliases.

  • Scopes are least privilege: gmail.readonly and gmail.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 for send_draft the 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=1 removes the four send tools entirely (drafts can still be created).

  • GMAIL_MCP_AUTO_SEND=1 turns 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_account still confirms. Cannot be combined with drafts-only.

  • Linking uses prompt=consent so a refresh token is always issued; nothing is stored if Google omits it.

  • remove-account revokes 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-account or 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 a groups map.

  • remove_account: unlink an account (confirmed through a dialog, or confirm_token fallback). Linking is CLI-only (gmail-mcp add-account).

  • assign_account: set or clear an account's group.

  • search_emails: Gmail search syntax. account may be an email, alias or group (or omitted for all accounts); every result row carries the account it came from, and per-account failures are reported under errors. 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, or confirm_token fallback). Not registered when GMAIL_MCP_DRAFTS_ONLY=1.

Available Tools

13 tools
add_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

    A3.6/5.0

    Scored across 13 tools

    Disambiguation4/5

    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.

    Naming Consistency5/5

    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.

    Tool Count5/5

    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.

    Completeness3/5

    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

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Manages email accounts via IMAP/SMTP, enabling reading, searching, sending, replying, forwarding, and folder management with multi-user and OAuth support.
      22
      2
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Safely 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.
      18
      121 PyPI
      Apache 2.0