get_thread
Get all messages in a conversation thread by walking In-Reply-To and References headers. Returns messages sorted chronologically, using Message-ID to handle cross-folder replies.
Instructions
Get all messages in a conversation thread by walking In-Reply-To and References headers. Returns messages sorted chronologically (oldest first).
PREFERRED: pass messageId — Message-IDs are globally unique, so this sidesteps the UID-collision footgun and walks INBOX + Sent + All Mail by default to catch replies that span folders. A thread member that lives in a user folder (e.g. Folders/Development) and surfaces only via the All Mail virtual copy is rewritten to its real storage folder AND UID, so the returned folder/uid pair is safe to feed into a single-folder tool.
Legacy: passing uid + folder searches only within that folder. UIDs are per-folder in IMAP, so the same UID in two folders refers to different messages — use messageId when possible.
SCOPE: this walks the reply chain only. Forwards do NOT set In-Reply-To/References back to the original, so a forwarded copy starts its own conversation and will NOT appear here — get_thread is the reply chain, not every message derived from the original.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | No | RFC 5322 Message-ID of any message in the thread (e.g. <abc@example.com>). Preferred over uid+folder. | |
| uid | No | UID of a thread message (only used when messageId is omitted; folder-scoped) | |
| folder | No | Folder the UID lives in (ignored when messageId is set) | INBOX |
| folders | No | Override the default folder walk when messageId is set (default: INBOX, Sent, All Mail) | |
| limit | No | Maximum messages to return (default: 25, max: 50) |