Skip to main content
Glama

gmail_delete_label

Delete custom labels from Gmail by name or ID to organize your inbox. Requires confirmation before removal and cannot delete system labels.

Instructions

Delete a Gmail label by name or ID. Cannot delete system labels. Requires confirmation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
label_nameNoName of the label to delete. Provide either label_name or label_id.
label_idNoID of the label to delete. Provide either label_name or label_id.
confirmYesMust be true to actually delete. Set false to preview what would be deleted.

Implementation Reference

  • Registration of the 'gmail_delete_label' tool including its input schema, description, and parameters.
    Tool(
        name="gmail_delete_label",
        description="Delete a Gmail label by name or ID. Cannot delete system labels. Requires confirmation.",
        inputSchema={
            "type": "object",
            "properties": {
                "label_name": {
                    "type": "string",
                    "description": "Name of the label to delete. Provide either label_name or label_id."
                },
                "label_id": {
                    "type": "string",
                    "description": "ID of the label to delete. Provide either label_name or label_id."
                },
                "confirm": {
                    "type": "boolean",
                    "description": "Must be true to actually delete. Set false to preview what would be deleted."
                }
            },
            "required": ["confirm"]
        },
    ),
  • Handler logic for executing the 'gmail_delete_label' tool: validates input, finds label by name if needed, requires confirmation, calls client.delete_label, and returns success/error message.
    elif name == "gmail_delete_label":
        label_id = arguments.get("label_id")
        label_name = arguments.get("label_name")
        confirm = arguments.get("confirm", False)
        
        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"]
            found_name = label["name"]
        else:
            found_name = label_name or label_id
        
        if not confirm:
            return [TextContent(
                type="text",
                text=f"Preview: Label '{found_name}' (ID: {label_id}) would be deleted. Set confirm=true to proceed."
            )]
        
        result = await client.delete_label(label_id)
        if result["success"]:
            return [TextContent(type="text", text=f"Success: Deleted label '{found_name}'.")]
        else:
            return [TextContent(type="text", text=f"Error: Failed to delete label. {result['error']}")]
  • Core implementation of label deletion using Gmail API: calls service.users().labels().delete and handles errors.
    async def delete_label(self, label_id: str) -> dict:
        """Delete a Gmail label.
        
        Args:
            label_id: The ID of the label to delete
            
        Returns:
            Success/error dict
        """
        try:
            self.service.users().labels().delete(
                userId="me",
                id=label_id
            ).execute()
            
            logger.info(f"Deleted label: {label_id}")
            return {"success": True, "deleted_label_id": label_id}
            
        except HttpError as e:
            logger.error(f"Failed to delete label: {e}")
            return {"success": False, "error": str(e)}
  • Input schema definition for the 'gmail_delete_label' tool specifying parameters: label_name or label_id (string), confirm (boolean required).
    Tool(
        name="gmail_delete_label",
        description="Delete a Gmail label by name or ID. Cannot delete system labels. Requires confirmation.",
        inputSchema={
            "type": "object",
            "properties": {
                "label_name": {
                    "type": "string",
                    "description": "Name of the label to delete. Provide either label_name or label_id."
                },
                "label_id": {
                    "type": "string",
                    "description": "ID of the label to delete. Provide either label_name or label_id."
                },
                "confirm": {
                    "type": "boolean",
                    "description": "Must be true to actually delete. Set false to preview what would be deleted."
                }
            },
            "required": ["confirm"]
        },
    ),
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 useful context beyond the schema by stating the tool cannot delete system labels and requires confirmation, which are behavioral traits. However, it does not cover other aspects like error handling, permissions needed, or what happens on deletion (e.g., if messages lose the label).

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 front-loaded with the core purpose in the first sentence, followed by two concise constraints. Every sentence earns its place by adding critical information (deletion action, system label restriction, confirmation need) without redundancy or fluff.

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 no annotations and no output schema, the description is moderately complete for a destructive tool. It covers the action, constraints, and safety mechanism, but lacks details on return values, error cases, or side effects (e.g., impact on labeled messages). For a deletion tool with 3 parameters, this leaves some gaps in contextual understanding.

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 parameters thoroughly. The description adds minimal value beyond the schema by implying the 'confirm' parameter is for safety, but does not provide additional semantics like format examples or edge cases. Baseline 3 is appropriate as 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 ('Delete a Gmail label') and resource ('by name or ID'), distinguishing it from siblings like 'gmail_rename_label' or 'gmail_create_label'. It explicitly mentions constraints ('Cannot delete system labels') that differentiate its scope from other label-related tools.

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 on when to use this tool (to delete labels) and when not to (for system labels), but does not explicitly name alternatives like 'gmail_rename_label' or 'gmail_remove_label_from_messages' for different operations. It implies usage through the confirmation requirement but lacks explicit comparison to siblings.

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