Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

delete_older_than

Remove emails older than a specified number of days from iCloud Mail to manage storage and organize your inbox by automatically clearing outdated messages.

Instructions

Delete all emails older than a certain number of days

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysYesDelete emails older than this many days
mailboxNoMailbox (default INBOX)

Implementation Reference

  • Handler function for deleting emails older than a specified number of days in a given mailbox.
    export async function deleteOlderThan(days, mailbox = 'INBOX', creds = null) {
      const client = createRateLimitedClient(creds);
      await client.connect();
      await client.mailboxOpen(mailbox);
      const date = new Date();
      date.setDate(date.getDate() - days);
      const uids = (await client.search({ before: date }, { uid: true })) ?? [];
      if (uids.length === 0) { await client.logout(); return { deleted: 0 }; }
      let deleted = 0;
      for (let i = 0; i < uids.length; i += CHUNK_SIZE) {
        const chunk = uids.slice(i, i + CHUNK_SIZE);
        await client.messageDelete(chunk, { uid: true });
        deleted += chunk.length;
      }
      await client.logout();
      return { deleted, olderThan: date.toISOString() };
    }

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