Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

list_calendar_events

Retrieve calendar events from Fastmail. Filter by date range and specific calendar to get the events you need.

Instructions

List events from a calendar

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendarIdNoID of the calendar (optional, defaults to all calendars)
startDateNoFilter events starting from this date (ISO 8601, e.g. 2026-03-23T00:00:00Z)
endDateNoFilter events ending before this date (ISO 8601, e.g. 2026-03-30T00:00:00Z)
limitNoMaximum number of events to return (default: 50)

Implementation Reference

  • src/index.ts:494-519 (registration)
    Tool 'list_calendar_events' is registered in the ListToolsRequestSchema handler with its name, description, and inputSchema (calendarId, startDate, endDate, limit).
    {
      name: 'list_calendar_events',
      description: 'List events from a calendar',
      inputSchema: {
        type: 'object',
        properties: {
          calendarId: {
            type: 'string',
            description: 'ID of the calendar (optional, defaults to all calendars)',
          },
          startDate: {
            type: 'string',
            description: 'Filter events starting from this date (ISO 8601, e.g. 2026-03-23T00:00:00Z)',
          },
          endDate: {
            type: 'string',
            description: 'Filter events ending before this date (ISO 8601, e.g. 2026-03-30T00:00:00Z)',
          },
          limit: {
            type: 'number',
            description: 'Maximum number of events to return (default: 50)',
            default: 50,
          },
        },
      },
    },
  • Handler for 'list_calendar_events' in the CallToolRequestSchema switch-case. Extracts calendarId, limit, startDate, endDate from args; first tries JMAP via ContactsCalendarClient.getCalendarEvents(), falls back to CalDAVCalendarClient.getCalendarEvents().
    case 'list_calendar_events': {
      const { calendarId, limit = 50, startDate, endDate } = args as any;
      try {
        const contactsClient = initializeContactsCalendarClient();
        const events = await contactsClient.getCalendarEvents(calendarId, limit);
        return { content: [{ type: 'text', text: JSON.stringify(events, 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 events = await davClient.getCalendarEvents(calendarId, limit, startDate, endDate);
        return { content: [{ type: 'text', text: JSON.stringify(events, null, 2) }] };
      }
    }
  • JMAP implementation: ContactsCalendarClient.getCalendarEvents() - checks permissions, builds CalendarEvent/query + CalendarEvent/get JMAP request with optional calendarId filter, sorts by start ascending, returns events.
    async getCalendarEvents(calendarId?: string, limit: number = 50): 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 filter = calendarId ? { inCalendar: calendarId } : {};
      
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:calendars'],
        methodCalls: [
          ['CalendarEvent/query', {
            accountId: session.accountId,
            filter,
            sort: [{ property: 'start', isAscending: true }],
            limit
          }, 'query'],
          ['CalendarEvent/get', {
            accountId: session.accountId,
            '#ids': { resultOf: 'query', name: 'CalendarEvent/query', path: '/ids' },
            properties: ['id', 'title', 'description', 'start', 'end', 'location', 'participants']
          }, 'events']
        ]
      };
    
      try {
        const response = await this.makeRequest(request);
        return this.getListResult(response, 1);
      } catch (error) {
        throw new Error(`Calendar events access not supported: ${error instanceof Error ? error.message : String(error)}. Try checking account permissions or enabling calendar API access in Fastmail settings.`);
      }
    }
  • CalDAV fallback implementation: CalDAVCalendarClient.getCalendarEvents() - fetches calendar objects from DAVClient, with optional calendarId filter, optional timeRange filter (startDate/endDate), parses iCalendar VEVENT data, sorts by start date, limits results.
    async getCalendarEvents(calendarId?: string, limit: number = 50, startDate?: string, endDate?: string): Promise<CalendarEvent[]> {
      const client = await this.getClient();
    
      if (!this.calendars) {
        this.calendars = await client.fetchCalendars();
      }
    
      let targetCalendars = this.calendars.filter(
        c => c.displayName !== 'DEFAULT_TASK_CALENDAR_NAME'
      );
      if (calendarId) {
        targetCalendars = targetCalendars.filter(
          c => c.url === calendarId || c.displayName === calendarId
        );
      }
    
      const fetchOptions: any = {};
      if (startDate || endDate) {
        fetchOptions.timeRange = {
          start: startDate || '1970-01-01T00:00:00Z',
          end: endDate || '2099-12-31T23:59:59Z',
        };
      }
    
      const allEvents: CalendarEvent[] = [];
      for (const cal of targetCalendars) {
        const objects = await client.fetchCalendarObjects({ calendar: cal, ...fetchOptions });
        for (const obj of objects) {
          allEvents.push(parseCalendarObject(obj));
        }
        if (allEvents.length >= limit) break;
      }
    
      // Sort by start date ascending
      allEvents.sort((a, b) => (a.start || '').localeCompare(b.start || ''));
    
      return allEvents.slice(0, limit);
    }
  • Helper functions for CalDAV event parsing: parseCalendarObject() parses DAVCalendarObject into CalendarEvent, extractVEvent() extracts VEVENT block, parseICalValue() and formatICalDate() handle iCalendar property parsing.
    export function parseCalendarObject(obj: DAVCalendarObject): CalendarEvent {
      const vevent = extractVEvent(obj.data || '');
      const title = parseICalValue(vevent, 'SUMMARY') || 'Untitled';
      const description = parseICalValue(vevent, 'DESCRIPTION');
      const rawStart = parseICalValue(vevent, 'DTSTART');
      const rawEnd = parseICalValue(vevent, 'DTEND');
      const location = parseICalValue(vevent, 'LOCATION');
      const uid = parseICalValue(vevent, 'UID') || obj.url || '';
    
      return {
        id: uid,
        url: obj.url || '',
        title: unescapeICalText(title),
        description: description ? unescapeICalText(description) : undefined,
        start: formatICalDate(rawStart),
        end: formatICalDate(rawEnd),
        location: location ? unescapeICalText(location) : undefined,
      };
    }
    
    /**
     * Unescape an iCalendar text value (RFC 5545 §3.3.11).
     * Reverses escaping of newlines, semicolons, commas, and backslashes.
     */
    export function unescapeICalText(value: string): string {
      return value
        .replace(/\\n/gi, '\n')
        .replace(/\\;/g, ';')
        .replace(/\\,/g, ',')
        .replace(/\\\\/g, '\\');
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits, but it provides none. Missing details on pagination, ordering, timezone handling, or return format.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Only one sentence, which is efficient but too brief for a tool with 4 parameters and many siblings. Could include more context without being verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Lacks completeness: no mention of return fields, default behavior when calendarId is omitted, or limitations. For a listing tool with date filters, more context is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% description coverage with clear parameter details. The description adds no extra meaning beyond the schema, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it lists events from a calendar, but does not specify the scope (e.g., single calendar or all) or differentiate from sibling tools like get_calendar_event.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool vs alternatives such as get_calendar_event or search_emails. Missing context on prerequisites or default behavior.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/owen-nash/fastmail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server