Guidelines for using the Gmail MCP server with Claude.
19 operations available for comprehensive Gmail management.
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
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
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
- 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
- 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"
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
- 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)
- 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
- Use
modify_emailto add/remove labels - Common labels:
INBOX,UNREAD,IMPORTANT,STARRED,TRASH - Use
batch_modify_emailsfor bulk operations (up to 50 per batch)
- Use descriptive names:
Work - Urgentnotlabel1 - Set visibility options:
messageListVisibility:showorhidelabelListVisibility:labelShow,labelShowIfUnread, orlabelHide
- Use
get_or_create_labelto avoid duplicates
- List all labels first to see existing structure
- Create labels before applying them to emails
- System labels cannot be deleted or modified
- 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
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
- 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.)
- First read email to get attachment IDs
- Use
download_attachmentwith message ID and attachment ID - Optionally specify
savePathandfilename - Original filename used if not specified
- 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
- 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
- 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
- Search for emails with attachments:
has:attachment - Read email to see attachment details
- Download important attachments
- Create filter to label emails with attachments
- 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
- 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
- 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