feat: add mailbox parameter to download_attachment method#90
Merged
Conversation
Previously download_attachment was hardcoded to use INBOX, while other methods (get_email_count, get_emails_metadata_stream, get_email_body_by_id, delete_emails) accept a mailbox parameter with INBOX as default. This change adds consistent mailbox parameter support to download_attachment, allowing users to download attachments from any mailbox (e.g., All Mail, Sent, [Gmail]/Sent Mail). Changes: - Add mailbox parameter to EmailClient.download_attachment() with default "INBOX" - Add mailbox parameter to ClassicEmailHandler.download_attachment() - Add mailbox parameter to abstract EmailHandler.download_attachment() - Add mailbox parameter to MCP tool download_attachment() - Add comprehensive tests for mailbox parameter functionality - Update existing test assertions for new parameter
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
rrroyal
pushed a commit
to rrroyal/mcp-email-server-auth
that referenced
this pull request
Jan 9, 2026
) Previously download_attachment was hardcoded to use INBOX, while other methods (get_email_count, get_emails_metadata_stream, get_email_body_by_id, delete_emails) accept a mailbox parameter with INBOX as default. This change adds consistent mailbox parameter support to download_attachment, allowing users to download attachments from any mailbox (e.g., All Mail, Sent, [Gmail]/Sent Mail). Changes: - Add mailbox parameter to EmailClient.download_attachment() with default "INBOX" - Add mailbox parameter to ClassicEmailHandler.download_attachment() - Add mailbox parameter to abstract EmailHandler.download_attachment() - Add mailbox parameter to MCP tool download_attachment() - Add comprehensive tests for mailbox parameter functionality - Update existing test assertions for new parameter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a
mailboxparameter to thedownload_attachmentmethod, enabling users to download attachments from any mailbox instead of being restricted to INBOX.Problem
Previously,
download_attachmentwas hardcoded to use INBOX:However, other methods in the same class accept a
mailboxparameter with INBOX as the default:get_email_count(mailbox: str = "INBOX")get_emails_metadata_stream(mailbox: str = "INBOX")get_email_body_by_id(mailbox: str = "INBOX")delete_emails(email_ids, mailbox: str = "INBOX")This inconsistency prevents users from downloading attachments from other mailboxes like "All Mail", "Sent", or "[Gmail]/Sent Mail".
Solution
Add consistent
mailboxparameter support todownload_attachmentacross all layers:EmailClient.download_attachment()- Core implementation with mailbox parameterClassicEmailHandler.download_attachment()- Handler layer with mailbox parameterEmailHandler.download_attachment()- Interface definition with mailbox parameterdownload_attachment()- Exposed to AI agents with mailbox parameterChanges
Code Changes
mcp_email_server/emails/classic.py:
mailbox: str = "INBOX"parameter toEmailClient.download_attachment()mailbox: str = "INBOX"parameter toClassicEmailHandler.download_attachment()mcp_email_server/emails/init.py:
mailbox: str = "INBOX"parameter to abstractEmailHandler.download_attachment()mcp_email_server/app.py:
mailboxparameter to MCP tooldownload_attachment()Test Changes
Testing
make checkpasses (ruff formatting, linting, dependency checks)Backward Compatibility
✅ Fully backward compatible. The new parameter has a default value of "INBOX", so existing code will continue to work unchanged.
Usage Example
Checklist
make checkpasses