list_calendars
Retrieve a list of all calendars available in your Fastmail account.
Instructions
List all calendars
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_calendars"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:487-493 (registration)Registration of the 'list_calendars' tool in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema (no input parameters).
name: 'list_calendars', description: 'List all calendars', inputSchema: { type: 'object', properties: {}, }, }, - src/index.ts:1305-1319 (handler)Handler for the 'list_calendars' tool call. First tries JMAP via ContactsCalendarClient.getCalendars(), and on failure falls back to CalDAV via CalDAVCalendarClient.getCalendars().
case 'list_calendars': { try { const contactsClient = initializeContactsCalendarClient(); const calendars = await contactsClient.getCalendars(); return { content: [{ type: 'text', text: JSON.stringify(calendars, null, 2) }] }; } catch { // JMAP calendars not available, try CalDAV 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 calendars = await davClient.getCalendars(); return { content: [{ type: 'text', text: JSON.stringify(calendars, null, 2) }] }; } } - src/contacts-calendar.ts:123-148 (helper)ContactsCalendarClient.getCalendars() - JMAP implementation. Checks calendar permissions, then makes a Calendar/get JMAP API request to the Fastmail server.
async getCalendars(): 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: [ ['Calendar/get', { accountId: session.accountId }, 'calendars'] ] }; try { const response = await this.makeRequest(request); return this.getListResult(response, 0); } catch (error) { // Calendar access might require special permissions throw new Error(`Calendar access not supported or requires additional permissions. This may be due to account settings or JMAP scope limitations: ${error instanceof Error ? error.message : String(error)}. Try checking account permissions or enabling calendar API access in Fastmail settings.`); } } - src/caldav-client.ts:210-224 (helper)CalDAVCalendarClient.getCalendars() - CalDAV fallback implementation. Uses tsdav library to fetch calendars and maps them to CalendarInfo objects.
async getCalendars(): Promise<CalendarInfo[]> { const client = await this.getClient(); const calendars = await client.fetchCalendars(); this.calendars = calendars; return calendars .filter(c => c.displayName !== 'DEFAULT_TASK_CALENDAR_NAME') .map(c => ({ id: c.url || '', displayName: String(c.displayName || 'Unnamed'), url: c.url || '', description: c.description || undefined, color: (c as any).calendarColor || undefined, })); }