list_events
Retrieve upcoming calendar events within specified time ranges using the Google Calendar API, with customizable start and end times, and control over the number of events returned.
Instructions
List upcoming calendar events
Input 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) |
Input Schema (JSON Schema)
{
"properties": {
"maxResults": {
"description": "Maximum number of events to return (default: 10)",
"type": "number"
},
"timeMax": {
"description": "End time in ISO format",
"type": "string"
},
"timeMin": {
"description": "Start time in ISO format (default: now)",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/index.ts:672-714 (handler)The handler function that executes the list_events tool. It fetches upcoming calendar events from Google Calendar API using the provided parameters (maxResults, timeMin, timeMax), formats them, and returns as JSON text content.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: "primary", 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:160-180 (registration)Tool registration in the listTools response, including name, description, and input schema definition.{ 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:163-179 (schema)Input schema definition for the list_events tool, specifying parameters for filtering and limiting 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:282-283 (handler)Dispatch case in the CallToolRequest handler that routes list_events calls to the handleListEvents function.case "list_events": return await this.handleListEvents(request.params.arguments);