get_all_calendars
Retrieve all Google Calendars accessible to your account to view and manage your schedules across different calendars.
Instructions
Get all Google Calendars accessible to the user
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:316-337 (handler)MCP tool handler for 'get_all_calendars'. Decorated with @mcp.tool(), it invokes the helper function and returns a JSON-formatted response containing the list of calendars.@mcp.tool() def get_all_calendars() -> str: """Get all Google Calendars accessible to the user""" try: calendars = GoogleCalendarTools.get_all_calendars(NANGO_CONNECTION_ID, NANGO_INTEGRATION_ID) result = { "success": True, "calendars": calendars, "total_calendars": len(calendars), "message": f"Retrieved {len(calendars)} calendars successfully" } return json.dumps(result, indent=2) except Exception as e: logger.error(f"Error in get_all_calendars: {e}") return json.dumps({ "success": False, "error": str(e), "message": "Failed to retrieve calendars" }, indent=2)
- main.py:105-138 (helper)Core helper function in GoogleCalendarTools that handles authentication and retrieves all calendars using the Google Calendar API with pagination support and optimized field selection.@staticmethod def get_all_calendars(connection_id: str, provider_config_key: str) -> List[Dict]: """Get all calendars with optimized field selection""" try: service = GoogleCalendarAuth.authenticate_google_calendar(connection_id, provider_config_key) calendars = [] page_token = None fields = "nextPageToken,items(id,summary,description,primary,accessRole,backgroundColor,foregroundColor,timeZone)" while True: request_params = {'fields': fields} if page_token: request_params['pageToken'] = page_token calendar_list = service.calendarList().list(**request_params).execute() page_calendars = calendar_list.get('items', []) calendars.extend(page_calendars) page_token = calendar_list.get('nextPageToken') if not page_token: break return calendars except HttpError as error: logger.error(f'HTTP error in get_all_calendars: {error}') raise except Exception as error: logger.error(f'Unexpected error in get_all_calendars: {error}') raise