Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

get_top_senders

Analyze email patterns by identifying the most frequent senders in your iCloud inbox using configurable sampling and result limits.

Instructions

Get the top senders by email count from a sample of the inbox

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxNoMailbox to analyze (default INBOX)
sampleSizeNoNumber of emails to sample (default 500)
maxResultsNoMax number of senders/domains to return (default 20)

Implementation Reference

  • The implementation of the get_top_senders tool, which fetches recent emails from a mailbox, aggregates senders and domains by frequency, and returns the top results.
    export async function getTopSenders(mailbox = 'INBOX', sampleSize = 500, maxResults = 20, creds = null) {
      const client = createRateLimitedClient(creds);
      await client.connect();
      const mb = await client.mailboxOpen(mailbox);
      const total = mb.exists;
      const senderCounts = {};
      const senderDomains = {};
    
      const end = total;
      const start = Math.max(1, total - sampleSize + 1);
      const range = `${start}:${end}`;
      let count = 0;
    
      for await (const msg of client.fetch(range, { envelope: true })) {
        const address = msg.envelope.from?.[0]?.address;
        if (address) {
          senderCounts[address] = (senderCounts[address] || 0) + 1;
          const domain = address.split('@')[1];
          if (domain) senderDomains[domain] = (senderDomains[domain] || 0) + 1;
        }
        count++;
      }
    
      await client.logout();
      const topAddresses = Object.entries(senderCounts).sort((a, b) => b[1] - a[1]).slice(0, maxResults).map(([address, count]) => ({ address, count }));
      const topDomains = Object.entries(senderDomains).sort((a, b) => b[1] - a[1]).slice(0, maxResults).map(([domain, count]) => ({ domain, count }));
      return { sampledEmails: count, topAddresses, topDomains };
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the sampling behavior (non-exhaustive analysis), but omits safety characteristics (read-only status), performance implications of large sample sizes, or return value structure.

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?

Single sentence that is front-loaded with the action ('Get the top senders') and efficiently qualifies it with the metric ('by email count') and scope ('from a sample'). No redundant words or wasted space.

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 3-parameter analytical tool with simple types and no output schema, the description adequately covers the core functionality and key limitation (sampling). It appropriately relies on the schema for parameter details, though explicit read-only assurance would improve completeness given the lack of annotations.

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

Parameters3/5

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

Schema description coverage is 100%, establishing a baseline of 3. The description provides context that 'sampleSize' relates to inbox sampling, but does not add syntax details, valid ranges, or semantic relationships beyond what the schema property descriptions already provide.

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

Purpose4/5

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

The description clearly states the tool retrieves sender frequency data ('top senders by email count') and specifies the methodology ('from a sample'). However, it does not explicitly distinguish from sibling tool 'get_unread_senders', which likely performs similar ranking but only on unread messages.

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?

The mention of 'sample' implicitly signals this is for approximate/quick analysis rather than exhaustive reporting, which helps usage context. However, there is no explicit guidance on when to choose this over 'get_emails_by_sender' or 'search_emails' for sender analysis.

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