gmail-mcp
CLAUDE.md4 starsChanged 12 months agoMITView on GitHub
Guidelines for using the Gmail MCP server with Claude. 19 operations available for comprehensive Gmail management.
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
37 rules. About 0 are common, 17 are distinctive, and 20 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
20
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 38
Verify authentication status - if authentication fails, guide user to run npm run auth
- Very specific: line 46
Use send_email for immediate sending
- Very specific: line 47
Use draft_email to create drafts for review
- Very specific: line 60
Use Gmail search syntax: from:example@gmail.com, subject:meeting, has:attachment, etc.
- Very specific: line 65
Use count_emails to get exact counts from label metadata (no pagination needed)
- Very specific: line 67
Use labelId or labelName parameter (e.g., "INBOX", "UNREAD", "STARRED", "SENT", or user label names)
- Very specific: line 69
Use list_email_labels first to see all available labels and their IDs
- Very specific: line 72
Use modify_email to add/remove labels
- Very specific: line 74
Use batch_modify_emails for bulk operations (up to 50 per batch)
- Very specific: line 79
Use descriptive names: Work - Urgent not label1
- Very specific: line 83
Use get_or_create_label to avoid duplicates
- Distinctive: line 87
Create labels before applying them to emails
- Distinctive: line 95
Use templates for common scenarios:
- Distinctive: line 117
All common file types supported (PDF, DOCX, images, etc.)
- Very specific: line 121
Use download_attachment with message ID and attachment ID
- Distinctive: line 129
Create new labels as needed
- Distinctive: line 130
Search for emails to organize
- Very specific: line 131
Use batch_modify_emails to apply labels in bulk
- Distinctive: line 132
Create filters to auto-organize future emails
- Very specific: line 135
Search for emails to delete (e.g., from:newsletter@company.com older_than:1y)
- Very specific: line 136
Use batch_delete_emails for bulk deletion
- Distinctive: line 137
Create filters to auto-archive or delete similar emails
- Distinctive: line 143
Test filter with existing emails
- Distinctive: line 144
Create filter to automate future emails
- Very specific: line 147
Search for emails with attachments: has:attachment
- Distinctive: line 148
Read email to see attachment details
- Distinctive: line 150
Create filter to label emails with attachments
- Very specific: line 155
Invalid message ID: Use search_emails to find correct message IDs
- Very specific: line 156
Label not found: Use list_email_labels to find correct label IDs
- Distinctive: line 157
File not found: Verify attachment file paths are correct and accessible
- Distinctive: line 158
API errors: Check Gmail API quotas and rate limits
- Very specific: line 159
Permission errors: Verify OAuth scopes include gmail.modify and gmail.settings.basic
- Distinctive: line 168
Thread IDs: Use thread IDs to maintain conversation context
- Distinctive: line 169
Search syntax: Use Gmail's powerful search operators for precise filtering
- Very specific: line 173
Always verify before deleting: Use read_email to confirm before delete_email
- Distinctive: line 176
Organize with labels: Create a label hierarchy for better organization
- Distinctive: line 177
Test filters: Create filters and test with existing emails before relying on them
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Gmail MCP Guidelines for Claude
Guidelines for using the Gmail MCP server with Claude.
Available Operations
19 operations available for comprehensive Gmail management.
Email Operations (10)
send_email- Send emails with optional attachments (plain text, HTML, or multipart)draft_email- Create email drafts with attachments supportread_email- Read email content with full MIME parsing and attachment informationsearch_emails- Search emails using Gmail query syntaxcount_emails- Get exact email count for a label using Gmail API label metadata (provides total and unread counts)modify_email- Modify email labels (add/remove labels)delete_email- Permanently delete emailsdownload_attachment- Download email attachments to local filesystembatch_modify_emails- Modify labels for multiple emails in batchesbatch_delete_emails- Delete multiple emails in batches
Label Management (5)
list_email_labels- List all Gmail labels (system and user)create_label- Create a new Gmail label with visibility settingsupdate_label- Update label properties (name, visibility)delete_label- Delete a user-created labelget_or_create_label- Get existing label by name or create if it doesn't exist
Filter Management (5)
create_filter- Create a custom Gmail filter with criteria and actionslist_filters- List all Gmail filtersget_filter- Get details of a specific filterdelete_filter- Delete a Gmail filtercreate_filter_from_template- Create a filter using pre-built templates
Usage Guidelines
Before Operations
- Verify authentication status - if authentication fails, guide user to run
npm run auth - For email operations, check if message IDs are valid
- For label operations, check if labels exist before creating duplicates
- For filter operations, understand the user's filtering needs
Email Operations
Sending Emails
- Use
send_emailfor immediate sending - Use
draft_emailto create drafts for review - Support attachments by providing file paths in the
attachmentsarray - Support HTML emails with
htmlBodyparameter - Support multipart emails (both plain text and HTML) with
mimeType: "multipart/alternative"
Reading Emails
read_emailreturns full email content including:- Headers (subject, from, to, date)
- Plain text and HTML content
- Attachment information (filename, type, size, download ID)
- Thread ID for conversation context
Searching Emails
- Use Gmail search syntax:
from:example@gmail.com,subject:meeting,has:attachment, etc. - Combine operators:
from:boss@company.com after:2024/01/01 has:attachment - Limit results with
maxResultsparameter (default: 10, max: 500)
Counting Emails
- Use
count_emailsto get exact counts from label metadata (no pagination needed) - Provides both total and unread message counts
- Use
labelIdorlabelNameparameter (e.g., "INBOX", "UNREAD", "STARRED", "SENT", or user label names) - Common system labels:
INBOX,UNREAD,STARRED,SENT,DRAFT,TRASH,SPAM - Use
list_email_labelsfirst to see all available labels and their IDs
Modifying Emails
- Use
modify_emailto add/remove labels - Common labels:
INBOX,UNREAD,IMPORTANT,STARRED,TRASH - Use
batch_modify_emailsfor bulk operations (up to 50 per batch)
Label Management
Creating Labels
- Use descriptive names:
Work - Urgentnotlabel1 - Set visibility options:
messageListVisibility:showorhidelabelListVisibility:labelShow,labelShowIfUnread, orlabelHide
- Use
get_or_create_labelto avoid duplicates
Organizing with Labels
- List all labels first to see existing structure
- Create labels before applying them to emails
- System labels cannot be deleted or modified
Filter Management
Creating Filters
- Define criteria:
from,to,subject,query,hasAttachment,size, etc. - Define actions:
addLabelIds,removeLabelIds,forward - Use templates for common scenarios:
fromSender- Filter emails from specific senderwithSubject- Filter by subject textwithAttachments- Filter emails with attachmentslargeEmails- Filter emails larger than specified sizecontainingText- Filter emails containing specific textmailingList- Filter mailing list emails
Filter Templates
fromSender: Archive emails from specific senderwithSubject: Mark emails with specific subject as readwithAttachments: Label all emails with attachmentslargeEmails: Label large emails for reviewcontainingText: Mark important emails containing specific keywordsmailingList: Archive mailing list emails
Attachment Handling
Sending Attachments
- Provide file paths in
attachmentsarray - Files are automatically detected and attached
- Gmail has 25MB limit per email
- All common file types supported (PDF, DOCX, images, etc.)
Downloading Attachments
- First read email to get attachment IDs
- Use
download_attachmentwith message ID and attachment ID - Optionally specify
savePathandfilename - Original filename used if not specified
Common Workflows
Organizing Inbox
- List all labels to see current structure
- Create new labels as needed
- Search for emails to organize
- Use
batch_modify_emailsto apply labels in bulk - Create filters to auto-organize future emails
Email Cleanup
- Search for emails to delete (e.g.,
from:newsletter@company.com older_than:1y) - Use
batch_delete_emailsfor bulk deletion - Create filters to auto-archive or delete similar emails
Setting Up Filters
- Identify email patterns (sender, subject, content)
- Choose appropriate template or create custom filter
- Define labels to apply
- Test filter with existing emails
- Create filter to automate future emails
Managing Attachments
- Search for emails with attachments:
has:attachment - Read email to see attachment details
- Download important attachments
- Create filter to label emails with attachments
Error Handling
- Authentication fails: Guide user to run
npm run author placegcp-oauth.keys.jsonin correct location - Invalid message ID: Use
search_emailsto find correct message IDs - Label not found: Use
list_email_labelsto find correct label IDs - File not found: Verify attachment file paths are correct and accessible
- API errors: Check Gmail API quotas and rate limits
- Permission errors: Verify OAuth scopes include
gmail.modifyandgmail.settings.basic
Important Notes
- Message IDs: Gmail message IDs are long alphanumeric strings
- Label IDs: System labels use uppercase (e.g.,
INBOX,UNREAD), user labels useLabel_prefix - Batch operations: Process up to 50 emails per batch (configurable)
- Attachments: 25MB limit per email, files processed locally
- OAuth tokens: Auto-refresh when expired
- Thread IDs: Use thread IDs to maintain conversation context
- Search syntax: Use Gmail's powerful search operators for precise filtering
Best Practices
- Always verify before deleting: Use
read_emailto confirm beforedelete_email - Use batch operations: More efficient for multiple emails
- Create filters proactively: Set up filters to prevent inbox clutter
- Organize with labels: Create a label hierarchy for better organization
- Test filters: Create filters and test with existing emails before relying on them
- Backup important emails: Download attachments before bulk operations
- Use search effectively: Combine search operators for precise results
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

