Skip to content

feat(email): batch_move_messages MCP tool#167

Merged
claude-puntlabs merged 3 commits intomainfrom
feat/batch-move
Apr 18, 2026
Merged

feat(email): batch_move_messages MCP tool#167
claude-puntlabs merged 3 commits intomainfrom
feat/batch-move

Conversation

@claude-puntlabs
Copy link
Copy Markdown
Contributor

@claude-puntlabs claude-puntlabs commented Apr 18, 2026

Summary

  • New batch_move_messages MCP tool: accepts array of message IDs, moves all to destination folder in one IMAP round-trip
  • MoveMessages method on email.Client: single SELECT + UID set MOVE (not N individual calls)
  • nil message_ids validation, invalid UIDs rejected before connecting
  • 3 tests: batch move, invalid UID, missing param

Test plan

  • go vet ./... clean
  • go test -race passes for internal/mcp/ and internal/email/
  • Code review: 3 findings found and fixed (SELECT per iteration, connection state, nil validation)

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 N move_message calls), returning a single summary string.

Implements email.Client.MoveMessages to perform one SELECT + one MOVE over 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.

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)
Copilot AI review requested due to automatic review settings April 18, 2026 19:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_messages MCP tool and implement handler logic to parse/validate UID inputs and call the email client.
  • Add (*email.Client).MoveMessages to move a UID set after a single folder SELECT.
  • 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.

Comment thread CHANGELOG.md Outdated
Comment thread internal/mcp/tools.go
Comment thread internal/mcp/tools.go
Comment thread internal/email/imap.go Outdated
Comment thread internal/email/imap.go
Comment thread README.md Outdated
- 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"
@claude-puntlabs claude-puntlabs merged commit 02d5645 into main Apr 18, 2026
6 checks passed
@claude-puntlabs claude-puntlabs deleted the feat/batch-move branch April 18, 2026 20:07
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.

2 participants