Skip to main content
Glama
gmail-mcp

gmail-mcp

by mortenv

gmail-mcp

MCP server for reading Gmail and creating drafts via AI assistants (Claude, OpenClaw, etc.).

Security model:

  • πŸ”’ Read-only by default β€” no send capability, ever

  • πŸ“‹ Drafts only β€” human must open Gmail and send manually

  • πŸ” Query whitelist β€” only configured filter queries are allowed

  • πŸ‘€ Optional recipient whitelist for drafts

  • πŸ”‘ API key authentication for HTTP/SSE mode

Tools

Tool

Description

list_filters

Show configured allowed search queries

search_email

Search Gmail (query must match a whitelisted filter)

get_email

Fetch full content of an email by ID

create_draft

Create a draft β€” NOT sent, human reviews in Gmail

Related MCP server: Gmail MCP Server

Setup

1. Google Cloud credentials

  1. Go to Google Cloud Console

  2. Create a project β†’ Enable Gmail API

  3. Create OAuth2 credentials (Desktop app type)

  4. Download as credentials.json and place in the project folder

2. Install

git clone https://github.com/mortenv/gmail-mcp
cd gmail-mcp
pip install -e .
# or with uv:
uv sync

3. Configure

cp config.example.yaml config.yaml

Edit config.yaml:

  • Add your filter queries (Gmail search syntax)

  • Optionally restrict draft recipients

4. Authenticate

First run opens a browser for OAuth2 login:

gmail-mcp config.yaml

Token is cached in token.json β€” subsequent runs don't need the browser.

5. Connect to Claude / OpenClaw

stdio mode (local):

{
  "mcpServers": {
    "gmail": {
      "command": "gmail-mcp",
      "args": ["/path/to/config.yaml"]
    }
  }
}

HTTP/SSE mode (remote server):

export GMAIL_MCP_API_KEY=$(python -c "import secrets; print(secrets.token_hex(32))")
gmail-mcp --http config.yaml
{
  "mcpServers": {
    "gmail": {
      "url": "https://your-server:8001/sse",
      "headers": { "X-API-Key": "your-key" }
    }
  }
}

Filter syntax

Uses standard Gmail search syntax:

filters:
  - query: "label:inbox"
    label: "Inbox"
  - query: "from:boss@company.com"
    label: "From boss"
  - query: "label:invoices newer_than:30d"
    label: "Recent invoices"

The AI can narrow results by appending terms to a base query: "label:inbox subject:urgent" β€” allowed if label:inbox is whitelisted.

Security notes

  • credentials.json and token.json are gitignored β€” never commit them

  • OAuth scopes: gmail.readonly + gmail.compose (no gmail.send)

  • Drafts require human review β€” the server has no way to send email

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to interact with Gmail through OAuth2 authentication, allowing users to list, search, read emails, and create drafts with a safety-first design that prevents accidental sends by default.
      298 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to search, read, and download attachments from Gmail using natural language, with read-only access.
      23 PyPI
      2
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to read unread Gmail messages and create threaded draft replies, without ever sending email automatically.
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI assistants to search, read, draft, and send Gmail messages, as well as manage labels and trash using natural language.
      24
      400 npm
      MIT