Featured

Deploy OpenClaw in 60 seconds — 20% off logoDeploy OpenClaw in 60 seconds — 20% off

Launch OpenClaw on Hostinger in about 60 seconds and keep your agent live 24/7. Our referral link gives you 20% off, no coupon code needed.

Launch on Hostinger
Run your Hermes agent on Hostinger, fully managed logoRun your Hermes agent on Hostinger, fully managed

Launch Hermes on Hostinger in one click, fully managed, no VPS knowledge needed. Use code ZACAARON10 for 10% off.

Launch on Hostinger
Crawl and scrape any site into clean data, 10% off logoCrawl and scrape any site into clean data, 10% off

Firecrawl crawls and scrapes any site into clean markdown for your agent. Get 1,000 free credits, and new users get 10% off their first purchase.

Try Firecrawl free
Your own AI agent, running 24/7 with QwikClaw logoYour own AI agent, running 24/7 with QwikClaw

QwikClaw sets up and runs an always-on OpenClaw agent for you. One click, no config files, no server setup.

Deploy now
One API to scrape, enrich, and extract the internet. logoOne API to scrape, enrich, and extract the internet.

Context.dev gives your agents a single API to scrape, enrich, and extract live web data — no proxies, no parsers, no maintenance.

Start building free
SetupClaw: done-for-you OpenClaw for founders & exec teams logoSetupClaw: done-for-you OpenClaw for founders & exec teams

White-glove OpenClaw for founders and exec teams (4–50+ employees): we install, harden, integrate your tools, and maintain it — secured from day one.

Get it set up for you
SEO data APIs for your agent, $1 free credit logoSEO data APIs for your agent, $1 free credit

DataForSEO gives your agent live access to SERP results, keyword data, backlinks, and on-page SEO data through one API. New accounts get a $1 credit, good for up to 20,000 keyword or backlink lookups.

Try DataForSEO free
Reach 47,000+ AI builders

A flat monthly placement in front of developers actively installing AI tools. No lock-in, cancel anytime.

Advertise here

Works with

Claude CodeClaude DesktopCursorVS CodeClineCodex CLIOpenClaw+ any MCP client

Install to Claude Code

This server doesn't publish a one-line install command. Follow the setup in the source repository.

Summary

Enables AI assistants to send, read, list, and reply to emails via the Gmail API.

README.md

gmail-mcp

A Model Context Protocol (MCP) server that exposes Gmail actions as tools, allowing AI assistants like Claude to send, read, list, and reply to emails on your behalf.

Tools

| Tool | Description | |------|-------------| | send_email | Send an email to a recipient | | list_emails | List emails matching a Gmail search query | | read_email | Read a specific email by message ID | | read_emails_from_sender | Fetch recent emails from a specific sender | | reply_email | Reply to an email, preserving thread headers | | forward_recent_replies_to_webhook | Forward recent Gmail replies to a signed LeadBorg email webhook |

Requirements

  • Python 3.13+
  • A Google Cloud project with the Gmail API enabled
  • OAuth 2.0 credentials (google_creds.json)

Setup

1. Get Google OAuth credentials

  1. Go to the Google Cloud Console.
  2. Create a project (or select an existing one).
  3. Enable the Gmail API.
  4. Under APIs & Services > Credentials, create an OAuth 2.0 Client ID (Application type: Desktop app).
  5. Download the JSON file and save it as google_creds.json in the project root.

2. Install dependencies

# Using uv (recommended)
uv sync

# Or pip
pip install -e .

3. Authenticate

Run the server once manually to trigger the OAuth browser flow:

python gmail_mcp.py

This creates a token.json file at ~/.config/gmail-mcp/token.json. Subsequent runs reuse and auto-refresh this token.

Running the server

The transport is controlled by the MCP_TRANSPORT environment variable (default: stdio).

stdio (default — for Claude Desktop / MCP clients)

python gmail_mcp.py

Streamable HTTP

MCP_TRANSPORT=streamable-http MCP_PORT=8001 python gmail_mcp.py
# or alias:
MCP_TRANSPORT=http python gmail_mcp.py

SSE

MCP_TRANSPORT=sse python gmail_mcp.py

Environment variables

| Variable | Default | Description | |----------|---------|-------------| | MCP_TRANSPORT | stdio | Transport mode: stdio, sse, streamable-http (alias: http) | | MCP_HOST | 127.0.0.1 | Host for HTTP/SSE transports | | MCP_PORT | 8001 | Port for HTTP/SSE transports | | GOOGLE_CREDS_PATH | ~/.config/gmail-mcp/google_creds.json | Path to OAuth client credentials file | | GOOGLE_TOKEN_PATH | ~/.config/gmail-mcp/token.json | Path to cached OAuth token file |

Claude Desktop configuration

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "gmail": {
      "command": "python",
      "args": ["/absolute/path/to/gmail_mcp.py"]
    }
  }
}

Running tests

python -m pytest tests/
# or
python -m unittest discover tests/

Project structure

gmail-mcp/
├── gmail_mcp.py        # MCP server and tool definitions
├── main.py             # Alternate entry point (HTTP transport)
├── pyproject.toml
└── tests/
    └── test_gmail_mcp.py

~/.config/gmail-mcp/
├── google_creds.json   # OAuth client credentials (not committed)
└── token.json          # Cached OAuth token (generated at runtime)

Permissions

The server requests two OAuth scopes:

  • https://www.googleapis.com/auth/gmail.readonly — read access to emails
  • https://www.googleapis.com/auth/gmail.send — permission to send email

This does not grant access to delete messages permanently.

LeadBorg integration notes

When using this server from LeadBorg, configure the email MCP endpoint as:

http://localhost:8001/mcp/

Set the provider to gmail-mcp. LeadBorg will pass a signed reply_to alias to send_email; Gmail-MCP writes it as the Reply-To header so inbound replies can be correlated back to the lead.

For local reply ingestion, run the forward_recent_replies_to_webhook tool with the LeadBorg webhook URL (/api/webhooks/email/mcp) and the same signing secret configured as EMAIL_WEBHOOK_SIGNING_SECRET.

See related servers & alternatives →

Related MCP servers

Browse all →

Related guides

Hand-picked reading to help you choose and use Communication servers.