Skip to main content
Glama
0x8687

Meme MCP Server

by 0x8687

search-emails

Search and retrieve emails by applying Gmail search syntax queries, such as 'from:', 'subject:', or 'is:unread', and specify the maximum number of results to return.

Instructions

Search emails using Gmail search syntax

Input Schema

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

Implementation Reference

  • The handler function for the 'search-emails' tool. It executes a Gmail search using toolset.executeAction('GMAIL_SEARCH_EMAILS'), processes the response to format email snippets and IDs, handles errors, and returns structured content.
    }, 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)}` }], }; } });
  • Input schema using Zod for validating the 'query' parameter (required string) and optional 'maxResults' (number).
    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"),
  • src/tools.ts:489-489 (registration)
    Registration of the 'search-emails' tool on the MCP server, specifying name, description, input schema, and handler function.
    server.tool("search-emails", "Search emails using Gmail search syntax", {

Other Tools

Related 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