Skip to main content
Glama
taylorwilsdon

Google Workspace MCP Server - Control Gmail, Calendar, Docs, Sheets, Slides, Chat, Forms & Drive

list_gmail_labels

Retrieve and display all Gmail labels, including their IDs, names, and types, for a specified user email address using the Google Workspace MCP Server.

Instructions

Lists all labels in the user's Gmail account. Args: user_google_email (str): The user's Google email address. Required. Returns: str: A formatted list of all labels with their IDs, names, and types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceYes
user_google_emailYes

Implementation Reference

  • The main handler function for the 'list_gmail_labels' tool, including decorators for registration (@server.tool()), error handling, and authentication requirements. It lists all Gmail labels, categorizing them into system and user labels, and returns a formatted string.
    @handle_http_errors("list_gmail_labels", is_read_only=True, service_type="gmail") @require_google_service("gmail", "gmail_read") async def list_gmail_labels(service, user_google_email: str) -> str: """ Lists all labels in the user's Gmail account. Args: user_google_email (str): The user's Google email address. Required. Returns: str: A formatted list of all labels with their IDs, names, and types. """ logger.info(f"[list_gmail_labels] Invoked. Email: '{user_google_email}'") response = await asyncio.to_thread( service.users().labels().list(userId="me").execute ) labels = response.get("labels", []) if not labels: return "No labels found." lines = [f"Found {len(labels)} labels:", ""] 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 system_labels: lines.append(f" • {label['name']} (ID: {label['id']})") lines.append("") if user_labels: lines.append("🏷️ USER LABELS:") for label in user_labels: lines.append(f" • {label['name']} (ID: {label['id']})") return "\n".join(lines)

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/taylorwilsdon/google_workspace_mcp'

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