Help us improve
Share bugs, ideas, or general feedback.
From claude-commands
Integrates Gmail with Claude Code via MCP for email processing: read, search, send, draft, manage labels, attachments, filters, and extract action items.
npx claudepluginhub jleechanorg/claude-commands --plugin claude-commandsHow this skill is triggered — by the user, by Claude, or both
Slash command
/claude-commands:mcp-gmail-agentThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill provides comprehensive setup and usage documentation for integrating Gmail with Claude Code via MCP (Model Context Protocol) servers, enabling intelligent email processing and automation.
Unified CLI for Google Workspace: manage Drive files, send/read Gmail, query/edit Sheets/Docs, handle Calendar/Chat/Admin via terminal or AI agents.
Automates Gmail operations like searching, reading, sending emails, managing drafts/labels via Python CLI scripts with standalone OAuth. Requires Google Workspace.
Automates Gmail tasks via Rube MCP (Composio): send/reply emails, search/filter threads, manage labels/drafts/attachments. Requires active Gmail OAuth connection.
Share bugs, ideas, or general feedback.
This skill provides comprehensive setup and usage documentation for integrating Gmail with Claude Code via MCP (Model Context Protocol) servers, enabling intelligent email processing and automation.
Purpose: Enable Claude to interact with Gmail for automated email processing, including reading, analyzing, drafting responses, organizing, and taking actions based on email content.
Core Capabilities:
Features:
Installation:
# Install via npm (optional, npx can run without install)
npm install -g @gongrzhe/server-gmail-autoauth-mcp
Configuration in .claude/settings.json:
{
"mcpServers": {
"gmail-autoauth": {
"command": "npx",
"args": [
"-y",
"@gongrzhe/server-gmail-autoauth-mcp"
]
}
}
}
Security note: The
-yflag auto-accepts package installation each time the MCP server launches. For production or security-sensitive environments, pin a vetted version by installing the package explicitly (npm install) and reference the local binary instead of relying onnpx -y.
Authentication Setup:
# 1. Set up Google Cloud Project and get OAuth credentials
# Download gcp-oauth.keys.json from Google Cloud Console
# 2. Place credentials in home directory
mkdir -p ~/.gmail-mcp
cp path/to/gcp-oauth.keys.json ~/.gmail-mcp/
# 3. Run authentication flow
npx @gongrzhe/server-gmail-autoauth-mcp auth
# 4. Follow browser OAuth flow to grant permissions
Features:
Installation:
# Clone repository
git clone https://github.com/tjzaks/gmail-mcp-server.git
cd gmail-mcp-server
# Install dependencies
npm install
# Build project
npm run build
Configuration in .claude/settings.json:
{
"mcpServers": {
"gmail": {
"command": "node",
"args": [
"/path/to/gmail-mcp-server/build/index.js"
],
"env": {
"GMAIL_CREDENTIALS_PATH": "${HOME}/.gmail-mcp/credentials.json",
"GMAIL_TOKEN_PATH": "${HOME}/.gmail-mcp/token.json"
}
}
}
}
Features:
Installation:
# Install Chrome extension
# Visit: https://github.com/cafferychen777/gmail-mcp
# Extension handles authentication automatically using active Gmail session
Configuration in .claude/settings.json:
{
"mcpServers": {
"gmail-chrome": {
"command": "npx",
"args": [
"-y",
"@cafferychen777/gmail-mcp"
]
}
}
}
Environment compatibility: This approach assumes access to a Chrome browser session. It is typically unsuitable for headless or CLI-only Claude Code environments where browser extensions cannot run.
# 1. Visit Google Cloud Console: https://console.cloud.google.com
# 2. Create new project or select existing
# 3. Enable Gmail API:
# - Navigate to "APIs & Services" > "Library"
# - Search for "Gmail API"
# - Click "Enable"
# 1. Navigate to "APIs & Services" > "OAuth consent screen"
# 2. Select "External" user type (or "Internal" for Workspace)
# 3. Fill in application details:
# - App name: "Claude MCP Gmail"
# - User support email: your email
# - Developer contact: your email
# 4. Add scopes:
# - .../auth/gmail.readonly (read emails)
# - .../auth/gmail.modify (modify labels, archive)
# - .../auth/gmail.compose (draft and send)
# - .../auth/gmail.labels (manage labels)
# 1. Navigate to "APIs & Services" > "Credentials"
# 2. Click "Create Credentials" > "OAuth client ID"
# 3. Application type: "Desktop app"
# 4. Name: "Claude Gmail MCP"
# 5. Download JSON file as "gcp-oauth.keys.json"
# Create directory
mkdir -p ~/.gmail-mcp
# Copy credentials
cp ~/Downloads/gcp-oauth.keys.json ~/.gmail-mcp/
# Secure permissions
chmod 600 ~/.gmail-mcp/gcp-oauth.keys.json
# Run authentication command
npx @gongrzhe/server-gmail-autoauth-mcp auth
# Or for other implementations:
node /path/to/gmail-mcp-server/build/auth.js
What happens:
~/.gmail-mcp/token.json# For auto-auth implementation
npx @gongrzhe/server-gmail-autoauth-mcp status
# Manually check token file
cat ~/.gmail-mcp/token.json | jq .
Automatic: MCP server automatically refreshes expired access tokens using refresh token
Manual:
npx @gongrzhe/server-gmail-autoauth-mcp refresh
Proactive rotation: Schedule periodic re-authentication (e.g., quarterly) for long-running deployments to ensure credentials remain valid even if refresh tokens lapse due to inactivity.
If refresh token expires (rare, typically 6 months of inactivity):
# Delete old token
rm ~/.gmail-mcp/token.json
# Re-authenticate
npx @gongrzhe/server-gmail-autoauth-mcp auth
Email Reading:
mcp__gmail__get_messages - Retrieve messages by querymcp__gmail__get_message - Get specific message by IDmcp__gmail__search - Search emails with Gmail query syntaxmcp__gmail__list_unread - Get unread messagesEmail Sending:
mcp__gmail__send_message - Send new emailmcp__gmail__create_draft - Create draft emailmcp__gmail__reply - Reply to messagemcp__gmail__forward - Forward messageOrganization:
mcp__gmail__apply_label - Add label to messagemcp__gmail__remove_label - Remove label from messagemcp__gmail__create_label - Create new labelmcp__gmail__archive - Archive messagemcp__gmail__trash - Move to trashmcp__gmail__star - Star/unstar messageAdvanced:
mcp__gmail__get_attachment - Download attachmentmcp__gmail__batch_modify - Modify multiple messagesmcp__gmail__get_threads - Retrieve email threadsmcp__gmail__modify_thread - Modify entire threadTool discovery tip: The names shown above match the actual tool identifiers exposed by most Gmail MCP servers. Run
list-tools(or check the server's README) after connecting to confirm the exact names available in your deployment.
# Unread messages
is:unread
# From specific sender
from:example@domain.com
# Subject contains
subject:"Project Update"
# Has attachment
has:attachment
# Date range
after:2025/01/01 before:2025/01/31
# Multiple conditions
from:github.com is:unread has:attachment
# Exclude
-from:noreply@spam.com
# Specific label
label:important
# Claude command (after /processmsgs invoked)
Use mcp__gmail__list_unread to retrieve all unread messages
Filter and display sender, subject, date for each
# Analyze email content
# Generate contextually appropriate response
# Use mcp__gmail__create_draft with:
# - to: original sender
# - subject: RE: original subject
# - body: generated response
# - threadId: original thread (for threading)
# After processing email:
# 1. Apply label: mcp__gmail__apply_label(messageId, "claude-processed")
# 2. Archive: mcp__gmail__archive(messageId)
# 3. Report action taken
# Search for urgent emails from last 24h
Use mcp__gmail__search with query: "is:unread after:2025/01/20 (urgent OR deadline)"
For each result:
- Parse content
- Extract action items
- Create draft response
- Apply "urgent" label
The /processmsgs command leverages these MCP tools to:
mcp__gmail__list_unreadmcp__gmail__create_draftmcp__gmail__apply_labelmcp__gmail__archivemcp__gmail__star# Verify MCP server configuration
cat .claude/settings.json | jq .mcpServers
# Test npx execution manually
npx -y @gongrzhe/server-gmail-autoauth-mcp --help
# Check Claude Code logs for MCP startup errors
# Check credentials exist
ls -la ~/.gmail-mcp/
# Verify credentials format
cat ~/.gmail-mcp/gcp-oauth.keys.json | jq .
# Re-run authentication
npx @gongrzhe/server-gmail-autoauth-mcp auth
# Check token validity
cat ~/.gmail-mcp/token.json | jq .expiry_date
# Ensure proper OAuth scopes in Google Cloud Console
# Required scopes:
# - https://www.googleapis.com/auth/gmail.readonly
# - https://www.googleapis.com/auth/gmail.modify
# - https://www.googleapis.com/auth/gmail.compose
# - https://www.googleapis.com/auth/gmail.labels
# Delete token and re-authenticate to get new scopes
rm ~/.gmail-mcp/token.json
npx @gongrzhe/server-gmail-autoauth-mcp auth
# Gmail API quotas (per Google Cloud Project):
# - 1 billion quota units/day
# - 250 quota units/user/second
#
# Solutions:
# 1. Implement exponential backoff
# 2. Batch requests when possible
# 3. Request quota increase in Google Cloud Console
# Find process using port 9005
lsof -ti:9005 | xargs kill -9
# Or modify MCP server config to use different port
# (server-specific, check documentation)
Credentials Security:
# Always secure credential files
chmod 600 ~/.gmail-mcp/gcp-oauth.keys.json
chmod 600 ~/.gmail-mcp/token.json
# Never commit to version control
echo "~/.gmail-mcp/" >> ~/.gitignore
Scope Minimization:
gmail.full-access scope unless absolutely necessaryToken Management:
MCP Server Trust:
Optimization Strategies:
Rate Limiting:
# Implement delays between requests
# Typical safe rate: 1 request/second for sustained operations
# Burst operations: up to 10 requests/second briefly
/processmsgs - Main command using this MCP integration/memory - Store extracted tasks and action items/learn - Learn from email patterns and improve processingOfficial Documentation:
MCP Gmail Implementations:
Community:
Test MCP Gmail Setup:
# 1. Restart Claude Code after configuration
# 2. Try simple email read command:
/processmsgs recent
# 3. Check for MCP tool calls in output
# Expected: mcp__gmail__* tools being invoked
# 4. Verify actions taken (drafts, labels, etc.)
# Check Gmail web interface for changes
# 1. Choose MCP implementation (recommend: @gongrzhe/server-gmail-autoauth-mcp)
# 2. Set up Google Cloud Project and get OAuth credentials
# 3. Configure in .claude/settings.json
# 4. Authenticate
npx @gongrzhe/server-gmail-autoauth-mcp auth
# 5. Restart Claude Code
# 6. Test with /processmsgs command
/processmsgs
# 7. Verify emails processed and actions taken
Potential Additions: