Skip to main content
Glama

gmail_list_labels

Retrieve all Gmail labels, including system and user-created ones, to organize and manage email categories effectively.

Instructions

List all Gmail labels including both system labels (INBOX, SENT, etc.) and user-created labels. Returns label names and IDs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Tool schema definition for 'gmail_list_labels' with no input parameters.
    Tool(
        name="gmail_list_labels",
        description="List all Gmail labels including both system labels (INBOX, SENT, etc.) and user-created labels. Returns label names and IDs.",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": []
        },
  • Registration of all Gmail tools including 'gmail_list_labels' via the MCP server's list_tools handler.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        return GMAIL_TOOLS
  • Tool handler in handle_call_tool that executes gmail_list_labels by calling GmailClient.get_labels() and formatting the result.
    elif name == "gmail_list_labels":
        labels = await client.get_labels()
        return [TextContent(type="text", text=_format_labels_detailed(labels))]
  • Core handler implementation in GmailClient that calls the Gmail API to list all labels.
    async def get_labels(self) -> list[dict]:
        """Get all Gmail labels."""
        try:
            results = self.service.users().labels().list(userId="me").execute()
            return results.get("labels", [])
        except HttpError as e:
            logger.error(f"Failed to get labels: {e}")
            raise
  • Helper function to format the list of labels into a detailed text response, separating system and user labels.
    def _format_labels_detailed(labels: list[dict]) -> str:
        """Format labels list with full details for display.
        
        Args:
            labels: List of label dictionaries.
            
        Returns:
            str: Formatted string representation.
        """
        lines = ["Gmail Labels:\n"]
        
        system_labels = []
        user_labels = []
        
        for label in labels:
            if label.get("type") == "system":
                system_labels.append(label)
            else:
                user_labels.append(label)
        
        if system_labels:
            lines.append("System Labels:")
            for label in sorted(system_labels, key=lambda x: x.get("name", "")):
                lines.append(f"  - {label['name']} (ID: {label['id']})")
        
        if user_labels:
            lines.append("\nUser Labels:")
            for label in sorted(user_labels, key=lambda x: x.get("name", "")):
                color_info = ""
                if label.get("color"):
                    color_info = f" [color: {label['color'].get('backgroundColor', 'default')}]"
                lines.append(f"  - {label['name']} (ID: {label['id']}){color_info}")
        
        return "\n".join(lines)
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses the return format ('label names and IDs') and scope of labels included, which is helpful behavioral context. However, it lacks details on permissions needed, rate limits, pagination, or error handling, leaving gaps for a read operation.

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, well-structured sentence that efficiently conveys purpose, scope, and return values without any wasted words. It is front-loaded with the core action and maintains clarity throughout.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (0 parameters, no output schema, no annotations), the description is largely complete—it explains what the tool does, what it returns, and the label types included. However, it could benefit from mentioning any limitations (e.g., label count constraints) to achieve full completeness.

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 with 100% schema description coverage, so the schema fully documents the lack of inputs. The description adds no parameter information, which is appropriate here, earning a baseline score above 3 due to the zero-parameter scenario.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('List all Gmail labels') and distinguishes what it includes ('both system labels... and user-created labels'), differentiating it from siblings like gmail_get_categories or gmail_list_unread. It specifies the resource (Gmail labels) with scope details.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving all labels, but provides no explicit guidance on when to use this tool versus alternatives like gmail_get_categories or gmail_search. There's no mention of prerequisites, exclusions, or specific contexts where this tool is preferred.

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

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/murphy360/mcp_gmail'

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