Get Email Source
get_email_sourceRetrieve the raw RFC 822 source of one email, keeping every header, MIME part, and href that rendered message bodies drop. Use it to inspect URLs, custom headers, or attachments.
Instructions
Return the raw RFC 822 source of a single message.
The MCP's other body-extraction paths return Mail.app's rendered content (HTML collapsed to display text, hrefs dropped, embedded objects replaced with U+FFFC). This tool returns the raw source instead — all headers, all MIME parts, all hrefs intact.
Implementation note:
Wraps the source property of message defined in Mail.sdef
(the AppleScript dictionary for Mail.app). That property returns the
same RFC 822 text Mail.app writes to the on-disk .partial.emlx file,
so the consumer does not need filesystem access or knowledge of the
Mail directory layout to recover MIME parts / hrefs / custom headers.
Identifier resolution: message_id is preferred when both are provided
(exact match on the RFC 822 Message-Id header via AppleScript's
message id property — distinct from id, which is Mail.app's
internal numeric id). subject_keyword matches the first message in
mailbox whose subject contains the substring.
Output sizing: messages can be large (a plain note is ~200 KB; with
attachments far larger). max_bytes caps the returned payload and
appends a truncation marker when exceeded. headers_only=True returns
only the RFC 822 header block (everything up to and including the first
blank line) — usually sufficient for URL/header inspection and avoids
returning base64 bodies. Cap applies after the headers_only filter.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | Yes | Account name (e.g., ``"Gmail"``, ``"Work"``). | |
| mailbox | No | Mailbox name (default: ``"INBOX"``). Resolved via the shared ``build_mailbox_ref`` helper so non-English / Exchange inboxes (Posteingang, Bandeja de entrada, etc.) are found. | INBOX |
| max_bytes | No | Byte cap on the returned payload (default 256 KB). | |
| message_id | No | RFC 822 Message-Id for exact match (preferred when known). | |
| headers_only | No | When ``True``, return only the header block. | |
| subject_keyword | No | Substring to match against subject (first hit). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |