get_calendar_event
Retrieve a specific calendar event by providing its unique event ID.
Instructions
Get a specific calendar event by ID
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventId | Yes | ID of the event to retrieve |
Implementation Reference
- src/index.ts:1337-1354 (handler)The CallToolRequestSchema handler for 'get_calendar_event'. Extracts eventId from args, validates it, then tries JMAP ContactsCalendarClient.getCalendarEventById() first, falling back to CalDAVClient.getCalendarEventById() if JMAP fails.
case 'get_calendar_event': { const { eventId } = args as any; if (!eventId) { throw new McpError(ErrorCode.InvalidParams, 'eventId is required'); } try { const contactsClient = initializeContactsCalendarClient(); const event = await contactsClient.getCalendarEventById(eventId); return { content: [{ type: 'text', text: JSON.stringify(event, null, 2) }] }; } catch { const davClient = initializeCalDAVClient(); if (!davClient) { throw new McpError(ErrorCode.InvalidRequest, 'JMAP calendars not available and CalDAV not configured. Set FASTMAIL_CALDAV_USERNAME and FASTMAIL_CALDAV_PASSWORD to use CalDAV.'); } const event = await davClient.getCalendarEventById(eventId); return { content: [{ type: 'text', text: JSON.stringify(event, null, 2) }] }; } } - src/contacts-calendar.ts:186-211 (handler)JMAP implementation of getCalendarEventById. Checks calendar permissions, builds a JMAP CalendarEvent/get request for the given event ID, and returns the event data.
async getCalendarEventById(id: string): Promise<any> { // Check permissions first const hasPermission = await this.checkCalendarsPermission(); if (!hasPermission) { throw new Error('Calendar access not available. This account may not have JMAP calendar permissions enabled. Please check your Fastmail account settings or contact support to enable calendar API access.'); } const session = await this.getSession(); const request: JmapRequest = { using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:calendars'], methodCalls: [ ['CalendarEvent/get', { accountId: session.accountId, ids: [id] }, 'event'] ] }; try { const response = await this.makeRequest(request); return this.getListResult(response, 0)[0]; } catch (error) { throw new Error(`Calendar event access not supported: ${error instanceof Error ? error.message : String(error)}. Try checking account permissions or enabling calendar API access in Fastmail settings.`); } } - src/caldav-client.ts:265-284 (handler)CalDAV fallback implementation of getCalendarEventById. Fetches all calendar objects across calendars, searches by UID or URL matching the eventId, and returns the parsed event or null.
async getCalendarEventById(eventId: string): Promise<CalendarEvent | null> { const client = await this.getClient(); if (!this.calendars) { this.calendars = await client.fetchCalendars(); } for (const cal of this.calendars) { const objects = await client.fetchCalendarObjects({ calendar: cal }); for (const obj of objects) { const vevent = extractVEvent(obj.data || ''); const uid = parseICalValue(vevent, 'UID'); if (uid === eventId || obj.url === eventId) { return parseCalendarObject(obj); } } } return null; } - src/index.ts:520-533 (schema)Schema registration for the 'get_calendar_event' tool in ListToolsRequestSchema. Defines input with required 'eventId' string field.
{ name: 'get_calendar_event', description: 'Get a specific calendar event by ID', inputSchema: { type: 'object', properties: { eventId: { type: 'string', description: 'ID of the event to retrieve', }, }, required: ['eventId'], }, },