Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

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
NameRequiredDescriptionDefault
uidYesEmail UID
mailboxNoMailbox name (default: current)

Implementation Reference

  • 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)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Soundhannes/IMAP-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server