gmail-mcp
A minimal MCP server that enables Claude to search, read, and manage Gmail messages and threads using official Google API libraries. It supports actions like sending emails, creating drafts, replying to threads, and managing labels through secure OAuth2 authentication.
README
gmail-mcp
Minimal Gmail MCP server for Claude Code. Zero third-party code — only official Google and Anthropic libraries.
Tools
| Tool | Description |
|---|---|
search_emails |
Search with Gmail query syntax (is:unread, from:x, after:2026/03/01) |
read_email |
Read full email by ID (headers + plain text body, HTML fallback) |
read_thread |
Read all messages in a thread |
mark_as_read |
Mark one or more emails as read |
mark_as_unread |
Mark one or more emails as unread |
send_email |
Send email (to, cc, bcc, subject, body) |
create_draft |
Create draft without sending |
reply |
Reply to a thread (supports reply-all) |
list_labels |
List all labels with unread counts |
Architecture
gmail-mcp/
├── server.py # FastMCP server — 9 tools, stdio transport
├── auth.py # OAuth2 flow + credential management
├── gmail_tools.py # Gmail API wrapper functions
├── requirements.txt # 3 dependencies (all official)
├── setup.sh # Create venv + install + first-time OAuth
├── .env.example # Template for OAuth credentials
└── .gitignore
- Transport: stdio (standard for Claude Code MCPs)
- Auth: OAuth2 with
gmail.modifyscope (covers read + modify + send) - Multi-account: Two instances in
~/.claude.jsonwith different env vars - Token storage:
~/.gmail-mcp/{email}.jsonper account,0600permissions
Setup
1. Google Cloud Console
- Enable the Gmail API in your GCP project
- Create an OAuth 2.0 Client ID (Desktop application)
- Add
https://www.googleapis.com/auth/gmail.modifyto allowed scopes
2. Install
git clone https://github.com/fernandezdiegoh/gmail-mcp.git
cd gmail-mcp
cp .env.example .env
# Edit .env with your OAuth credentials
bash setup.sh
setup.sh creates the venv, installs deps, and runs the browser OAuth flow.
3. Register in Claude Code
Add to ~/.claude.json under "mcpServers":
"gmail": {
"type": "stdio",
"command": "/path/to/gmail-mcp/.venv/bin/python3",
"args": ["/path/to/gmail-mcp/server.py"],
"env": {
"GOOGLE_OAUTH_CLIENT_ID": "your-client-id",
"GOOGLE_OAUTH_CLIENT_SECRET": "your-client-secret",
"USER_EMAIL": "you@example.com",
"CREDENTIALS_DIR": "~/.gmail-mcp"
}
}
Multi-account
Register multiple instances with different keys (e.g., gmail and gmail-personal) pointing to the same server.py but different env vars. Each account gets its own token file in CREDENTIALS_DIR.
Dependencies
| Package | Purpose | Source |
|---|---|---|
mcp |
MCP SDK (FastMCP) | Anthropic (official) |
google-auth-oauthlib |
OAuth2 flow | Google (official) |
google-api-python-client |
Gmail API client | Google (official) |
Requirements
- Python 3.10+
License
MIT
Recommended Servers
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.
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.
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.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
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.
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.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.