Skip to main content
Glama
adamzaidi

icloud-mcp

by adamzaidi

get_email_raw

Retrieve raw email data in RFC 2822 format with full headers and MIME body as base64-encoded content for debugging or export purposes.

Instructions

Get the raw RFC 2822 source of an email (full headers + MIME body) as base64-encoded data. Useful for debugging or export. Capped at 1 MB.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesEmail UID
mailboxNoMailbox name (default INBOX)

Implementation Reference

  • Implementation of get_email_raw tool, which fetches the raw source of an email given its UID.
    export async function getEmailRaw(uid, mailbox = 'INBOX', creds = null) {
      const MAX_RAW_BYTES = 1 * 1024 * 1024; // 1 MB cap
      const client = createRateLimitedClient(creds);
      await client.connect();
      await client.mailboxOpen(mailbox);
      const msg = await client.fetchOne(uid, { source: true }, { uid: true });
      await client.logout();
      if (!msg || !msg.source) throw new Error(`Email UID ${uid} not found`);
      const source = msg.source;
      const truncated = source.length > MAX_RAW_BYTES;
      const slice = truncated ? source.slice(0, MAX_RAW_BYTES) : source;
      return {
        uid,
        size: source.length,
        truncated,
        data: slice.toString('base64'),
        dataEncoding: 'base64'
      };
    }

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