get_upcoming_events
Retrieve scheduled events from Google Calendar for a specified number of upcoming days to view your agenda and manage time effectively.
Instructions
Get upcoming events for the next N days
Args: days_ahead: Number of days to look ahead (default: 7) calendar_id: Calendar ID (default: primary)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days_ahead | No | ||
| calendar_id | No | primary |
Implementation Reference
- main.py:465-492 (handler)Handler function decorated with @mcp.tool(), implementing the get_upcoming_events tool logic. Fetches upcoming events from Google Calendar within the specified days_ahead using GoogleCalendarTools.@mcp.tool() def get_upcoming_events(days_ahead: int = 7, calendar_id: str = "primary") -> str: """ Get upcoming events for the next N days Args: days_ahead: Number of days to look ahead (default: 7) calendar_id: Calendar ID (default: primary) """ try: # Calculate date range now = datetime.now() future = now + timedelta(days=days_ahead) time_min = now.isoformat() + 'Z' time_max = future.isoformat() + 'Z' result = GoogleCalendarTools.get_calendar_events( NANGO_CONNECTION_ID, NANGO_INTEGRATION_ID, calendar_id, time_min, time_max, 50 ) return json.dumps(result, indent=2) except Exception as e: logger.error(f"Error in get_upcoming_events: {e}") return json.dumps({ "success": False, "error": str(e), "message": "Failed to retrieve upcoming events" }, indent=2)