Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

archive_older_than

Move emails older than a specified number of days from a source mailbox to an archive folder using a safe copy-verify-delete process. Preview changes with dry run mode.

Instructions

Safely move emails older than N days from a source mailbox to an archive folder. Uses the same safe copy-verify-delete pipeline as bulk_move. Use dryRun: true to preview.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysYesArchive emails older than this many days
targetMailboxYesDestination archive folder (e.g. Archive)
sourceMailboxNoSource mailbox (default INBOX)
dryRunNoIf true, preview what would be moved without moving

Implementation Reference

  • The handler function that implements the "archive_older_than" tool. It searches for emails older than a given number of days and moves them to a target mailbox.
    export async function archiveOlderThan(days, targetMailbox, sourceMailbox = 'INBOX', dryRun = false, creds = null) {
      const client = createRateLimitedClient(creds);
      await client.connect();
      await client.mailboxOpen(sourceMailbox);
      const date = new Date();
      date.setDate(date.getDate() - days);
      const raw = await client.search({ before: date }, { uid: true });
      const uids = Array.isArray(raw) ? raw : [];
      await client.logout();
      if (dryRun) return { dryRun: true, wouldMove: uids.length, olderThan: date.toISOString(), sourceMailbox, targetMailbox };
      if (uids.length === 0) return { moved: 0, olderThan: date.toISOString(), sourceMailbox, targetMailbox };
      await ensureMailbox(targetMailbox, creds);
      const result = await safeMoveEmails(uids, sourceMailbox, targetMailbox, creds);
      return { ...result, olderThan: date.toISOString(), sourceMailbox, targetMailbox };
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/adamzaidi/icloud-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server