read_emails
Read/list recent emails from Gmail with optional filters.Parameters
Gmail search query. Supports Gmail search operators:
from:[email protected]- Filter by senderis:unread- Only unread emailssubject:meeting- Filter by subjecthas:attachment- Emails with attachmentslabel:inbox- Filter by label
Maximum number of emails to return (1-50)
Returns
Whether the operation succeeded
Summary message
List of email messages with:
id(string): Message IDsubject(string): Email subjectfrom(string): Sender email addressto(string): Recipient email addressdate(string): Date sentsnippet(string): Preview of email content
Example
get_email_details
Get full details of a specific email including body content.Parameters
The unique ID of the email message
Returns
Whether the operation succeeded
Status message
Message ID
Email subject
Sender email address
Recipient email address
Date sent
Email preview
Full email body content (plain text preferred, falls back to HTML)
Example
summarize_weekly_emails
Get a summary of emails from the past week (or specified days). Shows top senders and sample subjects.Parameters
Number of days to look back (1-30)
Maximum number of emails to include in summary (1-100)
Returns
Whether the operation succeeded
Summary description
Summary data containing:
period(string): Date range coveredmessage_count(int): Total number of messagestop_senders(list): Top 5 senders with message countssample_subjects(list): Up to 10 sample email subjectsmessages(list): Full message list
Example
search_emails
Search emails using Gmail search syntax.Parameters
Gmail search query. Examples:
"subject:project"- Subject contains “project”"has:attachment"- Has attachments"from:[email protected]"- From specific sender"after:2026/01/01"- After specific date"is:starred"- Starred emails
Maximum number of emails to return (1-50)
Returns
Whether the operation succeeded
Summary message
List of matching email messages
Example
list_unread_emails
List unread emails from inbox.Parameters
Maximum number of unread emails to return (1-50)
Returns
Whether the operation succeeded
Summary message
List of unread email messages
Example
Implementation Details
All Gmail tools interact with the Gmail API through theGmailService class located in services/gmail.py:13-337. The service:
- Provides read-only access to Gmail (no send/delete/modify)
- Handles MIME message parsing for plain text and HTML emails
- Supports full Gmail search syntax
- Decodes base64-encoded email bodies
- Returns structured responses with consistent error handling
Message Body Parsing
The service includes intelligent body extraction (services/gmail.py:37-75):
- Prioritizes plain text over HTML
- Handles multipart MIME messages
- Automatically decodes base64 content
- Falls back gracefully if parsing fails
Common Response Pattern
All Gmail tools return a dictionary with:Gmail Search Operators
Common Gmail search operators supported:| Operator | Description | Example |
|---|---|---|
from: | Sender email | from:[email protected] |
to: | Recipient email | to:[email protected] |
subject: | Subject contains | subject:meeting |
has:attachment | Has attachments | has:attachment |
is:unread | Unread status | is:unread |
is:starred | Starred status | is:starred |
is:important | Important label | is:important |
label: | Has specific label | label:work |
after: | After date | after:2026/01/01 |
before: | Before date | before:2026/12/31 |
older_than: | Age | older_than:7d |
newer_than: | Age | newer_than:2d |
Best Practices
- Use search queries: Leverage Gmail’s powerful search syntax to filter results
- Limit results: Keep
max_resultsreasonable to avoid overwhelming the user - Get details separately: Use
list_emailsfirst, thenget_email_detailsonly for specific emails - Weekly summaries: Use
summarize_weekly_emailsfor high-level overviews instead of listing all emails