get_attachments
Retrieve and list file attachments from a specific email in an IMAP mailbox using its unique identifier.
Instructions
List attachments of an email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Email UID | |
| mailbox | No | Mailbox name (default: current) |
Implementation Reference
- src/imap_mcp/imap_client.py:415-427 (handler)The implementation of the get_attachments tool in the ImapClientWrapper class.
def get_attachments(self, uid: int, mailbox: Optional[str] = None) -> list[Attachment]: """List attachments of an email.""" self._ensure_connected() if mailbox: self.select_mailbox(mailbox) data = self.client.fetch([uid], ["BODY[]"]) if uid not in data: raise ValueError(f"Email with UID {uid} not found") raw_body = data[uid].get(b"BODY[]", b"") msg = email.message_from_bytes(raw_body) return self._extract_attachment_info(msg)