Feature Request: Add Attachment Support to gmail.createDraft Tool
Summary
Extend the gmail.createDraft tool to support attaching local files. This enables users to create drafts with one or more attachments by providing absolute file paths.
Motivation
The current gmail.createDraft implementation only allows setting the recipient, subject, and body (text/HTML). In many workflows, users need to send files (reports, images, logs) along with their emails. Adding attachment support makes the tool much more versatile and aligns it with the capabilities of the Gmail API.
Proposed Changes
- Tool Schema Update: Add an
attachments array parameter to the gmail.createDraft tool. Each attachment object should include:
filePath (required): Absolute path to the local file.
filename (optional): Display name for the attachment.
mimeType (optional): MIME type of the file.
- MIME Handling: Enhance
MimeHelper to construct multipart/mixed messages when attachments are present. Ensure In-Reply-To and References headers are preserved for threaded drafts.
- File Operations: Implement file reading and automatic MIME type inference based on file extensions in
GmailService.
- Validation: Ensure absolute paths are used and handle file-not-found errors gracefully.
Benefits
- Enables automated email workflows that involve file sharing.
- Provides a seamless way to reply to threads with attachments.
- Improves parity with the full Gmail web/mobile experience.
Implementation Status
A draft implementation is available in PR #354, including comprehensive tests for:
- Basic attachment creation.
- Multiple attachments.
- MIME type inference.
- Threading support with attachments.
- Error handling for missing or relative paths.
Feature Request: Add Attachment Support to
gmail.createDraftToolSummary
Extend the
gmail.createDrafttool to support attaching local files. This enables users to create drafts with one or more attachments by providing absolute file paths.Motivation
The current
gmail.createDraftimplementation only allows setting the recipient, subject, and body (text/HTML). In many workflows, users need to send files (reports, images, logs) along with their emails. Adding attachment support makes the tool much more versatile and aligns it with the capabilities of the Gmail API.Proposed Changes
attachmentsarray parameter to thegmail.createDrafttool. Each attachment object should include:filePath(required): Absolute path to the local file.filename(optional): Display name for the attachment.mimeType(optional): MIME type of the file.MimeHelperto constructmultipart/mixedmessages when attachments are present. EnsureIn-Reply-ToandReferencesheaders are preserved for threaded drafts.GmailService.Benefits
Implementation Status
A draft implementation is available in PR #354, including comprehensive tests for: