get-message-rfc822
Retrieve a message's exact RFC 822 bytes as stored on IMAP, with UID, flags, size, and SHA-256 for archival or forensic evidence. Read-only, no decoding or changes to the email.
Instructions
Use when: you need a message's complete original RFC 822 bytes exactly as the IMAP server stores them — for archival, forensic review, evidence preservation, or a verifiable .eml — together with the IMAP identity that links back to the source (uid, uidValidity, internalDate, flags, RFC822.SIZE) and a SHA-256 of the acquired bytes. IMAP-only: needs an imap: id from list-messages/search-messages on an IMAP-configured account. Returns: the acquisition record (account, mailbox, uid, uidValidity, internalDate, flags, size, bytes, sha256, messageId, readMethod, backend, warnings) plus either contentBase64 — the bytes, base64-encoded, carried in structuredContent only — or savedPath when savePath was given. No decoding, charset conversion, line-ending change or MIME re-serialization is applied. Do not use when: you want readable content (use get-message), only the headers (use get-message-headers), or one attachment (use fetch-attachment / save-attachment); or when the id is numeric — Mail.app's AppleScript bridge exposes its own rendering, not the stored bytes, so there is no AppleScript path. Safety: strictly read-only against the mailbox — EXAMINE + BODY.PEEK[], so \Seen is not set and no STORE/COPY/MOVE/APPEND/EXPUNGE is issued; no Mail.app, AppleScript or osascript involved. Inline results are capped at 6 MiB of raw bytes (maxBytes) to stay under the MCP stdio 10 MB message limit; larger messages need savePath, which creates exactly one new file (never overwrites, mode 0600) inside the configured allowed roots, up to 25 MiB.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | An imap: message id (numeric Mail.app ids are refused) | |
| fileName | No | File name to use with savePath (no path separators or '..'). Default: <account>-<mailbox>-uidv<uidValidity>-uid<uid>.eml | |
| maxBytes | No | Refuse (never truncate) a message larger than this many raw bytes. Default and inline maximum 6291456 (6 MiB); with savePath up to 26214400 (25 MiB) | |
| savePath | No | Directory inside the allowed roots to write the .eml into instead of returning base64; raises the ceiling to 25 MiB |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| uid | No | ||
| size | No | RFC822.SIZE as reported by the server | |
| bytes | No | Number of bytes acquired (and hashed) | |
| flags | No | ||
| sha256 | No | Hex SHA-256 over exactly the acquired bytes | |
| account | No | ||
| backend | No | ||
| mailbox | No | ||
| warnings | No | ||
| messageId | No | Bare RFC 5322 Message-ID from ENVELOPE, for convenience; the authoritative copy is in the bytes | |
| savedPath | No | ||
| readMethod | No | The IMAP commands used | |
| uidValidity | No | Mailbox UIDVALIDITY as a decimal string; with uid, the durable identity of the source message | |
| internalDate | No | ISO 8601 IMAP INTERNALDATE (arrival), not the Date: header | |
| contentBase64 | No | The acquired bytes, base64-encoded (absent when savePath was used) |