gmail-mcp-server
Provides tools for reading, sending, searching, and managing Gmail emails, drafts, labels, threads, and attachments through the Google Gmail API.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
gmail-mcp-server
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).
Tools
Email Operations (5)
Tool | Description |
| Search emails using Gmail query syntax |
| Get full email content by ID |
| Send an email (supports CC, BCC, reply threading) |
| Get all messages in a thread |
| Get your Gmail profile info |
Drafts (4)
Tool | Description |
| Create a draft email |
| List all saved drafts |
| Send an existing draft |
| Delete a draft |
Labels (3)
Tool | Description |
| List all labels |
| Create a new label |
| Delete a label |
Message Management (4)
Tool | Description |
| Move email to trash |
| Restore email from trash |
| Mark email as read |
| Mark email as unread |
| Add or remove labels from an email |
Attachments (2)
Tool | Description |
| List all attachments in an email |
| Download attachment as base64 |
Related MCP server: Gmail MCP Local Server
Setup
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.
Step 1 — Create a Google Cloud Project
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 CreateMake sure the new project is selected
Step 2 — Enable the Gmail API
In the left menu go to "APIs & Services" → "Library"
Search for "Gmail API"
Click it → click "Enable"
Step 3 — Configure OAuth Consent Screen
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
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.labelsClick Save and Continue
On Test users, click "Add Users" → add your Gmail address
Click Save and Continue → Back to Dashboard
Step 4 — Create OAuth Client ID
Go to "APIs & Services" → "Credentials"
Click "+ Create Credentials" → "OAuth client ID"
Application type: "Desktop app"
Name:
Gmail MCP ServerClick Create
Click "Download JSON" — save this file, you'll need it next
Step 5 — Install & Authenticate
# 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.
Step 6 — Add to Claude Code
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"]
}
}
}Multiple Accounts
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 authGmail Search Syntax
The 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 spamCombine queries:
from:client@company.com is:unread has:attachment
subject:urgent OR subject:important
from:boss@company.com after:2024/06/01Configuration
Environment Variable | Default | Description |
|
| Directory for credentials and token |
Data & Auth Storage
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.
Troubleshooting
"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).
Requirements
Node.js 18+
A Google account (personal Gmail or Google Workspace)
Google Cloud project with Gmail API enabled (see setup above)
License
MIT — Hitesh Gupta
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Connect any IMAP/SMTP mailbox to Claude & ChatGPT: search, read, sort, draft. Sends only with OK.
Connect any mailbox to Claude, ChatGPT & AI: read, send, reply, schedule & search emails.
Manage Gmail end-to-end: search, read, send, draft, label, and organize threads. Automate workflow…
Bring Gmail, Outlook, iCloud Mail, Yahoo Mail, Fastmail and other IMAP mailboxes together. Search connected email, including semantic search; cached or indexed results may be incomplete or stale. Read messages and attachments, create drafts, send or reply when requested, and manage rules for new mail. Separate permissions control reading, attachments, drafts, sending and mailbox changes.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables Claude to read, search, send, label, and trash emails in any Gmail account via Google's Gmail API, using OAuth2 authentication with automatic token refresh.67 npmMIT
- FlicenseNot gradedqualityDmaintenanceProvides Claude with Gmail capabilities including sending emails, managing drafts, and searching messages.-
- FlicenseBqualityDmaintenanceEnables Claude to read unread emails and create draft responses using the Gmail API.2-
- AlicenseNot gradedqualityDmaintenanceEnables Claude to read, search, send, and manage Gmail messages and threads through natural language.239 npmMIT