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", {

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