Skip to main content
Glama
taylorwilsdon

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

list_calendars

Retrieve a formatted list of accessible calendars for a user, including details like summary, ID, and primary status, using their Google email address.

Instructions

Retrieves a list of calendars accessible to the authenticated user. Args: user_google_email (str): The user's Google email address. Required. Returns: str: A formatted list of the user's calendars (summary, ID, primary status).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceYes
user_google_emailYes

Implementation Reference

  • The complete handler implementation for the 'list_calendars' tool, including decorators for registration (@server.tool()), error handling, and Google service authentication. This function lists all calendars accessible to the user and returns a formatted string summary.
    @server.tool() @handle_http_errors("list_calendars", is_read_only=True, service_type="calendar") @require_google_service("calendar", "calendar_read") async def list_calendars(service, user_google_email: str) -> str: """ Retrieves a list of calendars accessible to the authenticated user. Args: user_google_email (str): The user's Google email address. Required. Returns: str: A formatted list of the user's calendars (summary, ID, primary status). """ logger.info(f"[list_calendars] Invoked. Email: '{user_google_email}'") calendar_list_response = await asyncio.to_thread( lambda: service.calendarList().list().execute() ) items = calendar_list_response.get("items", []) if not items: return f"No calendars found for {user_google_email}." calendars_summary_list = [ f"- \"{cal.get('summary', 'No Summary')}\"{' (Primary)' if cal.get('primary') else ''} (ID: {cal['id']})" for cal in items ] text_output = ( f"Successfully listed {len(items)} calendars for {user_google_email}:\n" + "\n".join(calendars_summary_list) ) logger.info(f"Successfully listed {len(items)} calendars for {user_google_email}.") return text_output
  • The @server.tool() decorator registers the list_calendars function as an MCP tool.
    @server.tool()
  • Function signature and docstring defining the input parameters and output format, which serves as the tool schema for MCP.
    async def list_calendars(service, user_google_email: str) -> str: """ Retrieves a list of calendars accessible to the authenticated user. Args: user_google_email (str): The user's Google email address. Required. Returns: str: A formatted list of the user's calendars (summary, ID, primary status).

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