Skip to main content
Glama
Soundhannes

IMAP MCP Server

by Soundhannes

search_by_sender

Find emails from specific senders in your IMAP account. Specify sender address, mailbox, and result limit to locate relevant messages quickly.

Instructions

Search emails by sender address

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
senderYesSender email address or name
mailboxNoMailbox name (default: current)
limitNoMax results (default: 50)

Implementation Reference

  • The actual implementation of the tool logic that interacts with the IMAP client.
    def search_by_sender(
        self, sender: str, mailbox: Optional[str] = None, limit: int = 50
    ) -> list[EmailHeader]:
        """Search emails by sender address."""
        self._ensure_connected()
        if mailbox:
            self.select_mailbox(mailbox)
        elif not self.current_mailbox:
            self.select_mailbox("INBOX")
    
        uids = self.client.search(["FROM", sender])
        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 MCP tool registration and schema definition for search_by_sender.
    make_tool(
        "search_by_sender",
        "Search emails by sender address",
        {
            "sender": {"type": "string", "description": "Sender email address or name"},
            "mailbox": {"type": "string", "description": "Mailbox name (default: current)"},
            "limit": {"type": "number", "description": "Max results (default: 50)"},
        },
        ["sender"],
    ),
  • The MCP tool handler in server.py that routes the tool call to the client implementation.
    elif name == "search_by_sender":
        return imap_client.search_by_sender(
            sender=args["sender"],
            mailbox=args.get("mailbox"),
            limit=args.get("limit", 50),
        )
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. While 'Search' implies a read-only operation, the description doesn't address important behavioral aspects like whether this is a real-time search or cached search, what permissions are required, whether it searches across all mailboxes or just the specified one, what the return format looks like, or any rate limits. The description only states what the tool does, not how it behaves.

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 perfectly concise at just 5 words: 'Search emails by sender address'. Every word earns its place - it specifies the action (search), the resource (emails), and the filtering criteria (by sender address). There's zero waste or redundancy.

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 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns (email objects, IDs, summaries?), whether results are paginated, how the search is performed (full-text, exact match, substring?), or any error conditions. The description only states the basic purpose without providing the context needed for 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%, so the schema already documents all three parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema - it doesn't explain how the sender parameter handles partial matches, case sensitivity, or what happens with ambiguous names. With complete schema coverage, the baseline score of 3 is appropriate.

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 'Search emails by sender address', which is a specific verb+resource combination. It distinguishes itself from generic search tools like 'search_emails' by focusing specifically on sender-based filtering, though it doesn't explicitly differentiate from 'search_by_date' or 'search_by_subject' which are similar specialized search tools.

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. There are multiple search-related sibling tools (search_by_date, search_by_subject, search_emails, search_flagged, search_unread), but the description doesn't indicate when sender-based searching is preferred over other search methods or when to use the more generic 'search_emails' tool instead.

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