feat: add email management tools (mark read, move, search, list mailboxes)#116
Open
rhubain wants to merge 6 commits intoai-zerolab:mainfrom
Open
feat: add email management tools (mark read, move, search, list mailboxes)#116rhubain wants to merge 6 commits intoai-zerolab:mainfrom
rhubain wants to merge 6 commits intoai-zerolab:mainfrom
Conversation
Add two new MCP tools for email management: - mark_emails_as_read: Mark emails as read/unread using IMAP \Seen flag - move_emails: Move emails between mailboxes using MOVE (RFC 6851) with fallback to COPY+DELETE for older servers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix bug where status messages like "SEARCH completed (took 5 ms)" were incorrectly parsed as email UIDs. The number in the timing info (e.g., "5") was being treated as a valid UID. Add _parse_search_response() method that: - Detects status messages by checking for keywords - Returns empty list for status-only responses - Only returns actual numeric UIDs from valid responses Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add new MCP tool to list all mailboxes (folders) in an email account. Returns mailbox name, flags, and hierarchy delimiter. Useful for discovering folder names like Archive, Sent, Trash which may vary across email providers (e.g., iCloud uses different names). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Performance optimization: - Don't fetch INTERNALDATE for all emails when paginating - Use UID ordering directly (UIDs are ascending by add date) - Only fetch headers for the requested page New search_emails tool: - Server-side IMAP SEARCH (fast even with thousands of emails) - Search in: all (TEXT), subject, body, or from - Paginated results Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use ternary operator in _parse_search_response (SIM108) - Replace raise Exception with logging + failed_ids (TRY301) - Add tests for list_mailboxes, search_emails, mark_emails_as_read, move_emails - Update test_get_emails_stream to match optimized pagination behavior Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Acid-Override
pushed a commit
to Acid-Override/mcp-email-server
that referenced
this pull request
Feb 18, 2026
… (search optimization + filter validation) Combined optimizations: - PR ai-zerolab#116: Add list_mailboxes, move_emails, mark_emails_as_read, search_emails tools - PR ai-zerolab#116: UID-based pagination optimization (60s+ → <5s on large mailboxes) - PR ai-zerolab#117: Filter validation (prevents accidental expensive searches) - PR ai-zerolab#117: Search result caching (_last_search_total) Conflict resolution: Merged parse_search_response logic with caching to avoid duplicate searches. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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 several new MCP tools for comprehensive email management:
list_mailboxes- Discover available folders (Archive, Sent, Trash, etc.)search_emails- Server-side text search using IMAP SEARCH (fast even with thousands of emails)mark_emails_as_read- Mark emails as read/unreadmove_emails- Move emails between folders (uses IMAP MOVE with COPY+DELETE fallback)Also includes:
New Tools
list_mailboxessearch_emailsmark_emails_as_readmove_emailsTest plan
list_mailboxesreturns correct folder listlist_emails_metadatawith large mailbox completes in <5s (was 60s+)search_emailsfinds emails by keywordmove_emailssuccessfully moves between foldersmake checkpasses (linting + formatting)Technical notes
🤖 Generated with Claude Code