Skip to main content
Glama
0x8687

Meme MCP Server

by 0x8687

search-emails

Find specific emails in Gmail by using search queries like 'from:example@gmail.com', 'subject:meeting', or 'is:unread' to locate messages based on sender, subject, or status.

Instructions

Search emails using Gmail search syntax

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesGmail search query (e.g., 'from:example@gmail.com', 'subject:meeting', 'is:unread')
maxResultsNoMaximum number of results to return

Implementation Reference

  • The async handler function that implements the core logic of the 'search-emails' tool. It uses the Composio VercelAIToolSet to execute the 'GMAIL_SEARCH_EMAILS' action, processes the response to format a list of matching emails with snippets and IDs, and returns a structured text response or error message.
    }, async (args, extra) => {
        try {
            const userAddress = "default-user";
            
            const result = await toolset.executeAction({
                action: "GMAIL_SEARCH_EMAILS",
                entityId: userAddress,
                params: args
            });
            
            if (result.successful) {
                const emails = result.data?.response_data as any;
                const emailList = emails.messages?.map((email: any) => 
                    `• ${email.snippet} (${email.id})`
                ).join('\n') || 'No emails found matching your search';
                
                return {
                    content: [{ 
                        type: "text", 
                        text: `🔍 Search results for "${args.query}":\n\n${emailList}\n\nTotal: ${emails.messages?.length || 0} emails found` 
                    }],
                };
            } else {
                return {
                    content: [{ 
                        type: "text", 
                        text: `❌ Failed to search emails: ${result.error || 'Unknown error'}` 
                    }],
                };
            }
        } catch (error) {
            console.error('Error searching emails:', error);
            return {
                content: [{ 
                    type: "text", 
                    text: `Error searching emails: ${error instanceof Error ? error.message : String(error)}` 
                }],
            };
        }
    });
  • The Zod schema defining the input parameters for the 'search-emails' tool: 'query' (required string for Gmail search syntax) and 'maxResults' (optional number). This is passed as the third argument to server.tool.
    server.tool("search-emails", "Search emails using Gmail search syntax", {
        query: z.string().describe("Gmail search query (e.g., 'from:example@gmail.com', 'subject:meeting', 'is:unread')"),
        maxResults: z.number().optional().describe("Maximum number of results to return"),
    }, async (args, extra) => {
  • src/tools.ts:489-489 (registration)
    The registration of the 'search-emails' tool using server.tool, specifying the name, description, and referencing the schema and handler.
    server.tool("search-emails", "Search emails using Gmail search syntax", {
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 offers minimal behavioral insight. It mentions 'Gmail search syntax' which hints at query capabilities, but doesn't disclose whether this is read-only, what permissions are needed, how results are returned (e.g., pagination, format), rate limits, or error conditions. For a search tool with zero annotation coverage, this is inadequate.

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 ('Search emails') and adds just enough context ('using Gmail search syntax'). Every word earns its place, making it easy for an agent to parse quickly.

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 tool's moderate complexity (search with parameters), lack of annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns (e.g., list of emails, metadata), how to handle results, or any behavioral traits like authentication needs. For a search tool in a Gmail context with many siblings, more completeness is needed.

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 fully documents both parameters (query and maxResults). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain query syntax beyond mentioning 'Gmail search syntax' (which the schema already covers with examples), nor does it clarify maxResults defaults or constraints. Baseline 3 is appropriate when schema does all the work.

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 ('search') and resource ('emails'), and specifies the search method ('using Gmail search syntax'). It distinguishes from siblings like 'get-emails' by emphasizing search functionality rather than retrieval. However, it doesn't explicitly differentiate from all potential search-related siblings.

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 like 'get-emails' or 'search' functions in other tools. It doesn't mention prerequisites (e.g., needing authentication via connect-gmail) or exclusions. The agent must infer usage from the name and context alone.

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/0x8687/mcp-gmail-v1'

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