Provides comprehensive tools for managing email accounts, including searching, reading, sending, and deleting emails, as well as managing labels, filters, and attachments.
Click on "Install 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 Serversearch for recent emails from GitHub and summarize the main points"
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.
Gmail MCP Server
A comprehensive Model Context Protocol (MCP) server for Gmail, providing 24 tools for full email management including sending, receiving, labels, filters, attachments, and batch operations.
Features
24 Gmail Tools: Full email operations, label management, filters, batch operations, and attachments
Multi-Account Support: Manage multiple Gmail accounts with
--accountflagOAuth Authentication: Secure authentication with automatic token refresh
Attachment Support: Download and send attachments
Batch Operations: Efficiently modify or delete up to 1000 emails at once
Filter Templates: Pre-built filter templates for common use cases
MCP Resources: Access messages, threads, and labels via URI
Prerequisites
Node.js 18+
A Google Cloud Project with Gmail API enabled
OAuth 2.0 credentials (Desktop app type)
Setup
1. Create Google Cloud OAuth Credentials
Go to Google Cloud Console
Create a new project or select an existing one
Enable the Gmail API:
Navigate to "APIs & Services" > "Library"
Search for "Gmail API"
Click "Enable"
Create OAuth credentials:
Go to "APIs & Services" > "Credentials"
Click "Create Credentials" > "OAuth Client ID"
If prompted, configure the OAuth consent screen:
Choose "External" user type (or "Internal" for Workspace)
Fill in required fields (app name, user support email, developer email)
Add scopes:
gmail.modifyandgmail.settings.basicAdd your email as a test user
Select "Desktop app" as the application type
Name it (e.g., "Gmail MCP")
Click "Create"
Download the JSON credentials file
2. Install and Configure
The auth command will:
Open your browser to Google's OAuth consent page
Ask you to authorize the application
Save the tokens to
~/.gmail-mcp/tokens/<account>.json
To list authenticated accounts:
3. Add to Claude Code
For a single account:
For multiple accounts, add each with its own name:
Or add manually to your Claude Code MCP settings:
Available Tools
Email Operations (7 tools)
Tool | Description |
| Search with Gmail query syntax, pagination |
| Full message with headers, body, attachment info |
| Send with to/cc/bcc, attachments, threading |
| Create draft without sending |
| Trash or permanent delete |
| Add/remove labels from message |
| Get full conversation thread |
Label Management (6 tools)
Tool | Description |
| All labels (system + user) |
| Create with color, visibility |
| Rename, change settings |
| Remove custom label |
| Idempotent label creation |
| Get single label details |
Filter Management (5 tools)
Tool | Description |
| All Gmail filters |
| Single filter details |
| Custom criteria + actions |
| Remove filter |
| Preset templates |
Batch Operations (2 tools)
Tool | Description |
| Bulk add/remove labels (50 at a time) |
| Bulk delete with fallback |
Attachments (2 tools)
Tool | Description |
| Save to local filesystem |
| Get attachment metadata for message |
Utilities (2 tools)
Tool | Description |
| User email address, history ID |
| Storage usage info |
Resources
Resource | URI Pattern |
Message |
|
Thread |
|
Label |
|
Usage Examples
Search for unread emails
Read a specific email
Send an email
Create a filter
Batch operations
OAuth Scopes
The server uses these scopes:
gmail.modify- Read, compose, send, and modify emails and labelsgmail.settings.basic- Manage mail filters
File Structure
Security
Credentials stored in
~/.gmail-mcp/with restricted permissions (0600)Per-account tokens stored in
~/.gmail-mcp/tokens/Tokens automatically refresh when expired
OAuth callback only on localhost
No external telemetry or data collection
Troubleshooting
"Not authenticated" error
Run node dist/index.js auth --account <name> to authenticate.
"Permission denied" error
Ensure your OAuth credentials have the correct scopes and the Gmail API is enabled.
Token refresh fails
Delete ~/.gmail-mcp/tokens/<account>.json and run auth again.
Port 3000 in use
The OAuth callback requires port 3000. Close any applications using this port.
License
MIT