Skip to main content
Glama

google_gmail_list_emails

Retrieve and filter emails from specified Gmail labels or folders using search queries and set maximum results for efficient email management on the Google MCP server.

Instructions

List emails from a specific label or folder

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
labelIdsNoLabel IDs to filter messages (e.g., 'INBOX', 'SENT')
maxResultsNoMaximum number of emails to return
queryNoSearch query to filter emails

Implementation Reference

  • The main handler function that validates the input arguments using isListEmailsArgs and invokes the GoogleGmail instance's listEmails method with labelIds, maxResults, and query parameters. It formats and returns the result as MCP content.
    export async function handleGmailListEmails( args: any, googleGmailInstance: GoogleGmail ) { if (!isListEmailsArgs(args)) { throw new Error("Invalid arguments for google_gmail_list_emails"); } const { labelIds, maxResults, query } = args; const result = await googleGmailInstance.listEmails( labelIds, maxResults, query ); return { content: [{ type: "text", text: result }], isError: false, }; }
  • Defines the Tool schema including name, description, and detailed inputSchema for parameters labelIds (array of strings), maxResults (number), and query (string).
    export const LIST_EMAILS_TOOL: Tool = { name: "google_gmail_list_emails", description: "List emails from a specific label or folder", inputSchema: { type: "object", properties: { labelIds: { type: "array", items: { type: "string" }, description: "Label IDs to filter messages (e.g., 'INBOX', 'SENT')", }, maxResults: { type: "number", description: "Maximum number of emails to return", }, query: { type: "string", description: "Search query to filter emails", }, }, }, };
  • Registers the tool handler in the MCP server's request handler switch statement, routing calls to the specific handleGmailListEmails function.
    case "google_gmail_list_emails": return await gmailHandlers.handleGmailListEmails( args, googleGmailInstance );
  • tools/index.ts:14-16 (registration)
    Includes the Gmail tools (including google_gmail_list_emails) in the main tools export array by spreading the gmailTools array.
    // Gmail tools ...gmailTools,

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/vakharwalad23/google-mcp'

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