download_attachment
Download an email attachment by specifying its part number. Retrieve the content as base64 or write it to a file for offline access.
Instructions
Download an email attachment by part number. Use read_message or list_attachments first to see available attachments and their part numbers. By default returns base64-encoded content inline (read-only). When saveTo is provided AND the ALLOW_FILE_DOWNLOAD_DIR env var is set, this tool WRITES the decoded bytes to that path inside the allowlist root and returns the file path + size instead of base64 (avoids blowing the token budget on large attachments) — that write is the only side effect, and it is why this tool is not marked read-only. Inline (no saveTo) calls do not touch the filesystem. Re-running with the same arguments is idempotent (overwrites the same file with identical bytes).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"uid": "<uid>",
"partNumber": "<partNumber>"
},
"name": "download_attachment"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Message UID | |
| folder | No | Folder containing the message (default: INBOX) | INBOX |
| partNumber | Yes | MIME part number of the attachment (from read_message output) | |
| saveTo | No | Optional relative path inside ALLOW_FILE_DOWNLOAD_DIR to write the decoded attachment to. Rejects absolute paths, `..` traversal, and symlink escapes. Requires ALLOW_FILE_DOWNLOAD_DIR to be set in the environment. |