Skip to main content
Glama

get_all_calendars

Retrieve all Google Calendars accessible to your account to view and manage your schedule across multiple calendars.

Instructions

Get all Google Calendars accessible to the user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • main.py:106-137 (handler)
    Core handler logic: Authenticates with Google Calendar service via Nango, fetches all calendars using paginated API calls with optimized field selection, handles HTTP and unexpected errors.
    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
  • main.py:317-337 (registration)
    MCP tool registration via @mcp.tool() decorator. Thin wrapper that invokes core handler with hardcoded connection IDs and formats response as JSON string.
    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)
  • Tool docstring providing description used for schema/input schema in MCP/FastMCP.
    """Get all Google Calendars accessible to the user"""
  • main.py:68-97 (helper)
    Supporting authentication helper used by the handler to obtain Google Calendar service instance from Nango credentials.
    def authenticate_google_calendar(connection_id: str, provider_config_key: str): """Authenticate using Nango credentials and return Google Calendar service object""" try: # Get credentials from Nango nango_response = GoogleCalendarAuth.get_connection_credentials(connection_id, provider_config_key) # Extract credentials from Nango response credentials_data = nango_response.get('credentials', {}) # Create Google OAuth2 credentials object creds = Credentials( token=credentials_data.get('access_token'), refresh_token=credentials_data.get('refresh_token'), token_uri='https://oauth2.googleapis.com/token', client_id=credentials_data.get('client_id'), client_secret=credentials_data.get('client_secret'), scopes=SCOPES ) # Refresh token if needed if not creds.valid: if creds.expired and creds.refresh_token: creds.refresh(Request()) else: raise Exception("Invalid credentials and no refresh token available") # Build and return the service service = build('calendar', 'v3', credentials=creds) return service

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/Shameerpc5029/google-calendar-mcp'

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