Skip to main content
Glama

google_gmail_list_labels

Retrieve all available Gmail labels using this integration tool, designed to streamline access and organization within Google MCP server workflows.

Instructions

List all available Gmail labels

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that validates the input arguments using isListLabelsArgs and calls googleGmailInstance.listLabels() to retrieve and format Gmail labels for the tool response.
    export async function handleGmailListLabels(
      args: any,
      googleGmailInstance: GoogleGmail
    ) {
      if (!isListLabelsArgs(args)) {
        throw new Error("Invalid arguments for google_gmail_list_labels");
      }
      const labels = await googleGmailInstance.listLabels();
      const formattedResult = labels
        .map((label: any) => `${label.name} - ID: ${label.id} (${label.type})`)
        .join("\n");
      return {
        content: [{ type: "text", text: formattedResult }],
        isError: false,
      };
    }
  • MCP tool schema definition specifying the name, description, and input schema (empty object, no parameters required).
    import { type Tool } from "@modelcontextprotocol/sdk/types.js";
    
    export const LIST_LABELS_TOOL: Tool = {
      name: "google_gmail_list_labels",
      description: "List all available Gmail labels",
      inputSchema: {
        type: "object",
        properties: {},
      },
    };
  • Server request handler switch case that registers and dispatches calls to the google_gmail_list_labels tool by invoking the corresponding Gmail handler.
    case "google_gmail_list_labels":
      return await gmailHandlers.handleGmailListLabels(
        args,
        googleGmailInstance
      );
  • Helper function (type guard) that validates tool arguments, ensuring no arguments are provided as per the schema.
    export function isListLabelsArgs(args: any): args is Record<string, never> {
      return args && Object.keys(args).length === 0;
    }
  • Core Gmail service method in GoogleGmail class that makes the actual Google Gmail API call to list user labels.
    async listLabels() {
      try {
        const response = await this.gmail.users.labels.list({
          userId: "me",
        });
    
        return response.data.labels.map((label: any) => ({
          id: label.id,
          name: label.name,
          type: label.type,
        }));
      } catch (error) {
        throw new Error(
          `Failed to list labels: ${
            error instanceof Error ? error.message : String(error)
          }`
        );
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states what the tool does but lacks behavioral details such as authentication requirements, rate limits, pagination, or the format of the returned label list. This is a significant gap for a tool with zero annotation coverage.

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, clear sentence that efficiently conveys the core functionality without unnecessary words. It is front-loaded and wastes no space, making it easy 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 lack of annotations and output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., list structure, label properties) or behavioral aspects like error handling. For a tool with no structured metadata, more context is needed to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so there's no need for parameter details in the description. The description appropriately focuses on the tool's purpose without redundant parameter information, earning a baseline score of 4 for zero-parameter tools.

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') and resource ('all available Gmail labels'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'google_gmail_list_emails' or 'google_gmail_modify_labels' beyond the obvious label vs. email distinction.

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?

No guidance is provided on when to use this tool versus alternatives. For example, it doesn't mention whether this is for retrieving labels to apply to emails via 'google_gmail_modify_labels' or for general reference. The description lacks context about prerequisites or typical use cases.

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