Gmail MCP Server
Allows Claude to interact with a Gmail account: list and search emails, read full email content, move emails to trash, permanently delete emails, and perform or preview bulk deletes based on Gmail search queries.
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
A Model Context Protocol (MCP) server that allows Claude Code to interact with your Gmail account for reading and deleting emails.
Features
List Emails: View your recent emails with summaries
Search Emails: Search using Gmail query syntax (unread, from specific senders, etc.)
Read Emails: Get full email content including body text
Delete Emails: Permanently delete or move to trash
Trash Emails: Move emails to trash (recoverable)
Related MCP server: Gmail MCP Server
Prerequisites
Python 3.10+ installed
Google Cloud Project with Gmail API enabled
OAuth 2.0 Credentials from Google Cloud Console
Setup Instructions
Step 1: Install Dependencies
cd gmail-mcp-server
pip install -r requirements.txtStep 2: Set Up Google Cloud Project
Go to Google Cloud Console
Create a new project (or select existing)
Enable the Gmail API:
Navigate to "APIs & Services" > "Library"
Search for "Gmail API"
Click "Enable"
Step 3: Create OAuth 2.0 Credentials
Go to "APIs & Services" > "Credentials"
Click "Create Credentials" > "OAuth client ID"
Choose "Desktop app" as application type
Name it "Gmail MCP Server"
Click "Create"
Download the JSON file and save it as
credentials.jsonin this directory
Step 4: Configure Environment
cp .env.example .envEdit .env and set the paths:
GMAIL_CREDENTIALS_PATH=~/git_repos/gmail-mcp-server/credentials.json
GMAIL_TOKEN_PATH=~/git_repos/gmail-mcp-server/token.jsonStep 5: Test the Server
Test with MCP Inspector:
npx @modelcontextprotocol/inspector ~/git_repos/gmail-mcp-server/server.pyOn first run, it will open a browser for you to authenticate with Google.
Step 6: Connect to Claude Code
Add the server to Claude Code:
claude mcp add --transport stdio gmail -- python3 ~/git_repos/gmail-mcp-server/server.pyOr manually edit ~/.claude.json:
{
"mcpServers": {
"gmail": {
"command": "python3",
"args": ["~/git_repos/gmail-mcp-server/server.py"],
"env": {
"GMAIL_CREDENTIALS_PATH": "~/git_repos/gmail-mcp-server/credentials.json",
"GMAIL_TOKEN_PATH": "~/git_repos/gmail-mcp-server/token.json"
}
}
}
}Available Tools
list_emails
List recent emails from your inbox.
Parameters:
max_results(optional): Number of emails to return (default: 10, max: 100)query(optional): Gmail search query
Example:
List my last 20 emailssearch_emails
Search emails using Gmail query syntax.
Parameters:
query: Gmail search querymax_results(optional): Number of results (default: 20, max: 100)
Example queries:
is:unread- All unread emailsfrom:boss@company.com- Emails from specific sendersubject:urgent- Emails with "urgent" in subjecthas:attachment- Emails with attachmentsnewer_than:7d- Emails from last 7 days
Example:
Search for unread emails from the last weekget_email
Get full details of a specific email including body text.
Parameters:
message_id: The Gmail message ID
Example:
Show me the full content of email ID 18c5a1b2f3d4e5f6delete_email
Permanently delete an email (cannot be recovered).
Parameters:
message_id: The Gmail message ID
Example:
Permanently delete email ID 18c5a1b2f3d4e5f6trash_email
Move an email to Trash (can be recovered later).
Parameters:
message_id: The Gmail message ID
Example:
Move email ID 18c5a1b2f3d4e5f6 to trashdelete_emails_by_query
Delete multiple emails matching a Gmail search query (BULK DELETE).
Parameters:
query: Gmail search query to find emails to deletemax_emails(optional): Maximum number to delete (default: 100, max: 500)permanent(optional): If True, permanently delete. If False, move to Trash (default: False)
Example queries:
is:unread older_than:1y- Delete unread emails older than 1 yearfrom:spam@example.com- Delete all emails from a sendersubject:newsletter older_than:6m- Delete old newslettershas:attachment larger:10M- Delete emails with large attachmentsis:read older_than:2y- Delete read emails older than 2 years
Example:
Delete all unread emails from last yearcount_emails_by_query
Count emails matching a query without deleting (useful for preview before bulk delete).
Parameters:
query: Gmail search query
Returns:
Count of matching emails and sample subjects
Example:
How many unread emails are older than 1 year?Usage in Claude Code
Once connected, you can ask Claude:
"List my last 10 emails"
"Search for unread emails"
"Show me emails from john@example.com"
"Delete email ID abc123"
"Show me the full content of the first email"
"Remove all emails that were unread in the last year"
"Delete all emails from newsletter@example.com"
"How many unread emails are older than 6 months?" (preview before deleting)
"Trash all read emails older than 2 years"
Troubleshooting
Authentication Issues
Make sure
credentials.jsonexists and has correct OAuth credentialsDelete
token.jsonand re-authenticate if you get token errors
Server Not Found
Use absolute paths in Claude Code configuration
Verify Python 3 is in your PATH:
which python3
Permission Errors
Check that Gmail API is enabled in Google Cloud Console
Verify OAuth consent screen is configured
Ensure you granted all requested permissions during authentication
Security Notes
Never commit
credentials.jsonortoken.jsonto version controlThe
.gitignorefile excludes these by defaultOAuth tokens are stored locally and refresh automatically
Use "Desktop app" OAuth type for maximum security
License
MIT
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…
Your mailboxes in ChatGPT and Claude: Gmail, iCloud, Fastmail, any IMAP. Passwords stay yours.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables reading, sending, searching, and managing Gmail through Claude using the official Google Gmail API.3MIT
- 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
- FlicenseAqualityCmaintenanceEnables Claude to read, search, send, and manage Gmail messages and threads through natural language.13-
- AlicenseNot gradedqualityDmaintenanceEnables Gmail integration with Claude Code for reading, sending, searching emails, and managing labels through natural language.ISC