Skip to main content
Glama

gmail_rename_label

Change the name of an existing Gmail label to better organize your email categories. This tool allows you to update label names for improved email management.

Instructions

Rename an existing Gmail label. Cannot rename system labels.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
label_nameNoCurrent name of the label to rename. Provide either label_name or label_id.
label_idNoID of the label to rename. Provide either label_name or label_id.
new_nameYesNew name for the label.

Implementation Reference

  • Core implementation of gmail_rename_label tool using Gmail API labels.patch to update label name.
    async def rename_label(self, label_id: str, new_name: str) -> dict:
        """Rename a Gmail label.
        
        Args:
            label_id: The ID of the label to rename
            new_name: The new name for the label
            
        Returns:
            Updated label object or error
        """
        try:
            result = self.service.users().labels().patch(
                userId="me",
                id=label_id,
                body={"name": new_name}
            ).execute()
            
            logger.info(f"Renamed label {label_id} to: {new_name}")
            return {"success": True, "label": result}
            
        except HttpError as e:
            logger.error(f"Failed to rename label: {e}")
            return {"success": False, "error": str(e)}
  • Tool dispatch handler in handle_call_tool that processes arguments, finds label if needed, and calls GmailClient.rename_label.
    elif name == "gmail_rename_label":
        label_id = arguments.get("label_id")
        label_name = arguments.get("label_name")
        new_name = arguments.get("new_name")
        
        if not new_name:
            return [TextContent(type="text", text="Error: new_name is required.")]
        if not label_id and not label_name:
            return [TextContent(type="text", text="Error: Provide either label_id or label_name.")]
        
        # Find label by name if ID not provided
        if not label_id:
            label = await client.find_label_by_name(label_name)
            if not label:
                return [TextContent(type="text", text=f"Error: Label not found: {label_name}")]
            label_id = label["id"]
            old_name = label["name"]
        else:
            old_name = label_name or label_id
        
        result = await client.rename_label(label_id, new_name)
        if result["success"]:
            return [TextContent(type="text", text=f"Success: Renamed label '{old_name}' to '{new_name}'.")]
        else:
            return [TextContent(type="text", text=f"Error: Failed to rename label. {result['error']}")]
  • JSON schema definition for input parameters and tool description in GMAIL_TOOLS list.
        name="gmail_rename_label",
        description="Rename an existing Gmail label. Cannot rename system labels.",
        inputSchema={
            "type": "object",
            "properties": {
                "label_name": {
                    "type": "string",
                    "description": "Current name of the label to rename. Provide either label_name or label_id."
                },
                "label_id": {
                    "type": "string",
                    "description": "ID of the label to rename. Provide either label_name or label_id."
                },
                "new_name": {
                    "type": "string",
                    "description": "New name for the label."
                }
            },
            "required": ["new_name"]
        },
    ),
  • Registers the list_tools handler that returns GMAIL_TOOLS including the gmail_rename_label tool definition.
    @server.list_tools()
    async def list_tools() -> list[Tool]:
        return GMAIL_TOOLS
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 of behavioral disclosure. It adds some context by specifying the system label constraint, but does not cover other behavioral aspects like permissions needed, error handling, or what happens if the new name conflicts. It adequately describes the mutation nature but lacks depth for a tool with no annotation support.

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, efficient sentence that is front-loaded with the core purpose and includes a critical constraint. There is no wasted language, and every word earns its place, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's moderate complexity (mutation with 3 parameters), no annotations, and no output schema, the description is minimally adequate. It covers the purpose and a key constraint but lacks details on behavioral traits, error cases, or return values, leaving gaps for an agent to operate effectively.

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 does not add any additional meaning beyond what the schema provides, such as format details or examples. Baseline 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.

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 ('Rename') and resource ('an existing Gmail label'), and distinguishes it from siblings by specifying it cannot rename system labels. It precisely identifies what the tool does without being vague or tautological.

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

Usage Guidelines4/5

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

The description provides clear context by stating 'Cannot rename system labels,' which implicitly guides when not to use it. However, it does not explicitly mention when to use this tool versus alternatives like gmail_create_label or gmail_delete_label, or provide prerequisites beyond the system label restriction.

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