feat(email): batch_move_messages MCP tool#167
Merged
claude-puntlabs merged 3 commits intomainfrom Apr 18, 2026
Merged
Conversation
Accepts an array of message IDs and moves all to a destination folder in one call. Returns "moved N of M messages to Archive" with per-ID error lines for partial failures. 3 tests: batch move, partial failure, empty array. beadle-iue
Addresses 3 review findings: - MoveMessages method on email.Client: SELECT once, MOVE with full UID set in one IMAP round-trip (was SELECT per message) - nil message_ids returns error instead of misleading success - Invalid UIDs rejected before connecting (no partial IMAP state)
There was a problem hiding this comment.
Pull request overview
Adds a new MCP tool to move multiple IMAP messages in a single operation, backed by a new email.Client batch move method to avoid per-message IMAP commands.
Changes:
- Register new
batch_move_messagesMCP tool and implement handler logic to parse/validate UID inputs and call the email client. - Add
(*email.Client).MoveMessagesto move a UID set after a single folderSELECT. - Update docs and tests to include the new tool (smoke test registration + handler tests).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/mcp/tools.go | Registers batch_move_messages, defines tool schema, and implements the handler that validates IDs and calls MoveMessages. |
| internal/mcp/smoke_test.go | Extends tool registration smoke test to expect batch_move_messages. |
| internal/mcp/handler_test.go | Adds tests for batch move success, invalid UID, empty list, and missing param. |
| internal/mcp/format.go | Adds a formatter for the batch move summary string. |
| internal/email/imap.go | Introduces MoveMessages to MOVE a UID set after one SELECT. |
| README.md | Updates tool count and adds batch_move_messages to the MCP tools table. |
| CHANGELOG.md | Adds an “Unreleased” entry for the new tool. |
| .ethos/missions.jsonl | Records mission metadata for the work. |
| .beads/issues.jsonl | Tracks the related issue/task entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Doc alignment: CHANGELOG, tool description, README match actual aggregate behavior (not per-message errors) - UID 0 rejected as invalid before IMAP connection - MoveMessages guards against empty uids slice - Doc comment: "single SELECT + single MOVE" not "one round-trip"
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
batch_move_messagesMCP tool: accepts array of message IDs, moves all to destination folder in one IMAP round-tripMoveMessagesmethod on email.Client: single SELECT + UID set MOVE (not N individual calls)Test plan
go vet ./...cleango test -racepasses forinternal/mcp/andinternal/email/Bead: beadle-iue
Note
Low Risk
Low risk: adds a new bulk-move tool that reuses existing IMAP move behavior and is covered by new handler/smoke tests; main impact is moving more messages per call if misused.
Overview
Adds a new MCP tool,
batch_move_messages, to move an array of message UIDs to a destination folder in one call (instead of Nmove_messagecalls), returning a single summary string.Implements
email.Client.MoveMessagesto perform oneSELECT+ oneMOVEover a UID set, and updates MCP formatting, tool registration, smoke coverage, and handler tests (including empty input, missing param, and invalid UID validation). Docs are updated to reflect the additional tool and changelog entry.Reviewed by Cursor Bugbot for commit 65921dd. Bugbot is set up for automated code reviews on this repo. Configure here.