Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

get_emails_by_sender

Retrieve emails from a specific sender in your iCloud Mail account. Filter messages by sender address or domain, specify mailbox, and set result limits.

Instructions

Get all emails from a specific sender

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
senderYesSender email address or domain
mailboxNoMailbox to search (default INBOX)
limitNoMax results to show (default 10)

Implementation Reference

  • Implementation of get_emails_by_sender tool, which connects to IMAP, searches for emails from a sender, fetches details for recent ones, and returns them.
    export async function getEmailsBySender(sender, mailbox = 'INBOX', limit = 10, creds = null) {
      const client = createRateLimitedClient(creds);
      await client.connect();
      await client.mailboxOpen(mailbox);
      const uids = (await client.search({ from: sender }, { uid: true })) ?? [];
      const total = uids.length;
      const recentUids = uids.slice(-limit).reverse();
      const emails = [];
      for (const uid of recentUids) {
        const msg = await client.fetchOne(uid, { envelope: true, flags: true }, { uid: true });
        if (msg) {
          emails.push({
            uid,
            subject: msg.envelope.subject,
            from: msg.envelope.from?.[0]?.address,
            date: msg.envelope.date,
            flagged: msg.flags.has('\\Flagged'),
            seen: msg.flags.has('\\Seen')
          });
        }
      }
      await client.logout();
      return { total, showing: emails.length, emails };
    }

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