Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

get_email

Retrieve complete email messages by UID from IMAP mailboxes for reading and processing email content.

Instructions

Get complete email by UID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesEmail UID
mailboxNoMailbox name (default: current)

Implementation Reference

  • Implementation of `get_email` in `ImapClientWrapper`, which fetches complete email data (headers, body, attachments) by UID.
    def get_email(self, uid: int, mailbox: Optional[str] = None) -> Email:
        """Get complete email by UID."""
        self._ensure_connected()
        if mailbox:
            self.select_mailbox(mailbox)
    
        data = self.client.fetch([uid], ["ENVELOPE", "FLAGS", "RFC822.SIZE", "BODY[]"])
        if uid not in data:
            raise ValueError(f"Email with UID {uid} not found")
    
        msg_data = data[uid]
        header = self._parse_email_header(uid, msg_data)
    
        # Parse body
        raw_body = msg_data.get(b"BODY[]", b"")
        msg = email.message_from_bytes(raw_body)
        body = self._extract_body(msg)
        attachments = self._extract_attachment_info(msg)
    
        return Email(header=header, body=body, attachments=attachments)
  • Tool registration for `get_email` in `src/imap_mcp/server.py`.
    make_tool(
        "get_email",
        "Get complete email by UID",
        {
            "uid": {"type": "number", "description": "Email UID"},
            "mailbox": {"type": "string", "description": "Mailbox name (default: current)"},
        },
        ["uid"],
    ),
  • Tool handler for `get_email` in `src/imap_mcp/server.py` that routes to `imap_client.get_email`.
    elif name == "get_email":
        return imap_client.get_email(
            uid=args["uid"],
            mailbox=args.get("mailbox"),
        )
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves a 'complete email', implying a read-only operation, but doesn't cover critical aspects like authentication requirements, error handling (e.g., invalid UID), rate limits, or what 'complete' entails (e.g., includes attachments, headers, body). For a tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Get complete email by UID') with zero wasted words. It's appropriately sized for a straightforward retrieval tool, making it easy for an agent to parse quickly without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (a read operation with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'complete email' returns (e.g., format, fields), error conditions, or dependencies like authentication. For a tool in this context, more detail is needed to guide the agent effectively, especially without structured support from annotations or output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with both parameters ('uid' and 'mailbox') well-documented in the schema itself. The description adds no additional parameter semantics beyond implying the 'uid' is used to identify the email. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract from the schema's clarity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Get complete email') and target resource ('by UID'), making the purpose immediately understandable. It distinguishes itself from siblings like 'get_email_body' or 'get_email_headers' by specifying 'complete email'. However, it doesn't explicitly contrast with 'fetch_emails' (which likely retrieves multiple emails) or 'get_thread' (which might retrieve conversation threads), leaving some sibling differentiation incomplete.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing authentication or connection), compare it to similar tools like 'fetch_emails' for bulk retrieval or 'get_email_body' for partial content, or specify use cases (e.g., for detailed viewing vs. overview). This leaves the agent with minimal context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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