The Gmail AutoAuth MCP Server integrates Gmail directly into Claude Desktop. Built on the Model Context Protocol, this server manages OAuth2 authentication automatically, turning Claude into a natural-language interface for your inbox. Users can search, read, draft, and organize emails without ever leaving the chat interface.
Send Emails: Draft and send messages complete with subject lines, body text, attachments, and multiple recipients. The server supports plain text, HTML, and multipart alternative formats. It ensures international characters in subject lines and bodies are rendered correctly across all clients.
Read and Search: Retrieve specific messages by ID with clean parsing of complex MIME structures. Claude can search your inbox using senders, subject lines, date ranges, or any standard Gmail search operator.
Label Management: Create, rename, or delete labels. The server handles both system labels (Inbox, Sent, Trash) and custom user labels. You can also mark messages as read/unread or move them between folders via the chat interface.
Batch Operations: Modify or delete dozens of emails simultaneously. The server includes built-in chunking logic to ensure operations stay within Gmail API limits.
Authentication Flow: Full Gmail API integration featuring a streamlined OAuth2 consent process. Once configured, credentials are stored globally, so you only need to complete the setup once.
Install via Smithery
To automatically install and configure the server for Claude Desktop, run the following command:
npx -y @smithery/cli install @gongrzhe/server-gmail-autoauth-mcp --client claude
Manual Setup
Create a Google Cloud Project
http://localhost:3000/oauth2callback to the Authorized redirect URIs.gcp-oauth.keys.json.Run Authentication
.gmail-mcp folder in your home directory and place gcp-oauth.keys.json inside. Then execute:npx @gongrzhe/server-gmail-autoauth-mcp auth
gcp-oauth.keys.json in your current working directory and run the same command. The file will automatically copy itself to ~/.gmail-mcp/.The authentication process searches for the key file in your current folder or ~/.gmail-mcp/. It will open your default browser for Google sign-in. After access is granted, your credentials will be saved to ~/.gmail-mcp/credentials.json.
Configure Claude Desktop
Add the following configuration to your Claude Desktop settings file:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": [
"@gongrzhe/server-gmail-autoauth-mcp"
]
}
}
}
Authentication
docker run -i --rm \
--mount type=bind,source=/path/to/gcp-oauth.keys.json,target=/gcp-oauth.keys.json \
-v mcp-gmail:/gmail-server \
-e GMAIL_OAUTH_PATH=/gcp-oauth.keys.json \
-e "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json" \
-p 3000:3000 \
mcp/gmail auth
Usage
{
"mcpServers": {
"gmail": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"mcp-gmail:/gmail-server",
"-e",
"GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json",
"mcp/gmail"
]
}
}
}
For remote environments (such as n8n) where localhost is inaccessible, you can specify a custom callback URL:
npx @gongrzhe/server-gmail-autoauth-mcp auth https://gmail.gongrzhe.com/oauth2callback
Cloud Setup Steps
gmail.gongrzhe.com) to that port.https://gmail.gongrzhe.com/oauth2callback to your authorized redirect URIs.This allows the OAuth flow to complete on a remote server successfully.
The server provides the following tools to Claude:
send_email: Sends a message immediately. Supports plain text, HTML, and multipart (HTML with plain text fallback).draft_email: Creates a message in your drafts folder without sending it.read_email: Retrieves the full content of a specific message using its ID.search_emails: Finds messages using standard Gmail search syntax.modify_email: Adds or removes labels from a specific message.delete_email: Permanently deletes a message.list_email_labels: Returns all available Gmail labels.create_label: Generates a new custom label with specific visibility settings.update_label: Renames existing labels or modifies their visibility.delete_label: Removes a custom label.get_or_create_label: Finds a label by name or creates it if it does not exist.batch_modify_emails: Applies label changes to multiple messages simultaneously with configurable batch sizes.batch_delete_emails: Permanently deletes multiple messages in a single operation.The search_emails tool utilizes Gmail's native query engine:
| Operator | Example | Description |
|---|---|---|
from: |
from:[email protected] |
Messages from a specific sender |
to: |
to:[email protected] |
Messages sent to a specific recipient |
subject: |
subject:"project update" |
Subject contains specific text |
has:attachment |
has:attachment |
Filters for emails with files |
after: |
after:2024/01/01 |
Received after a specific date |
before: |
before:2024/02/01 |
Received before a specific date |
is: |
is:unread |
Filters by status (unread, starred, etc.) |
label: |
label:work |
Filters by label name |
You can combine these for precise results: from:[email protected] after:2024/01/01 has:attachment.
Intelligent Content Extraction The server processes complex MIME trees by prioritizing plain text and falling back to HTML when necessary. It accurately handles nested multipart messages and preserves essential metadata like sender details, recipients, and timestamps.
Internationalization Subject lines and message bodies fully support non-ASCII characters. Whether your emails are in Chinese, Japanese, Arabic, or European languages with diacritics, the text will render accurately.
Granular Label Management Claude can manage mailbox organization via custom visibility settings:
messageListVisibility: Set to show or hide labels in the message list.labelListVisibility: Choose between labelShow, labelShowIfUnread, or labelHide.Batch Processing Power The server handles up to 50 messages per batch by default. It automatically segments large requests to stay within API rate limits and provides a detailed success/failure report for each item, including automatic retries for individual failures.
OAuth credentials are stored locally in ~/.gmail-mcp/. The server utilizes "offline access" to maintain authentication without repeated logins. These files contain sensitive access tokens and should never be committed to version control. You can review or revoke these permissions at any time via your Google Account security settings.
gcp-oauth.keys.json is located in the active directory or ~/.gmail-mcp/. Verify that the file has the correct read permissions.web or installed credential blocks. If using a web app, ensure the redirect URI matches your Google Cloud settings exactly.batchSize to avoid rate limiting.
Dianman VPN: Free Trial, Unlimited Data & Zero Throttling
Liebao VPN Free Trial: 4K Streaming & Easy Setup on Any Device
OpenAI’s New Open-Weight Models: gpt-oss-120b & 20b
Infinite Radio: The AI DJ That Adapts Music Genres to Your Screen
NeuralAgent: An Open-Source AI Agent for Native Desktop Automation
Scira: The Minimalist AI Search Engine for Grok, Claude, and Beyond
Teable: The Self-Hosted, PostgreSQL-Based Airtable Alternative
Memvid: Store Millions of Text Chunks in a Single MP4 File
n8n Automation: Over 400 AI Integrations in a Single Workflow
ACI.dev: 600+ Tools for AI Agents with Built-In Auth and MCP Support
Natural Language CAD Control via CAD-MCP Server
Add Area Fill to Line Charts in Excel: Step-by-Step