mcp-server-gmail
v0.1.5
Published
Gmail MCP Server - A Model Context Protocol server for Gmail integration
Downloads
43
Maintainers
Readme
Gmail MCP Server
A Model Context Protocol (MCP) server that provides Gmail integration for AI assistants and chatbots.
Quick Start
# Install and run (requires Python 3.10+)
npx mcp-server-gmailFeatures
- 📧 Send emails
- 📬 Read unread emails
- 🔍 Search emails by sender
- 📖 Read specific email content
- 🗑️ Move emails to trash
- ✅ Mark emails as read
- 🌐 Open emails in browser
- 🎯 AI-powered email drafting and management
Setup
1. Google Cloud Setup
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Gmail API:
- Go to APIs & Services > Library
- Search for "Gmail API"
- Click Enable
2. OAuth 2.0 Credentials
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- Select Desktop application
- Download the credentials file as
credentials.json
3. Install and Setup
# Install the MCP server
npx mcp-server-gmail --help
# Create config directory and place credentials
mkdir -p ~/.gmail-mcp
cp /path/to/your/credentials.json ~/.gmail-mcp/credentials.json4. First Run
# Start the server (will open browser for OAuth)
npx mcp-server-gmailThe first run will open a browser window for OAuth authentication. Grant the necessary permissions, and the server will store the tokens for future use.
Configuration
Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": ["-y", "mcp-server-gmail"]
}
}
}Custom Paths
{
"mcpServers": {
"gmail": {
"command": "npx",
"args": [
"-y",
"mcp-server-gmail",
"--creds-file-path", "/path/to/credentials.json",
"--token-path", "/path/to/token.json"
]
}
}
}Other MCP Hosts
For other MCP-compatible applications, use:
npx -y mcp-server-gmailAvailable Tools
send-email
Send an email to a recipient.
Parameters:
recipient_id(string): Email address of the recipientsubject(string): Email subjectmessage(string): Email body content
get-unread-emails
Retrieve all unread emails from your inbox.
read-email
Read the content of a specific email.
Parameters:
email_id(string): The ID of the email to read
get-emails-by-sender
Get emails from a specific sender.
Parameters:
sender_email(string): Email address of the senderunread_only(boolean, optional): Only fetch unread emails
trash-email
Move an email to trash.
Parameters:
email_id(string): The ID of the email to trash
mark-as-read
Mark an email as read.
Parameters:
email_id(string): The ID of the email to mark as read
open-email
Open an email in your default web browser.
Parameters:
email_id(string): The ID of the email to open
Available Prompts
manage-email
Act as an email administrator with access to Gmail tools.
draft-email
Draft an email with specified content and recipient.
Arguments:
content: What the email is aboutrecipient: Who the email should be addressed torecipient_email: Recipient's email address
edit-draft
Edit an existing email draft.
Arguments:
changes: What changes should be made to the draftcurrent_draft: The current draft to edit
Usage Examples
With Claude Desktop
Once configured, you can ask Claude:
- "Check my unread emails"
- "Send an email to [email protected] about the meeting tomorrow"
- "Show me all emails from [email protected]"
- "Draft a professional email to the client about the project update"
Command Line Usage
# Basic usage
npx mcp-server-gmail
# Custom credentials path
npx mcp-server-gmail --creds-file-path /path/to/creds.json
# Custom token storage
npx mcp-server-gmail --token-path /path/to/token.json
# Help
npx mcp-server-gmail --helpRequirements
- Python 3.10+ (automatically checked during setup)
- Node.js 18+ (for npx)
- Google Cloud Project with Gmail API enabled
- OAuth 2.0 credentials for Gmail access
Troubleshooting
Python Not Found
# Install Python 3.12+
# macOS
brew install python3
# Ubuntu/Debian
sudo apt install python3
# Windows
# Download from python.orgOAuth Errors
- Ensure Gmail API is enabled in Google Cloud Console
- Check that OAuth consent screen is configured
- Verify credentials file is valid JSON
- Try deleting token file and re-authenticating
Permission Errors
The server requests minimal permissions:
https://www.googleapis.com/auth/gmail.modify
This allows reading, sending, and managing emails but not deleting them permanently.
Security Notes
- Credentials and tokens are stored locally
- The server runs locally and doesn't send data to external services
- OAuth tokens are automatically refreshed as needed
- No email content is logged or stored beyond the session
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
Changelog
v0.1.0
- Initial release
- Basic Gmail integration
- Support for send, read, search, trash operations
- OAuth 2.0 authentication
- Cross-platform compatibility
