Gmail MCP Server — read, send, search, and manage Gmail through Claude using Google's official API.
19 tools for emails, drafts, labels, threads, and attachments — powered by the official Google Gmail API with OAuth 2.0. Works with any Google account (personal Gmail or Google Workspace).
| Tool | Description |
|---|---|
gmail_search |
Search emails using Gmail query syntax |
gmail_get_message |
Get full email content by ID |
gmail_send |
Send an email (supports CC, BCC, reply threading) |
gmail_get_thread |
Get all messages in a thread |
gmail_get_profile |
Get your Gmail profile info |
| Tool | Description |
|---|---|
gmail_create_draft |
Create a draft email |
gmail_list_drafts |
List all saved drafts |
gmail_send_draft |
Send an existing draft |
gmail_delete_draft |
Delete a draft |
| Tool | Description |
|---|---|
gmail_list_labels |
List all labels |
gmail_create_label |
Create a new label |
gmail_delete_label |
Delete a label |
| Tool | Description |
|---|---|
gmail_trash |
Move email to trash |
gmail_untrash |
Restore email from trash |
gmail_mark_read |
Mark email as read |
gmail_mark_unread |
Mark email as unread |
gmail_modify_labels |
Add or remove labels from an email |
| Tool | Description |
|---|---|
gmail_list_attachments |
List all attachments in an email |
gmail_get_attachment |
Download attachment as base64 |
This server uses Google's official Gmail API. You need to create OAuth 2.0 credentials once in Google Cloud Console — this takes about 5 minutes.
- Go to console.cloud.google.com
- Click the project dropdown at the top → "New Project"
- Give it a name (e.g.
gmail-mcp) and click Create - Make sure the new project is selected
- In the left menu go to "APIs & Services" → "Library"
- Search for "Gmail API"
- Click it → click "Enable"
- Go to "APIs & Services" → "OAuth consent screen"
- Choose "External" (works for any Google account) → click Create
- Fill in:
- App name:
Gmail MCP Server(or anything) - User support email: your email
- Developer contact email: your email
- App name:
- Click Save and Continue
- On the Scopes page, click "Add or Remove Scopes" and add these:
https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.labels - Click Save and Continue
- On Test users, click "Add Users" → add your Gmail address
- Click Save and Continue → Back to Dashboard
- Go to "APIs & Services" → "Credentials"
- Click "+ Create Credentials" → "OAuth client ID"
- Application type: "Desktop app"
- Name:
Gmail MCP Server - Click Create
- Click "Download JSON" — save this file, you'll need it next
# Install the package
npm install -g @dev-hitesh-gupta/gmail-mcp-server
# Install dependencies for first run
npx playwright install chromium 2>/dev/null; true
# Create config directory and place your credentials
mkdir -p ~/.gmail-mcp
cp /path/to/downloaded-credentials.json ~/.gmail-mcp/credentials.json
# Authenticate — opens a browser window for Google sign-in
gmail-mcp-server authYour token is saved to ~/.gmail-mcp/token.json and auto-refreshed on expiry.
claude mcp add gmail -- npx @dev-hitesh-gupta/gmail-mcp-serverOr manually in your Claude config (~/.claude/claude_desktop_config.json):
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["@dev-hitesh-gupta/gmail-mcp-server"]
}
}
}You can connect multiple Gmail accounts by running separate server instances with different config directories:
{
"mcpServers": {
"gmail-work": {
"command": "npx",
"args": ["@dev-hitesh-gupta/gmail-mcp-server"],
"env": { "GMAIL_MCP_CONFIG_DIR": "~/.gmail-mcp-work" }
},
"gmail-personal": {
"command": "npx",
"args": ["@dev-hitesh-gupta/gmail-mcp-server"],
"env": { "GMAIL_MCP_CONFIG_DIR": "~/.gmail-mcp-personal" }
}
}
}Authenticate each separately:
GMAIL_MCP_CONFIG_DIR=~/.gmail-mcp-work gmail-mcp-server auth
GMAIL_MCP_CONFIG_DIR=~/.gmail-mcp-personal gmail-mcp-server authThe gmail_search tool supports the full Gmail query language:
from:boss@company.com # From specific sender
to:me # Sent to you
subject:invoice # Subject contains word
is:unread # Unread emails
is:starred # Starred emails
has:attachment # Has attachments
after:2024/01/01 # After date
before:2024/12/31 # Before date
label:work # Has label
in:inbox # In inbox
in:sent # In sent
in:spam # In spam
Combine queries:
from:client@company.com is:unread has:attachment
subject:urgent OR subject:important
from:boss@company.com after:2024/06/01
| Environment Variable | Default | Description |
|---|---|---|
GMAIL_MCP_CONFIG_DIR |
~/.gmail-mcp |
Directory for credentials and token |
All data is stored locally:
~/.gmail-mcp/
├── credentials.json # Your Google OAuth client credentials
└── token.json # Access + refresh token (auto-managed)
Security: Never commit
credentials.jsonortoken.jsonto version control. Add~/.gmail-mcp/to your.gitignore.
"Not authenticated" / "Credentials not found":
# Make sure credentials.json is in place
ls ~/.gmail-mcp/credentials.json
# Re-authenticate
gmail-mcp-server authToken expired:
rm ~/.gmail-mcp/token.json
gmail-mcp-server auth"Access blocked" during Google sign-in: Your OAuth app is in test mode. Go to Google Cloud Console → OAuth consent screen → add your email under Test users.
Scope errors: Ensure all 5 Gmail scopes are added in the OAuth consent screen (Step 3 above).
- Node.js 18+
- A Google account (personal Gmail or Google Workspace)
- Google Cloud project with Gmail API enabled (see setup above)
MIT — Hitesh Gupta