Skip to content

[FEAT/Batch] Add batch email operations with filter support and batch_archive#61

Merged
elydelva merged 7 commits into
mainfrom
feat/batch-operations
Mar 28, 2026
Merged

[FEAT/Batch] Add batch email operations with filter support and batch_archive#61
elydelva merged 7 commits into
mainfrom
feat/batch-operations

Conversation

@elydelva

Copy link
Copy Markdown
Owner

Summary

Implements ADR-016: adds MCP tools for batch email operations (delete, move, mark, archive) capable of processing up to 500 emails in a single call, with optional server-side filter resolution via IMAP SEARCH.

Closes #60

Related ADR

ADR-016

Notable changes

  • Single IMAP round-trip per batch: handlers now pass a UID sequence set string (e.g. "1,2,3") to messageMove/messageDelete/messageFlagsAdd instead of N sequential calls — significant latency reduction for large batches.
  • Filter-based resolution: callers can pass a filter object (from, subject, before, after, read) instead of explicit UIDs; the server resolves matching UIDs via IMAP SEARCH before executing the operation.
  • batch_archive: new tool that auto-detects the Archive folder via \Archive special-use flag (with fallback to name patterns) then moves in one command.
  • 500-uid hard limit: enforced at handler level with a clear error message; protects against accidental large-scale destructive operations.

Checklist

  • Tests pass (162/162)
  • Type check passes
  • Lint passes
  • ADR frontmatter updated (pr, pr_url, status)
  • docs/adr/README.md status column updated

Review notes

  • IMAP batch commands are not atomic on all servers (RFC 3501 does not guarantee partial rollback). A failure on a batch command will fail the entire operation — no partial success tracking.
  • batch_archive throws if no Archive folder is detected; callers should use list_folders first if unsure.

elydelva and others added 5 commits March 28, 2026 02:01
- searchByFilter: resolve UIDs via IMAP SEARCH from a structured filter
  (from, subject, before, after, read)
- batchMoveEmails / batchDeleteEmails / batchMarkEmails: single IMAP
  command per operation using UID sequence sets instead of N round-trips
- findArchiveFolder: detect Archive mailbox via \Archive special-use flag
  then fallback to common name patterns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Batch handlers (batch_move, batch_delete, batch_mark) now accept either
  explicit `uids` or a structured `filter` resolved via IMAP SEARCH
- 500-uid hard limit per call; exceeding it throws with a clear message
- New batch_archive handler: auto-detects Archive folder via findArchiveFolder,
  then moves matching emails in a single IMAP command
- Update mock pool to handle UID set strings for batch assertions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add batch_archive tool (auto-detects Archive folder)
- Update batch_move, batch_delete, batch_mark schemas: uids is now optional
  and accepts an optional filter object (from, subject, before, after, read)
- Max 500 UIDs enforced at handler level; MCP schema stays open for filter path

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- batchMove/Delete/Mark: test filter-based uid resolution via IMAP SEARCH
- batch uid limit: verify 501 throws, 500 is accepted
- missing input: verify error when neither uids nor filter provided
- batchArchive: archive via explicit uids, via filter, and no-archive-folder error
- Update mock pool to expose archiveFolder option and handle list() for
  findArchiveFolder detection

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a0374bc-95e8-4661-ac80-febcad5fea8f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/batch-operations

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@elydelva
elydelva marked this pull request as ready for review March 28, 2026 01:08
list all available mcp tools grouped by category: account management,
reading & searching, sending, single-email actions, and batch actions.
add batch_archive and filter examples to the batch section.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@elydelva
elydelva merged commit c656cac into main Mar 28, 2026
7 checks passed
@elydelva
elydelva deleted the feat/batch-operations branch March 28, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADR-016 — MCP Tools: Batch Email Operations

1 participant