Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

get_storage_report

Analyze iCloud Mail storage usage by categorizing emails into size groups and identifying top senders contributing to storage consumption.

Instructions

Estimate storage usage by size bucket and identify top senders by email size. Uses SEARCH LARGER queries for bucketing and samples large emails for sender analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxNoMailbox to analyze (default INBOX)
sampleSizeNoMax number of large emails to sample for sender analysis (default 100)

Implementation Reference

  • Implementation of the get_storage_report tool logic.
    export async function getStorageReport(mailbox = 'INBOX', sampleSize = 100, creds = null) {
      const client = createRateLimitedClient(creds);
      await client.connect();
      await client.mailboxOpen(mailbox);
    
      // Count emails by size bucket using 4x SEARCH LARGER
      const thresholds = [10 * 1024, 100 * 1024, 1024 * 1024, 10 * 1024 * 1024];
      const counts = [];
      for (const thresh of thresholds) {
        const r = await client.search({ larger: thresh }, { uid: true }).catch(() => []);
        counts.push(Array.isArray(r) ? r.length : 0);
      }
    
      const buckets = [
        { range: '10KB–100KB', count: counts[0] - counts[1] },
        { range: '100KB–1MB', count: counts[1] - counts[2] },
        { range: '1MB–10MB', count: counts[2] - counts[3] },
        { range: '10MB+', count: counts[3] }
      ];
    
      // Sample top senders among large emails (> 100 KB)
      const largeRaw = await client.search({ larger: 100 * 1024 }, { uid: true }).catch(() => []);
      const largeUids = Array.isArray(largeRaw) ? largeRaw : [];
      const sampleUids = largeUids.slice(-sampleSize);
    
      const senderSizes = {};
      if (sampleUids.length > 0) {
        for await (const msg of client.fetch(sampleUids, { envelope: true, bodyStructure: true }, { uid: true })) {
          const address = msg.envelope?.from?.[0]?.address;
          if (address && msg.bodyStructure) {
            senderSizes[address] = (senderSizes[address] || 0) + estimateEmailSize(msg.bodyStructure);
          }
        }
      }
    
      await client.logout();
    
      const topSendersBySize = Object.entries(senderSizes)
        .sort((a, b) => b[1] - a[1])
        .slice(0, 10)
        .map(([address, estimateBytes]) => ({ address, estimateKB: Math.round(estimateBytes / 1024) }));
    
      const midpoints = [50, 512, 5120, 15360]; // rough KB midpoint for each bucket
      const estimatedTotalKB = buckets.reduce((sum, b, i) => sum + b.count * midpoints[i], 0);
    
      return {
        mailbox,
        buckets,
        estimatedTotalKB,
        topSendersBySize,
        ...(sampleUids.length < largeUids.length && {
          note: `Sender analysis sampled ${sampleUids.length} of ${largeUids.length} large emails (>100 KB)`
        })
      };
    }
Behavior4/5

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

With no annotations provided, description carries the full burden and successfully discloses implementation methodology: it uses 'SEARCH LARGER queries' for bucketing and performs 'sampling' (not exhaustive analysis). Does not mention performance costs or read-only nature, though implied by 'Estimate' and 'get' prefix.

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 with zero waste. First sentence front-loads the value proposition (what it does), second sentence explains methodology (how it works). Every word earns its place.

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

Completeness4/5

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

For a 2-parameter analysis tool with no output schema, the description adequately explains what the report contains (size buckets, top senders by size). Could be improved by noting that results are estimates/samples, but sufficient for tool selection.

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 coverage is 100%, establishing baseline 3. Description adds value by connecting sampleSize to 'sender analysis' and implying mailbox scopes the storage analysis, providing functional context beyond the schema's mechanical descriptions.

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?

Description clearly states specific actions: 'Estimate storage usage by size bucket' and 'identify top senders by email size.' Effectively distinguishes from sibling get_top_senders by specifying size-based analysis rather than frequency-based analysis.

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

Usage Guidelines3/5

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

Provides implicit context that this is for storage analysis, but lacks explicit when-to-use guidance versus alternatives like get_mailbox_summary or search_emails. Does not specify prerequisites or when to prefer this over get_top_senders.

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