Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

search_unread

Retrieve unread emails from an IMAP account to manage inbox priorities and track pending messages. Specify mailbox and limit parameters to filter results.

Instructions

Get all unread emails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
mailboxNoMailbox name (default: current)
limitNoMax results (default: 50)

Implementation Reference

  • The `search_unread` method in the `IMAPClient` class implements the logic to search for unread emails by selecting the mailbox and searching for the 'UNSEEN' flag.
    def search_unread(
        self, mailbox: Optional[str] = None, limit: int = 50
    ) -> list[EmailHeader]:
        """Get all unread emails."""
        self._ensure_connected()
        if mailbox:
            self.select_mailbox(mailbox)
        elif not self.current_mailbox:
            self.select_mailbox("INBOX")
    
        uids = self.client.search(["UNSEEN"])
        uids = sorted(uids, reverse=True)[:limit]
        if not uids:
            return []
    
        messages = self.client.fetch(uids, ["ENVELOPE", "FLAGS", "RFC822.SIZE"])
        return [self._parse_email_header(uid, data) for uid, data in messages.items()]
  • The `search_unread` tool is registered and called in `src/imap_mcp/server.py` within the tool handler dispatch logic.
    elif name == "search_unread":
        return imap_client.search_unread(
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. It states it 'gets' emails (implying a read operation) but doesn't cover critical aspects like whether this is a safe operation, if it requires authentication, what the return format is (e.g., list of email objects), or if it has side effects like marking emails as read. For a tool with no annotations, this leaves significant gaps.

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 with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a simple retrieval tool.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what 'gets' entails (e.g., returns email metadata, bodies, or just IDs), how results are ordered, or error conditions. For a search/retrieval tool in a complex email system with many siblings, more context is needed to guide effective use.

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%, with both parameters ('mailbox' and 'limit') well-documented in the schema. The description doesn't add any parameter-specific information beyond implying it retrieves emails. This meets the baseline for high schema coverage, where the schema does the heavy lifting.

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 ('all unread emails'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'search_emails' or 'get_unread_count', but the focus on 'unread' emails provides some implicit distinction.

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?

No guidance is provided about when to use this tool versus alternatives like 'search_emails' (which might support filtering by read status) or 'get_unread_count' (which returns only counts). The description doesn't mention prerequisites, exclusions, or comparative context with sibling 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