Skip to main content
Glama

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
NameRequiredDescriptionDefault
days_aheadNo
calendar_idNoprimary

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)

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