list_events
Retrieve upcoming calendar events within a specified time range using start and end times in ISO format. Set the maximum number of results to display. Preserves calendar data by preventing deletions while maintaining event creation.
Instructions
List upcoming calendar events
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | Maximum number of events to return (default: 10) | |
| timeMax | No | End time in ISO format | |
| timeMin | No | Start time in ISO format (default: now) |
Implementation Reference
- src/index.ts:492-534 (handler)Executes the list_events tool by querying Google Calendar events.list API with provided filters and returns formatted event list or error.private async handleListEvents(args: any) { try { const maxResults = args?.maxResults || 10; const timeMin = args?.timeMin || new Date().toISOString(); const timeMax = args?.timeMax; const response = await this.calendar.events.list({ calendarId: 'camilagolin3@gmail.com', timeMin, timeMax, maxResults, singleEvents: true, orderBy: 'startTime', }); const events = response.data.items?.map((event) => ({ id: event.id, summary: event.summary, start: event.start, end: event.end, location: event.location, })); return { content: [ { type: 'text', text: JSON.stringify(events, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error fetching calendar events: ${error.message}`, }, ], isError: true, }; } }
- src/index.ts:155-171 (schema)Defines the input schema for list_events tool parameters.inputSchema: { type: 'object', properties: { maxResults: { type: 'number', description: 'Maximum number of events to return (default: 10)', }, timeMin: { type: 'string', description: 'Start time in ISO format (default: now)', }, timeMax: { type: 'string', description: 'End time in ISO format', }, }, },
- src/index.ts:152-172 (registration)Registers the list_events tool in the ListTools response with name, description, and schema.{ name: 'list_events', description: 'List upcoming calendar events', inputSchema: { type: 'object', properties: { maxResults: { type: 'number', description: 'Maximum number of events to return (default: 10)', }, timeMin: { type: 'string', description: 'Start time in ISO format (default: now)', }, timeMax: { type: 'string', description: 'End time in ISO format', }, }, }, },
- src/index.ts:238-239 (registration)Routes CallTool requests for list_events to the handler function.case 'list_events': return await this.handleListEvents(request.params.arguments);