Skip to main content
Glama

search_emails

Find specific emails in Gmail using advanced search queries. Filter messages by sender, recipient, subject, attachments, date, or read status to locate relevant correspondence quickly.

Instructions

    Search for emails using Gmail's search syntax.
    
    This tool searches for emails matching the specified query using
    Gmail's powerful search syntax.
    
    Prerequisites:
    - The user must be authenticated. Check auth://status resource first.
    - If not authenticated, guide the user through the authentication process.
    
    Args:
        query (str): The search query using Gmail's search syntax.
            Examples:
            - "from:example@gmail.com" - Emails from a specific sender
            - "to:example@gmail.com" - Emails to a specific recipient
            - "subject:meeting" - Emails with "meeting" in the subject
            - "has:attachment" - Emails with attachments
            - "is:unread" - Unread emails
            - "after:2023/01/01" - Emails after January 1, 2023
        max_results (int, optional): Maximum number of emails to return. Defaults to 10.
        
    Returns:
        Dict[str, Any]: The search results including:
            - query: The search query used
            - emails: List of email objects matching the query with links
            - next_page_token: Token for pagination (if applicable)
            
    Example usage:
    1. First check authentication: access auth://status resource
    2. If authenticated, search for emails: search_emails(query="from:example@gmail.com")
    3. If not authenticated, guide user to authenticate first
    4. Always include the email_link when discussing specific emails with the user
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key traits: authentication requirements, default behavior (max_results defaults to 10), pagination support (via next_page_token), and output structure. However, it lacks details on rate limits, error handling, or specific permissions needed, leaving some gaps in behavioral context.

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

Conciseness4/5

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

The description is well-structured with sections for prerequisites, arguments, returns, and example usage, making it easy to scan. However, it includes some redundancy (e.g., repeating the tool's purpose) and could be more front-loaded; the core functionality is clear, but minor trimming could improve efficiency without losing value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (search functionality with authentication needs), no annotations, and no output schema, the description is highly complete. It covers purpose, usage, parameters, return values, and authentication workflow, providing all necessary context for an AI agent to invoke the tool correctly and handle edge cases like authentication states.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% coverage. It explains both parameters in detail: 'query' with examples of Gmail syntax and 'max_results' with its default value and optional nature. This compensates fully for the schema's lack of descriptions, providing clear semantics and usage examples.

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

Purpose5/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: 'Search for emails using Gmail's search syntax.' It specifies the verb ('search'), resource ('emails'), and method ('Gmail's search syntax'), distinguishing it from siblings like 'list_emails' or 'get_email' by emphasizing search functionality rather than listing or retrieving specific emails.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidelines, including prerequisites (authentication via 'auth://status'), when to use (after authentication), and alternatives (e.g., guiding users to authenticate first). It also references sibling tools like 'authenticate' and 'check_auth_status' in the context of authentication steps, offering clear guidance on tool selection.

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/bastienchabal/gmail-mcp'

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