Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

get_thread

Retrieve complete email conversations by providing a single message UID. This tool fetches all related messages in a thread from IMAP mailboxes for comprehensive email review.

Instructions

Get email thread/conversation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uidYesEmail UID (any email in thread)
mailboxNoMailbox name (default: current)

Implementation Reference

  • The actual implementation of the get_thread tool logic in the IMAP client.
    def get_thread(self, uid: int, mailbox: Optional[str] = None) -> list[EmailHeader]:
        """Get email thread/conversation."""
        self._ensure_connected()
        if mailbox:
            self.select_mailbox(mailbox)
    
        # Get the email to find its references
        email_data = self.get_email(uid, mailbox)
        message_id = email_data.header.message_id
        subject = email_data.header.subject
    
        # Search for related emails by subject (simplified thread detection)
        if subject:
            # Remove Re: Fwd: etc. prefixes
            clean_subject = subject
            for prefix in ["Re:", "RE:", "Fwd:", "FWD:", "Fw:", "AW:", "Aw:"]:
                clean_subject = clean_subject.replace(prefix, "").strip()
    
            uids = self.client.search(["SUBJECT", clean_subject])
            if uids:
  • Registration of the get_thread tool in the server configuration.
    make_tool(
        "get_thread",
        "Get email thread/conversation",
        {
            "uid": {"type": "number", "description": "Email UID (any email in thread)"},
            "mailbox": {"type": "string", "description": "Mailbox name (default: current)"},
        },
        ["uid"],
    ),
  • Handling the get_thread tool call by routing it to the imap_client.
    elif name == "get_thread":
        return imap_client.get_thread(
            uid=args["uid"],
            mailbox=args.get("mailbox"),
        )
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. 'Get' implies a read operation, but the description doesn't specify whether this requires authentication, what format the thread data returns in, whether it includes attachments, or if there are rate limits. This leaves significant behavioral questions unanswered.

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, with zero wasted language. It's front-loaded with the core purpose and uses minimal syntax. Every word earns its place by communicating essential information about the tool's function.

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?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what constitutes a 'thread/conversation', what data is returned, how the tool behaves with invalid UIDs, or how it relates to similar email retrieval tools in the sibling set. The agent would have significant gaps in understanding how to properly use this tool.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain what 'uid' represents in context of threads, how mailbox selection affects results, or provide examples of valid values.

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 verb ('Get') and resource ('email thread/conversation'), making the purpose immediately understandable. However, it doesn't differentiate this tool from sibling tools like 'get_email' or 'get_email_body', which also retrieve email-related data but target different resources.

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. With siblings like 'get_email', 'get_email_body', and 'get_email_headers' that retrieve specific email components, there's no indication whether this tool retrieves the full conversation thread or how it differs from those other retrieval tools.

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