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,
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions listing emails but doesn't specify whether this is a read-only operation, how results are ordered, if pagination is supported, or what happens with large result sets. For a list operation with zero annotation coverage, this leaves significant behavioral gaps.

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, focused sentence that states exactly what the tool does without any unnecessary words. It's perfectly front-loaded and wastes no space, making it highly efficient for an AI agent to parse.

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?

For a list operation with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the output looks like (email objects, metadata only), how results are structured, or any behavioral constraints. The description should provide more context about the operation's scope and results.

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 already documents all three parameters thoroughly. The description mentions 'label or folder' which aligns with the 'labelIds' parameter but doesn't add meaningful semantic context beyond what's in the schema. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 action ('List emails') and specifies the scope ('from a specific label or folder'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'google_gmail_get_email' or 'google_gmail_get_email_by_index', which retrieve individual emails rather than lists.

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 'google_gmail_get_email' for single emails or 'google_gmail_list_labels' for listing labels. It mentions filtering by label/folder but doesn't clarify if this is the primary method for listing emails or if there are other approaches.

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

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

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