Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

empty_trash

Permanently delete all emails in the trash folder. Use dryRun to preview deletions first.

Instructions

Permanently delete all emails in the trash (Deleted Messages or Trash folder). Use dryRun: true to preview first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dryRunNoIf true, preview how many emails would be deleted without deleting

Implementation Reference

  • The `emptyTrash` function searches common trash folders (e.g., "Deleted Messages", "Trash") and deletes all emails found within them. It supports a `dryRun` mode for testing.
    export async function emptyTrash(dryRun = false, creds = null) {
      const t0 = Date.now();
      // iCloud uses 'Deleted Messages'; Gmail uses '[Gmail]/Trash'; standard IMAP uses 'Trash'
      const trashFolders = ['Deleted Messages', '[Gmail]/Trash', 'Trash'];
      const client = createRateLimitedClient(creds);
      await client.connect();
    
      let mailbox = null;
      for (const folder of trashFolders) {
        try {
          await client.mailboxOpen(folder);
          mailbox = folder;
          break;
        } catch (err) {
          if (!err.message.includes('Mailbox does not exist') && !err.message.includes('NONEXISTENT') && !err.message.includes('does not exist')) {
            await safeClose(client);
            throw err;
          }
        }
      }
    
      if (!mailbox) {
        await safeClose(client);
        throw new Error('No trash folder found — tried: ' + trashFolders.join(', '));
      }
    
      const raw = await client.search({ all: true }, { uid: true });
      const uids = Array.isArray(raw) ? raw : [];
    
      if (dryRun) {
        await safeClose(client);
        return { dryRun: true, wouldDelete: uids.length, mailbox };
      }
    
      if (uids.length === 0) {
        await safeClose(client);
        return { deleted: 0, mailbox, timeTaken: ((Date.now() - t0) / 1000).toFixed(1) + 's' };
      }
    
      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 safeClose(client);
      return { deleted, mailbox, timeTaken: ((Date.now() - t0) / 1000).toFixed(1) + 's' };
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full disclosure burden. Successfully communicates destructive nature ('Permanently delete') and safety mechanism (dryRun preview). Missing return value description and rate limit details, but 'permanently' adequately warns of irreversibility.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, zero waste. Front-loaded with critical behavioral info ('Permanently delete') immediately signaling danger, followed by safety instruction. Perfect density for the tool complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter tool with 100% schema coverage and no output schema, the description is complete. Covers scope (trash folder), destructive nature, and safety mechanism. No significant gaps given the tool's simplicity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% coverage (baseline 3). Description adds value beyond schema by prescribing usage semantics ('preview first') rather than just defining the boolean, helping the agent understand WHEN to set dryRun=true.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear specific verb ('Permanently delete') + resource ('emails in the trash') + scope ('all'). Clarifies folder name variations ('Deleted Messages or Trash folder') to distinguish from other mailboxes, effectively differentiating from sibling deletion tools like bulk_delete or delete_email.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Provides explicit safety guidance ('Use dryRun: true to preview first') which establishes a recommended workflow before destructive execution. Lacks explicit comparison to siblings (e.g., when to use this vs bulk_delete), but the trash-specific scope makes usage context largely self-evident.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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