gmail-mcp

gmail-mcp

Enables AI assistants to read Gmail and create drafts securely with read-only access and query whitelisting.

Category
Visit Server

README

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

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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured