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

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