Skip to main content
Glama

search_emails

Search emails in your mailbox using IMAP criteria like sender, subject, or status to find specific messages quickly.

Instructions

Search emails with criteria

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
folderNoFolder to search in (default: INBOX)INBOX
criteriaNoIMAP search criteria (e.g., 'ALL', 'UNSEEN', 'FROM sender@example.com', 'SUBJECT urgent')ALL
limitNoMaximum number of results (default: 10)

Implementation Reference

  • The core implementation of the search_emails logic as part of the EmailSearch class.
    def search_emails(
        self, folder: str, conditions: dict[str, Any], charset: str | None = None
    ) -> list[int]:
        """
        Search for emails matching conditions.
    
        Args:
            folder: Folder to search in
            conditions: Dictionary of search conditions
                Supported keys:
                - subject, from, to, cc, bcc, body, text: Search in fields
                - since, before, on: Date conditions (YYYY-MM-DD or date object)
                - seen/unseen, answered/unanswered, flagged/unflagged, deleted/undeleted: Flag conditions
                - uid: UID search
            charset: Character set for search (default: None/UTF-8)
    
        Returns:
            List of email sequence numbers
    
        Raises:
            EmailSearchError: If search fails
    
        Example:
  • The registration and invocation handler for the 'search_emails' tool in the MCP tools dispatcher.
    elif name == "search_emails":
        result = client.search_emails(
            folder=arguments.get("folder", "INBOX"),
            criteria=arguments.get("criteria", "ALL"),
            limit=arguments.get("limit", 10),
        )
        return [TextContent(type="text", text=str(result))]
Behavior2/5

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

With no annotations provided, the description carries full burden but discloses no behavioral traits. It does not confirm the read-only nature of the operation, explain result pagination, describe return format, or note performance characteristics of IMAP searches.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

While brief, the description is under-specified rather than efficiently concise. The single sentence fails to earn its place due to extreme vagueness, leaving critical gaps for a tool with 3 parameters and no output schema.

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?

Inadequate for the complexity level. With no output schema and no annotations, the description should explain what the tool returns (message IDs? full content? metadata?) and how it fits into the email workflow, but it provides none of this context.

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%, establishing a baseline of 3. The description mentions 'criteria' which aligns with the parameter name, but adds no semantic detail beyond what the schema already provides (IMAP syntax, examples, defaults).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Search emails with criteria' essentially restates the tool name with minimal elaboration. It fails to distinguish this tool from siblings like 'get_email' or clarify the scope of the search operation.

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 provided on when to use this tool versus alternatives (e.g., 'get_email' for specific retrieval), nor any prerequisites or exclusions mentioned.

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/AdJIa/mail-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server