-
Notifications
You must be signed in to change notification settings - Fork 0
feat(gmail): add attachment support #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add comprehensive attachment handling to Gmail daemon:
New methods:
- gmail.read: Read full email with body (text/HTML) and attachment info
- gmail.download_attachment: Download attachment by ID (save to file or base64)
Enhanced gmail.send:
- Support for cc and bcc recipients
- Attachments via file path: {"path": "~/file.pdf"}
- Attachments via base64 data: {"filename": "data.txt", "data": "..."}
Implementation:
- Recursive MIME part parsing for multipart messages
- Proper handling of nested attachments
- Base64 encoding/decoding for attachment data
- File type detection via mimetypes
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds comprehensive attachment support to the Gmail service, including new methods for reading full email bodies and downloading attachments, plus enhanced sending capabilities with cc/bcc support.
Changes:
- Added
gmail.readmethod to retrieve full email content with body (text/HTML) and attachment metadata - Added
gmail.download_attachmentmethod for downloading email attachments by ID - Enhanced
gmail.sendto support attachments (via file path or base64) and cc/bcc recipients
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/main.rs | Updated architecture documentation and method list; switched from subprocess-based CLI to PyO3 warm connection module |
| module/gmail.py | New Python module implementing Gmail API operations with attachment support including read, send with attachments, and download_attachment methods |
| manifest.json | Updated method names to use fully qualified names (gmail.inbox, gmail.unread, etc.) |
Comments suppressed due to low confidence (1)
manifest.json:81
- The manifest.json is missing entries for the new methods 'gmail.read' and 'gmail.download_attachment'. These methods are implemented in the Python module and documented in the code comments but not registered in the manifest, which could cause discrepancies in API documentation and tooling.
],
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
module/gmail.py
Outdated
| from google.oauth2.credentials import Credentials | ||
| from google_auth_oauthlib.flow import InstalledAppFlow | ||
| from googleapiclient.discovery import build | ||
| from googleapiclient.errors import HttpError |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HttpError import is unused in this module. Consider removing it or adding error handling that uses it for better error messages.
| from googleapiclient.errors import HttpError |
module/gmail.py
Outdated
| import base64 | ||
| from email.mime.text import MIMEText | ||
| from email.mime.multipart import MIMEMultipart | ||
| from email.mime.base import MIMEBase | ||
| from email import encoders | ||
| import mimetypes |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Email and MIME-related imports should be moved to the top of the file with other imports, following Python best practices. Importing within functions can cause slight performance overhead on repeated calls.
module/gmail.py
Outdated
| if not message_id: | ||
| raise ValueError("message_id parameter is required") | ||
|
|
||
| import base64 |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base64 import should be moved to the top of the file with other imports. It's already imported at the module level (if moved from _cmd_send), and importing within functions goes against Python conventions.
module/gmail.py
Outdated
| if not attachment_id: | ||
| raise ValueError("attachment_id parameter is required") | ||
|
|
||
| import base64 |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The base64 import should be moved to the top of the file with other imports rather than importing within the function.
manifest.json
Outdated
| { | ||
| "name": "send", | ||
| "name": "gmail.send", | ||
| "description": "Send an email", |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description for gmail.send in manifest.json should be updated to reflect the new attachment support capabilities. It currently says 'Send an email' but should mention 'Send an email with optional attachments' to match the Python module description.
| "description": "Send an email", | |
| "description": "Send an email with optional attachments", |
module/gmail.py
Outdated
|
|
||
| import pickle | ||
| from pathlib import Path | ||
| from typing import Dict, Any, List, Optional |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import of 'Optional' is not used.
| from typing import Dict, Any, List, Optional | |
| from typing import Dict, Any, List |
- Move imports to top of file (base64, email.mime.*, mimetypes) - Remove unused imports (HttpError, Optional) - Update gmail.send description in manifest.json - Add gmail.read and gmail.download_attachment to manifest.json Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add examples/basic_operations.py with common Gmail operations - Add troubleshooting section to README - Add CI workflow Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
gmail.readmethod to read full email with body (text/HTML) and attachment infogmail.download_attachmentmethod to download attachments by IDgmail.sendto support attachments via file path or base64 datagmail.sendNew Methods
gmail.readgmail.download_attachmentEnhanced
gmail.sendNow supports:
ccandbccparametersattachmentsarray with two formats:{"path": "~/file.pdf"}- Load from filesystem{"filename": "data.txt", "data": "base64..."}- Inline dataExample Usage
Test plan
gmail.readwith email containing attachmentsgmail.download_attachmentwith save_pathgmail.download_attachmentwithout save_path (base64 return)gmail.sendwith file path attachmentgmail.sendwith base64 attachmentgmail.sendwith cc/bcc🤖 Generated with Claude Code