Gmail MCP Server
Provides tools for searching, reading, sending, and organizing emails, managing labels, extracting addresses, and handling attachments through the Gmail API.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Gmail MCP Server find emails from my boss about meeting"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
⚡ Quick Start
# One-command setup — auto-configures your AI client
npx gmail-mcp-server setupThat's it. The setup wizard will:
Check your Google OAuth credentials
Let you choose your AI client (Claude Desktop, Claude Code, Cursor, Windsurf)
Auto-write the config file
Run the OAuth authentication flow
Related MCP server: Gmail MCP Server
✨ Why choose this MCP?
While Google provides workspace integrations and generic email readers exist, this MCP is explicitly built for AI Agents acting autonomously:
Zero-Config Setup:
npx gmail-mcp-server setupdetects your OS and AI client, automatically editing your local configuration JSON. No manual path mapping required.Built for AI Agents: Includes tools like
advanced_filter(search + bulk actions with LLM-friendly dry-runs),batch_modify_emails(modify 1000 emails at once), andget_frequent_contacts(turn an inbox into a CRM context).100% Local & Private: Bring-your-own-credentials. Tokens remain strictly on your machine. No proxy servers, no telemetry, and no third-party email routing.
Modular & Extensible: Clean, deeply typed domain-driven structure (e.g.,
src/tools/compose.ts,src/tools/search.ts) making it extremely easy for developers to fork and extend.
🔧 Tools (20 tools)
Category | Tool | Description |
Search |
| Search with Gmail query syntax ( |
Read |
| Full email content — body, headers, attachments |
| All messages in a thread | |
Compose |
| Send a new email |
| Reply (or reply-all) keeping the thread | |
| Forward with optional note | |
| Save a draft (optionally in a thread) | |
Organize |
| Add/remove labels, mark read/unread |
| Bulk modify up to 1000 emails | |
| Move to trash | |
| Restore from trash | |
| Bulk trash | |
| Mark as spam | |
| Search + bulk action (archive, label, etc.) with dry-run | |
Labels |
| List all labels with IDs |
| Create new label (supports nesting) | |
| Delete user-created label | |
Extract |
| Extract unique addresses from search results |
| Filter, sort, reformat email data | |
Profile |
| Your email address, message/thread counts |
| Most-contacted addresses from sent mail | |
Attachments |
| Download attachment content |
🚀 Step-by-Step Setup Guide
Follow these steps to get your Gmail MCP server running in less than 5 minutes.
1. Create Google Cloud Project & Enable API
Open the Google Cloud Console.
Create a New Project: Click the project dropdown (top left) → "New Project" → Name it
Gmail MCP→ "Create".Enable Gmail API: Search for "Gmail API" in the search bar → Click it → Click Enable.
2. Configure OAuth Consent Screen
Go to APIs & Services → OAuth consent screen.
Select User Type: "External" (or "Internal" if you have a Google Workspace) → Click Create.
App Information: Fill in "App name" (e.g.,
Gmail MCP) and "User support email".Developer Contact: Fill in your email address.
Click Save and Continue until you reach the Summary.
Add Test Users: Go back to the "OAuth consent screen" tab → Under "Test users" → Click + ADD USERS → Enter your Gmail address → Click Save.
3. Generate Credentials
Go to APIs & Services → Credentials.
Click + CREATE CREDENTIALS → Select OAuth client ID.
Application type: Select Desktop app.
Name: Give it a name (e.g.,
Gmail MCP Client).Click Create.
Download JSON: In the "OAuth 2.0 Client IDs" list, click the download icon (↓) for your new client.
Rename & Move: Save this file as
credentials.jsonin your project folder (or keep it ready for the setup wizard).
4. Run the Setup Wizard
Open your terminal and run:
npx gmail-mcp-server setupThe wizard will guide you through:
Finding your
credentials.json.Selecting your AI client (Claude, Cursor, etc.).
Authorizing the app via your browser.
🖥️ Client Configuration
Claude Desktop
npx gmail-mcp-server setup # Select "Claude Desktop"Or manually add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["-y", "gmail-mcp-server"]
}
}
}Claude Code
npx gmail-mcp-server setup # Select "Claude Code"Or add to ~/.claude/mcp.json:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["-y", "gmail-mcp-server"]
}
}
}Cursor
npx gmail-mcp-server setup # Select "Cursor"Or add to .cursor/mcp.json:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["-y", "gmail-mcp-server"]
}
}
}Windsurf
npx gmail-mcp-server setup # Select "Windsurf"🛠️ CLI Commands
npx gmail-mcp-server setup # Interactive setup wizard
npx gmail-mcp-server auth # Run OAuth flow
npx gmail-mcp-server serve # Start MCP server (default)
npx gmail-mcp-server doctor # Diagnose issues
npx gmail-mcp-server --help # Show help
npx gmail-mcp-server --version # Show version🩺 Troubleshooting
If you run into issues, try the following:
Run the Doctor:
npx gmail-mcp-server doctorwill diagnose common problems with your credentials, tokens, and system.Missing
credentials.json: Ensure you've downloaded the file from Google Cloud Console and it's named exactlycredentials.jsonin your current directory.Invalid Grant / Expired Token: If the server can't connect, try running
npx gmail-mcp-server authto reset your OAuth tokens.Port 3000 Busy: The auth flow uses port 3000. If it's busy, the flow might fail. Ensure no other apps are using port 3000 during setup.
💬 Usage Examples
Once configured, ask your AI agent:
"Search my emails for unread messages from GitHub"
"Get the full content of email ID 18abc123"
"Show me the whole thread for this conversation"
"Reply to that email saying thanks"
"Forward the invoice to accounting@company.com"
"Create a draft reply for that message"
"Mark all newsletters from last month as read"
"Extract all email addresses from my last 50 emails"
"Who do I email most frequently?"
"Download the PDF attachment from that email"
🔒 Security
credentials.json— never committed (in.gitignore)Tokens stored in
~/.gmail-mcp/token.json— outside the project, auto-refreshedOAuth scope:
gmail.modify(read + modify, no permanent delete or admin)All data stays local — no external servers, no telemetry
🌍 Environment Variables
Variable | Default | Description |
|
| Path to your OAuth credentials file |
|
| Base directory for credentials lookup |
🤝 Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
git clone https://github.com/neutral-Stage/gmail-mcp-server.git
cd gmail-mcp-server
npm install
npm run build📄 License
MIT — use it however you want.
Available Tools
22 toolsadvanced_filterA
Search emails with multiple criteria and optionally apply a bulk action to all matching results. Useful for inbox cleanup, bulk labeling, or archiving by rule.
Inputs: query (required), maxResults, action, labelId, +1 more.
batch_modify_emailsA
Apply the same label modifications to multiple emails at once (up to 1000 IDs).
Inputs: ids (required), addLabelIds, removeLabelIds.
batch_trash_emailsA
Move multiple emails to Trash at once by adding the TRASH label and removing INBOX.
Inputs: ids (required).
create_draftA
Create a draft email (not sent). Optionally attach it to an existing thread for a draft reply.
Inputs: to (required), subject (required), body (required), cc, +3 more.
create_labelB
Create a new Gmail label (folder).
Inputs: name (required), messageListVisibility, labelListVisibility.
delete_labelA
Delete a user-created Gmail label. System labels (INBOX, SENT, etc.) cannot be deleted.
Inputs: labelId (required).
extract_addressesB
Extract unique email addresses from messages matching a Gmail query. Useful for building contact lists.
Inputs: query (required), maxMessages, fields.
format_emailsA
Re-format and filter a list of email objects (previously fetched) into a custom structure. Supports field selection, filtering by field value, and sorting.
Inputs: emails (required), fields, filterBy, sortBy, +1 more.
forward_emailB
Forward an existing email to new recipients, optionally adding a note above the original message.
Inputs: id (required), to (required), note, cc, +1 more.
get_attachmentA
Download an email attachment by message ID and attachment ID. Returns base64-encoded content with metadata. Use get_email first to find attachment IDs.
Inputs: messageId (required), attachmentId (required).
get_emailB
Get the full content of an email by its ID, including body text and attachment info.
Inputs: id (required), preferHtml.
get_frequent_contactsB
Analyze recent sent emails to find your most frequently contacted email addresses. No extra API scope needed.
Inputs: maxSent.
get_profileA
Get the authenticated user's Gmail profile: email address, total messages, total threads, and history ID.
Inputs: no named parameters.
get_threadB
Get all messages in an email thread by thread ID.
Inputs: threadId (required), preferHtml.
list_labelsA
List all Gmail labels (system and user-created), including their IDs needed for modify operations.
Inputs: no named parameters.
mark_spamB
Mark one or more emails as spam (moves to Spam folder).
Inputs: ids (required).
modify_emailB
Modify a single email: add/remove labels, mark as read/unread, archive, or move to trash.
Inputs: id (required), addLabelIds, removeLabelIds.
reply_emailA
Reply to an existing email. Automatically sets In-Reply-To and References headers and keeps the thread.
Inputs: id (required), body (required), replyAll, isHtml, +1 more.
search_emailsA
Search Gmail using Gmail query syntax (e.g. 'from:alice@example.com', 'is:unread', 'subject:invoice'). Returns message summaries.
Inputs: query (required), maxResults, pageToken.
send_emailC
Compose and send a new email.
Inputs: to (required), subject (required), body (required), cc, +2 more.
trash_emailA
Move an email to Trash (recoverable for 30 days).
Inputs: id (required).
untrash_emailB
Restore an email from Trash back to the inbox.
Inputs: id (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 22 tools
Each tool has a distinct purpose: email CRUD, label management, batch operations, search with bulk actions, etc. Even similar tools like send_email vs create_draft vs reply_email are clearly differentiated by their descriptions.
Most tools follow a verb_noun pattern in snake_case (e.g., create_draft, send_email). However, 'advanced_filter' breaks the pattern as an adjective_noun, and 'batch_modify_emails' uses a prefix, but overall the naming is largely consistent.
With 22 tools, the server covers a comprehensive set of Gmail operations. While slightly above the typical 3-15 range, each tool appears justified and contributes to the complete email management workflow.
The tool set covers the full lifecycle of emails: create, send, receive, reply, forward, trash, untrash, label management, batch operations, attachment handling, search with advanced filtering, and contacts. No obvious gaps.
Related MCP Connectors
Email infrastructure for AI agents — send, receive, search, and reply to email over MCP.
Email inboxes for AI agents: send, receive, reply, search, and manage threaded email over MCP.
Email for AI agents: read, search and send from your Gmail, Outlook, Yahoo, iCloud or IMAP inbox.
Real email inboxes for AI agents: register, receive, read and send mail over MCP. Free to receive.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables users to manage Gmail accounts using AI agent-assisted operations via an MCP protocol, supporting email search, reading, deletion, and sending with a voice-powered interface.55 npm12Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables interaction with Gmail through the MCP protocol, supporting sending, reading, searching, replying, forwarding, managing drafts and labels, and saving attachments.7 npm3MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Gmail through a standardized MCP server interface, allowing for natural language email management and automation.-
- FlicenseNot gradedqualityDmaintenanceFull Gmail control for any MCP-compatible AI agent. Exposes ~40 tools for reading, composing, labeling, filtering, threading, and account management.-