google_calendar_get_events
Retrieve upcoming Google Calendar events by specifying a limit, calendar ID, time range, search term, or inclusion of deleted events.
Instructions
Retrieve upcoming events from Google Calendar
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| calendarId | No | Optional: ID of calendar to use (defaults to primary if not specified) | |
| limit | No | Maximum number of events to return | |
| q | No | Free text search term for events | |
| showDeleted | No | Whether to include deleted events | |
| timeMax | No | End date/time in ISO format | |
| timeMin | No | Start date/time in ISO format (defaults to now) |
Implementation Reference
- handlers/calendar.ts:89-109 (handler)The main handler function for the google_calendar_get_events tool, which validates arguments and calls the GoogleCalendar instance to retrieve events.export async function handleCalendarGetEvents( args: any, googleCalendarInstance: GoogleCalendar ) { if (!isGetEventsArgs(args)) { throw new Error("Invalid arguments for google_calendar_get_events"); } const { limit, calendarId, timeMin, timeMax, q, showDeleted } = args; const result = await googleCalendarInstance.getEvents( limit || 10, calendarId, timeMin, timeMax, q, showDeleted ); return { content: [{ type: "text", text: result }], isError: false, }; }
- tools/calendar/index.ts:79-112 (schema)Tool schema definition for google_calendar_get_events, specifying input parameters and descriptions.export const GET_EVENTS_TOOL: Tool = { name: "google_calendar_get_events", description: "Retrieve upcoming events from Google Calendar", inputSchema: { type: "object", properties: { limit: { type: "number", description: "Maximum number of events to return", }, calendarId: { type: "string", description: "Optional: ID of calendar to use (defaults to primary if not specified)", }, timeMin: { type: "string", description: "Start date/time in ISO format (defaults to now)", }, timeMax: { type: "string", description: "End date/time in ISO format", }, q: { type: "string", description: "Free text search term for events", }, showDeleted: { type: "boolean", description: "Whether to include deleted events", }, }, }, };
- server-setup.ts:107-111 (registration)Registration of the tool in the server switch statement, dispatching to the handler function.case "google_calendar_get_events": return await calendarHandlers.handleCalendarGetEvents( args, googleCalendarInstance );
- utils/helper.ts:38-55 (helper)Type guard function for validating arguments to google_calendar_get_events.export function isGetEventsArgs(args: any): args is { limit?: number; calendarId?: string; timeMin?: string; timeMax?: string; q?: string; showDeleted?: boolean; } { return ( args && (args.limit === undefined || typeof args.limit === "number") && (args.calendarId === undefined || typeof args.calendarId === "string") && (args.timeMin === undefined || typeof args.timeMin === "string") && (args.timeMax === undefined || typeof args.timeMax === "string") && (args.q === undefined || typeof args.q === "string") && (args.showDeleted === undefined || typeof args.showDeleted === "boolean") ); }