Skip to main content
Glama

get_email

Retrieve detailed email information including headers, attachments, and body content from your mailbox using message ID or UID.

Instructions

Get detailed email information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoFolder containing the email (default: INBOX)INBOX
message_idNoMessage ID (sequence number)
uidNoUnique ID of the message
include_bodyNoInclude email body (default: true)

Implementation Reference

  • The core handler logic that fetches email data from an IMAP server.
    def get_email(
        self, folder: str, uid: int, headers_only: bool = False, decode_bodies: bool = True
    ) -> dict[str, Any]:
        """
        Fetch a single email.
    
        Args:
            folder: Folder containing the email
            uid: Email sequence number or UID
            headers_only: If True, fetch only headers (default: False)
            decode_bodies: If True, decode quoted-printable/base64 (default: True)
    
        Returns:
            Dictionary containing:
            - uid: Email UID
            - sequence_number: Sequence number
            - headers: Email headers as dict
            - subject: Subject line
            - from: From address
            - to: To addresses
            - date: Date header
            - message_id: Message-ID
            - body: Body text (if not headers_only)
            - html: HTML body (if available)
            - attachments: List of attachments (if any)
    
        Raises:
            EmailFetchError: If fetch fails
    
        Example:
  • Tool definition and schema for the 'get_email' tool, used by the MCP server to expose the functionality.
    Tool(
        name="get_email",
        description="Get detailed email information",
        inputSchema={
            "type": "object",
            "properties": {
                "folder": {
                    "type": "string",
                    "description": "Folder containing the email (default: INBOX)",
                    "default": "INBOX",
                },
                "message_id": {
                    "type": "string",
                    "description": "Message ID (sequence number)",
                },
                "uid": {
                    "type": "string",
                    "description": "Unique ID of the message",
                },
                "include_body": {
                    "type": "boolean",
                    "description": "Include email body (default: true)",
                    "default": True,
                },
            },
            "anyOf": [
                {"required": ["message_id"]},
                {"required": ["uid"]},
            ],

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/AdJIa/mail-mcp-server'

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