Skip to main content
Glama

calendar_get_upcoming_events

Retrieve upcoming calendar events within a specified date range to help users view and manage their schedule.

Instructions

Get upcoming events in date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoNumber of days ahead to look (default: 7)

Implementation Reference

  • src/index.ts:266-277 (registration)
    Registration of the calendar_get_upcoming_events tool, including name, description, and input schema definition.
    name: 'calendar_get_upcoming_events', description: 'Get upcoming events in date range', inputSchema: { type: 'object', properties: { days: { type: 'number', description: 'Number of days ahead to look (default: 7)', }, }, }, },
  • The handler for calendar_get_upcoming_events executes an AppleScript command via execAsync to retrieve upcoming calendar events within the specified number of days (default 7), formats the output, and returns it as text content.
    case 'calendar_get_upcoming_events': try { const days = (args?.days as number) || 7; const command = `osascript -e 'on run argv set numDays to (item 1 of argv) as number tell application "Calendar" set upcomingEvents to {} set startDate to (current date) set endDate to startDate + (numDays * 24 * 60 * 60) repeat with aCal in calendars set calName to title of aCal repeat with anEvent in events of aCal set eventStart to start date of anEvent if eventStart ≥ startDate and eventStart ≤ endDate then set eventSummary to summary of anEvent set eventTime to (eventStart as string) set end of upcomingEvents to (eventSummary & " (" & calName & ") - " & eventTime) end if end repeat end repeat return upcomingEvents as string end tell end run' -- ${days}`; const { stdout, stderr } = await execAsync(command); if (stderr.trim()) { return { content: [ { type: 'text', text: `Error getting upcoming events: ${stderr.trim()}`, }, ], }; } const output = stdout.trim(); if (!output || output === '') { return { content: [ { type: 'text', text: `No events scheduled in the next ${days} days`, }, ], }; } return { content: [ { type: 'text', text: `Upcoming Events (next ${days} days):\n${output}`, }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error executing upcoming events command: ${error.message}`, }, ], }; }

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/samicokar/mcp-mac'

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