Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

search_by_subject

Find emails by subject text to locate specific messages in your IMAP mailbox. Specify subject, mailbox, and result limit for targeted email searches.

Instructions

Search emails by subject

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
subjectYesSubject text to search
mailboxNoMailbox name (default: current)
limitNoMax results (default: 50)

Implementation Reference

  • Implementation of the `search_by_subject` tool which connects to IMAP, selects the mailbox, performs a search by subject, and returns a list of EmailHeader objects.
    def search_by_subject(
        self, subject: str, mailbox: Optional[str] = None, limit: int = 50
    ) -> list[EmailHeader]:
        """Search emails by subject."""
        self._ensure_connected()
        if mailbox:
            self.select_mailbox(mailbox)
        elif not self.current_mailbox:
            self.select_mailbox("INBOX")
    
        uids = self.client.search(["SUBJECT", subject])
        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()]
  • Registration and invocation logic for `search_by_subject` in the MCP server handler.
    elif name == "search_by_subject":
        return imap_client.search_by_subject(
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does (search emails by subject) without revealing any behavioral traits like whether this is a read-only operation, what permissions are required, how results are returned, whether there are rate limits, or what happens when no matches are found.

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, front-loading the essential information with zero wasted words. Every word earns its place by specifying the action (search), target (emails), and criteria (by subject).

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 search tool with no annotations and no output schema, the description is inadequate. It doesn't explain what the tool returns (email objects, IDs, summaries), how results are structured, whether there's pagination, or any error conditions. The description provides only the most basic functional statement without the context needed for effective tool selection and invocation.

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 all three parameters (subject, mailbox, limit) with their types and descriptions. The description adds no additional parameter information beyond what's in the schema, maintaining the baseline score of 3 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 clearly states the tool's purpose as searching emails by subject, which is a specific verb+resource combination. However, it doesn't distinguish this tool from sibling search tools like search_by_date, search_by_sender, search_emails, or search_unread, which all search emails but with different criteria.

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 multiple sibling search tools available (search_by_date, search_by_sender, search_emails, search_unread, search_flagged), there's no indication of when subject-based searching is appropriate versus other search criteria or general email searching.

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