Manage Gmail through natural language with auto-authentication support.
Gmail AutoAuth MCP Server
A Model Context Protocol (MCP) server for Gmail integration in Claude Desktop with auto authentication support. This server enables AI assistants to manage Gmail through natural language interactions.
Features
- Send emails with subject, content, attachments, and recipients
- Full support for international characters in subject lines and email content
- Read email messages by ID with advanced MIME structure handling
- View email attachments information (filenames, types, sizes)
- Search emails with various criteria (subject, sender, date range)
- Comprehensive label management with ability to create, update, delete and list labels
- List all available Gmail labels (system and user-defined)
- List emails in inbox, sent, or custom labels
- Mark emails as read/unread
- Move emails to different labels/folders
- Delete emails
- Batch operations for efficiently processing multiple emails at once
- Full integration with Gmail API
- Simple OAuth2 authentication flow with auto browser launch
- Support for both Desktop and Web application credentials
- Global credential storage for convenience
Installation & Authentication
Installing via Smithery
To install Gmail AutoAuth for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @raghavared/gmail-mcp --client claude
Installing Manually
Create a Google Cloud Project and obtain credentials:
a. Create a Google Cloud Project:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API for your project
b. Create OAuth 2.0 Credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose either "Desktop app" or "Web application" as application type
- Give it a name and click "Create"
- For Web application, add
http://localhost:3000/v2/auth/google/callbackto the authorized redirect URIs - Download the JSON file of your client's OAuth keys
- Rename the key file to
token.json
Run Authentication:
You can authenticate in two ways:
a. Global Authentication (Recommended):
# First time: Place token.json in your home directory's .gmail-mcp folder mkdir -p ~/.gmail-mcp mv token.json ~/.gmail-mcp/ # Run authentication from anywhere npx @raghavared/gmail-mcp authb. Local Authentication:
# Place token.json in your current directory # The file will be automatically copied to global config npx @raghavared/gmail-mcp authThe authentication process will:
- Look for
token.jsonin the current directory or~/.gmail-mcp/ - If found in current directory, copy it to
~/.gmail-mcp/ - Open your default browser for Google authentication
- Save credentials as
~/.gmail-mcp/credentials.json
Note:
- After successful authentication, credentials are stored globally in
~/.gmail-mcp/and can be used from any directory - Both Desktop app and Web application credentials are supported
- For Web application credentials, make sure to add
http://localhost:3000/v2/auth/google/callbackto your authorized redirect URIs
- Look for
Configure in Claude Desktop:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": [
"@raghavared/gmail-mcp"
]
}
}
}
Docker Support
If you prefer using Docker:
- Authentication:
docker run -i --rm \
--mount type=bind,source=/path/to/token.json,target=/token.json \
-v gmail-mcp:/gmail-server \
-e GMAIL_OAUTH_PATH=/token.json \
-e "GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json" \
-p 3000:3000 \
mcp/gmail auth
- Usage:
{
"mcpServers": {
"gmail": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-v",
"mcp-gmail:/gmail-server",
"-e",
"GMAIL_CREDENTIALS_PATH=/gmail-server/credentials.json",
"gmail-mcp"
]
}
}
}
Cloud Server Authentication
For cloud server environments (like n8n), you can specify a custom callback URL during authentication:
npx @raghavared/gmail-mcp auth {domain}/v2/auth/google/callback
Setup Instructions for Cloud Environment
Configure Reverse Proxy:
- Set up your n8n container to expose a port for authentication
- Configure a reverse proxy to forward traffic from your domain (e.g.,
domain.com) to this port
DNS Configuration:
- Add an A record in your DNS settings to resolve your domain to your cloud server's IP address
Google Cloud Platform Setup:
- In your Google Cloud Console, add your c
Tools (5)
send_emailSend emails with subject, content, attachments, and recipients.read_emailRead email messages by ID with advanced MIME structure handling.search_emailsSearch emails with various criteria like subject, sender, and date range.manage_labelsCreate, update, delete, and list Gmail labels.batch_operationsEfficiently process multiple emails at once.Environment Variables
GMAIL_OAUTH_PATHPath to the token.json file for authenticationGMAIL_CREDENTIALS_PATHPath where the generated credentials.json will be storedConfiguration
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": [
"@raghavared/gmail-mcp"
]
}
}
}