Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

get_email_body

Retrieve email body content from IMAP mailboxes in text or HTML format using email UID to access message content for reading or processing.

Instructions

Get email body content

Input Schema

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

Implementation Reference

  • The core logic for fetching and extracting the email body from an IMAP server.
    def get_email_body(
        self, uid: int, mailbox: Optional[str] = None, format: str = "text"
    ) -> str:
        """Get email body content."""
        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)
        body = self._extract_body(msg)
    
        if format == "html" and body.html:
            return body.html
        return body.text or ""
  • The MCP tool registration handler that calls the IMAP client's get_email_body method.
    elif name == "get_email_body":
        return imap_client.get_email_body(
            uid=args["uid"],
            mailbox=args.get("mailbox"),
            format=args.get("format", "text"),
        )
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 action ('get') but doesn't cover critical aspects like whether this is a read-only operation, authentication requirements, rate limits, error handling, or what happens if the UID doesn't exist. For a tool with no annotation coverage, this leaves significant gaps in understanding its behavior.

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 extremely concise at just three words ('Get email body content'), with zero wasted language. It's front-loaded and gets straight to the point, making it easy for an agent to parse quickly.

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 of email retrieval (with multiple sibling tools), no annotations, and no output schema, the description is insufficient. It doesn't explain what 'body content' entails (e.g., plain text vs. HTML, attachments), how it relates to other email tools, or what the return value looks like. The agent would need to guess or rely heavily on the schema alone.

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 input schema has 100% description coverage, with clear documentation for all three parameters (uid, mailbox, format). The description adds no additional parameter semantics beyond what's in the schema, such as explaining the relationship between parameters or usage examples. This meets the baseline for high schema coverage.

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 'Get email body content' clearly states the verb (get) and resource (email body content), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'get_email' or 'get_email_headers', which likely retrieve different parts of an email, so it falls short of a perfect score.

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 such as 'get_email' (which might return full email data) or 'get_email_headers'. There's no mention of prerequisites, context, or exclusions, leaving the agent to infer usage from the tool name alone.

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