Skip to main content
Glama

calendar

Search, create, open, or list calendar events in the Apple Calendar app using specific criteria such as dates, titles, or event IDs. Simplify event management directly through the MCP server.

Instructions

Search, create, and open calendar events in Apple Calendar app

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendarNameNoName of the calendar to create the event in (optional for create operation, uses default calendar if not specified)
endDateNoEnd date/time of the event in ISO format (required for create operation)
eventIdNoID of the event to open (required for open operation)
fromDateNoStart date for search range in ISO format (optional, default is today)
isAllDayNoWhether the event is an all-day event (optional for create operation, default is false)
limitNoNumber of events to retrieve (optional, default 10)
locationNoLocation of the event (optional for create operation)
notesNoAdditional notes for the event (optional for create operation)
operationYesOperation to perform: 'search', 'open', 'list', or 'create'
searchTextNoText to search for in event titles, locations, and notes (required for search operation)
startDateNoStart date/time of the event in ISO format (required for create operation)
titleNoTitle of the event to create (required for create operation)
toDateNoEnd date for search range in ISO format (optional, default is 30 days from now for search, 7 days for list)

Implementation Reference

  • The main handler function for the 'calendar' tool. It parses arguments, loads the calendar module lazily, and dispatches to specific operations (search, open, list, create) by calling methods on the module.
    export async function handleCalendar(
      args: CalendarArgs,
      loadModule: LoadModuleFunction
    ): Promise<ToolResult> {
      try {
        const calendarModule = await loadModule("calendar");
    
        switch (args.operation) {
          case "search": {
            const events = await calendarModule.searchEvents(args.searchText, args.limit, args.fromDate, args.toDate);
            return {
              content: [{
                type: "text",
                text: events.length > 0 ? 
                  `Found ${events.length} events matching "${args.searchText}":\n\n${events.map(event => 
                    `${event.title} (${new Date(event.startDate!).toLocaleString()} - ${new Date(event.endDate!).toLocaleString()})\n` +
                    `Location: ${event.location || 'Not specified'}\n` +
                    `Calendar: ${event.calendarName}\n` +
                    `ID: ${event.id}\n` +
                    `${event.notes ? `Notes: ${event.notes}\n` : ''}`
                  ).join("\n\n")}` : 
                  `No events found matching "${args.searchText}".`
              }],
              isError: false
            };
          }
          
          case "open": {
            const result = await calendarModule.openEvent(args.eventId);
            return {
              content: [{
                type: "text",
                text: result.success ? 
                  result.message : 
                  `Error opening event: ${result.message}`
              }],
              isError: !result.success
            };
          }
          
          case "list": {
            const events = await calendarModule.getEvents(args.limit, args.fromDate, args.toDate);
            const startDateText = args.fromDate ? new Date(args.fromDate).toLocaleDateString() : 'today';
            const endDateText = args.toDate ? new Date(args.toDate).toLocaleDateString() : 'next 7 days';
            
            return {
              content: [{
                type: "text",
                text: events.length > 0 ? 
                  `Found ${events.length} events from ${startDateText} to ${endDateText}:\n\n${events.map(event => 
                    `${event.title} (${new Date(event.startDate!).toLocaleString()} - ${new Date(event.endDate!).toLocaleString()})\n` +
                    `Location: ${event.location || 'Not specified'}\n` +
                    `Calendar: ${event.calendarName}\n` +
                    `ID: ${event.id}`
                  ).join("\n\n")}` : 
                  `No events found from ${startDateText} to ${endDateText}.`
              }],
              isError: false
            };
          }
          
          case "create": {
            const result = await calendarModule.createEvent(args.title, args.startDate, args.endDate, args.location, args.notes, args.isAllDay, args.calendarName);
            return {
              content: [{
                type: "text",
                text: result.success ? 
                  `${result.message} Event scheduled from ${new Date(args.startDate).toLocaleString()} to ${new Date(args.endDate).toLocaleString()}${result.eventId ? `\nEvent ID: ${result.eventId}` : ''}` : 
                  `Error creating event: ${result.message}`
              }],
              isError: !result.success
            };
          }
          
          default:
            // This should be unreachable due to Zod validation
            throw new Error(`Unknown calendar operation: ${(args as any).operation}`);
        }
      } catch (error) {
        return {
          content: [{
            type: "text",
            text: `Error in calendar tool: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    }
  • Zod schema defining the discriminated union of input arguments for different calendar operations: search, open, list, create.
    // Define the Zod schema for calendar arguments
    export const CalendarArgsSchema = z.discriminatedUnion("operation", [
      z.object({ 
        operation: z.literal("search"), 
        searchText: z.string().min(1), 
        limit: z.number().optional(), 
        fromDate: z.string().datetime().optional(), 
        toDate: z.string().datetime().optional() 
      }),
      z.object({ operation: z.literal("open"), eventId: z.string().min(1) }),
      z.object({ 
        operation: z.literal("list"), 
        limit: z.number().optional(), 
        fromDate: z.string().datetime().optional(), 
        toDate: z.string().datetime().optional() 
      }),
      z.object({ 
        operation: z.literal("create"), 
        title: z.string().min(1), 
        startDate: z.string().datetime(), 
        endDate: z.string().datetime(), 
        location: z.string().optional(), 
        notes: z.string().optional(), 
        isAllDay: z.boolean().optional(), 
        calendarName: z.string().optional() 
      }),
    ]);
  • tools.ts:195-257 (registration)
    MCP Tool definition for 'calendar', including name, description, and inputSchema that matches the Zod schema used for validation.
    const CALENDAR_TOOL: Tool = {
      name: "calendar",
      description: "Search, create, and open calendar events in Apple Calendar app",
      inputSchema: {
        type: "object",
        properties: {
          operation: {
            type: "string",
            description: "Operation to perform: 'search', 'open', 'list', or 'create'",
            enum: ["search", "open", "list", "create"]
          },
          searchText: {
            type: "string",
            description: "Text to search for in event titles, locations, and notes (required for search operation)"
          },
          eventId: {
            type: "string",
            description: "ID of the event to open (required for open operation)"
          },
          limit: {
            type: "number",
            description: "Number of events to retrieve (optional, default 10)"
          },
          fromDate: {
            type: "string",
            description: "Start date for search range in ISO format (optional, default is today)"
          },
          toDate: {
            type: "string",
            description: "End date for search range in ISO format (optional, default is 30 days from now for search, 7 days for list)"
          },
          title: {
            type: "string",
            description: "Title of the event to create (required for create operation)"
          },
          startDate: {
            type: "string",
            description: "Start date/time of the event in ISO format (required for create operation)"
          },
          endDate: {
            type: "string",
            description: "End date/time of the event in ISO format (required for create operation)"
          },
          location: {
            type: "string",
            description: "Location of the event (optional for create operation)"
          },
          notes: {
            type: "string",
            description: "Additional notes for the event (optional for create operation)"
          },
          isAllDay: {
            type: "boolean",
            description: "Whether the event is an all-day event (optional for create operation, default is false)"
          },
          calendarName: {
            type: "string",
            description: "Name of the calendar to create the event in (optional for create operation, uses default calendar if not specified)"
          }
        },
        required: ["operation"]
      }
    };
  • index.ts:140-143 (registration)
    Server-side registration in the CallToolRequest handler switch statement, validating args with CalendarArgsSchema and calling handleCalendar.
    case "calendar": {
      const validatedArgs = CalendarArgsSchema.parse(args);
      return await handleCalendar(validatedArgs, loadModule);
    }
  • Exports the low-level calendar module with JXA-based functions: searchEvents, openEvent, getEvents, createEvent. These are called by the handler.
    const calendar = {
        searchEvents,
        openEvent,
        getEvents,
        createEvent
    };
    
    export default calendar;

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but provides minimal information. It mentions the Apple Calendar app context but doesn't describe what happens during operations (e.g., whether 'create' opens the app, saves automatically, requires confirmation), error conditions, rate limits, or permission requirements. For a multi-operation tool with 13 parameters, this is insufficient.

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

Conciseness5/5

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

The description is extremely concise at just 8 words, front-loading the core functionality without any wasted words. It efficiently communicates the three main operations and target application in a single, clear phrase.

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?

For a complex tool with 13 parameters, 4 distinct operations, and no annotations or output schema, the description is inadequate. It doesn't explain what the tool returns for different operations, how operations differ behaviorally, what happens in the Apple Calendar app, or any system dependencies. The agent would struggle to use this tool effectively based solely on the description.

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?

The description provides no parameter-specific information beyond what's already in the schema, which has 100% coverage. While the schema thoroughly documents all 13 parameters with descriptions and requirements, the description doesn't add any additional context about parameter interactions, default behaviors, or usage patterns across different operations.

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 the tool's purpose as 'Search, create, and open calendar events in Apple Calendar app', which specifies the actions (search, create, open) and resource (calendar events). It distinguishes from siblings like contacts or mail by focusing on calendar events, though it doesn't explicitly differentiate from other potential calendar tools.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'search' vs 'list' operations, when to use this tool over other calendar management options, or any prerequisites for operations like 'create' that might require specific permissions or app states.

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

Deploy Server

Other Tools

Related Tools