mail.get_attachment
Download the contents of an email attachment as base64
Scope: mail:read
Download an email attachment as base64-encoded data so the agent can immediately process it (parse a PDF, OCR an image, etc.) without a separate HTTP fetch.
Use mail.get_message or mail.get_thread first to discover the attachmentId and metadata.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
messageId | string | Yes | The messageId that owns the attachment |
attachmentId | string | Yes | The attachmentId from a previous get_message call |
Example
Agent: "What's in the attachment on that report email?"
→ mail.get_message({ messageId: "<abc@mailgent.dev>" })
→ returns message including attachments[0].attachmentId
→ mail.get_attachment({
messageId: "<abc@mailgent.dev>",
attachmentId: "cm9k2x4f80001abc"
})Returns
{
"attachmentId": "cm9k2x4f80001abc",
"messageId": "<abc@mailgent.dev>",
"filename": "Q1-report.pdf",
"contentType": "application/pdf",
"size": 2148532,
"data": "JVBERi0xLjQKJeLjz9MK..."
}The data field is the base64-encoded file content. Decode it to get the original bytes.
Sending attachments
To send an attachment with mail.send or mail.reply, include an attachments array on the call:
{
"to": ["user@example.com"],
"subject": "Quarterly report",
"text": "See attached.",
"attachments": [
{
"filename": "Q1-report.pdf",
"contentType": "application/pdf",
"data": "JVBERi0xLjQKJeLjz9MK..."
}
]
}| Limit | Value |
|---|---|
| Per attachment | 10 MB |
| Per email (total) | 25 MB |
| Per email (count) | 10 |
REST equivalent
GET /v0/messages/:messageId/attachments/:attachmentIdThe REST endpoint streams the raw bytes (no base64 wrapper). For agents the MCP tool is more convenient because the response is JSON-RPC and the data is already in-memory.