Skip to main content
Glama
shadowfax92

MCP Apple Calendars

by shadowfax92

updateCalendarEvent

Modify existing Apple Calendar events by updating details like title, time, location, or notes through the MCP Apple Calendars server.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
calendarIdYes
eventIdYes
titleNo
startDateNo
endDateNo
locationNo
notesNo

Implementation Reference

  • src/index.ts:163-233 (registration)
    Registration of the MCP tool 'updateCalendarEvent' with input schema and handler function that calls the low-level calendars.updateCalendarEvent.
    server.tool(
      "updateCalendarEvent",
      { 
        calendarId: z.string(),
        eventId: z.string(),
        title: z.string().optional(),
        startDate: z.string().optional(),
        endDate: z.string().optional(),
        location: z.string().optional(),
        notes: z.string().optional()
      },
      async ({ calendarId, eventId, title, startDate, endDate, location, notes }) => {
        try {
          try {
            const updates = {
              title,
              startDate,
              endDate,
              location,
              notes
            };
            
            // Filter out undefined values
            Object.keys(updates).forEach(key => {
              if (updates[key as keyof typeof updates] === undefined) {
                delete updates[key as keyof typeof updates];
              }
            });
            
            const result = await calendars.updateCalendarEvent(calendarId, eventId, updates);
            
            return {
              content: [{ 
                type: "text", 
                text: JSON.stringify({ 
                  success: true, 
                  message: "Event updated", 
                  event: result 
                }) 
              }]
            };
          } catch (error: any) {
            // Check if it's a date format error
            if (error.message && error.message.includes('date')) {
              return {
                content: [{ 
                  type: "text", 
                  text: JSON.stringify({ 
                    error: "Failed to update event due to date format issues", 
                    message: "The Calendar API requires a specific date format that we couldn't determine. Please try using a different date format or contact the API provider for the correct format.",
                    details: error.message
                  }) 
                }],
                isError: true
              };
            }
            
            // If it's not a date format error, rethrow
            throw error;
          }
        } catch (error) {
          return {
            content: [{ 
              type: "text", 
              text: JSON.stringify({ error: "Failed to update event" }) 
            }],
            isError: true
          };
        }
      }
    );
  • Zod schema defining the input parameters for the updateCalendarEvent tool.
    { 
      calendarId: z.string(),
      eventId: z.string(),
      title: z.string().optional(),
      startDate: z.string().optional(),
      endDate: z.string().optional(),
      location: z.string().optional(),
      notes: z.string().optional()
    },
  • Low-level handler function that performs the actual API PUT request to update the calendar event, including date formatting using formatDate helper.
    export async function updateCalendarEvent(
      calendarId: string,
      eventId: string,
      updates: {
        title?: string;
        startDate?: string;
        endDate?: string;
        location?: string;
        notes?: string;
      }
    ): Promise<any> {
      try {
        const updatedData: any = { ...updates };
        
        // Format dates if provided
        if (updatedData.startDate) {
          const formattedStartDate = formatDate(updatedData.startDate);
          if (!formattedStartDate) {
            throw new Error('Invalid start date format provided. Please use one of the supported formats.');
          }
          updatedData.startDate = formattedStartDate;
        }
        
        if (updatedData.endDate) {
          const formattedEndDate = formatDate(updatedData.endDate);
          if (!formattedEndDate) {
            throw new Error('Invalid end date format provided. Please use one of the supported formats.');
          }
          updatedData.endDate = formattedEndDate;
        }
        
        console.error('Updating event with data:', JSON.stringify(updatedData));
        
        // Send the request
        const response = await axios.put(
          `${API_BASE_URL}/calendars/${calendarId}/events/${eventId}`,
          updatedData
        );
        
        return response.data;
      } catch (error) {
        console.error(`Failed to update event "${eventId}" in calendar "${calendarId}":`, error);
        throw new Error(`Failed to update calendar event: ${error}`);
      }
    }
  • Helper function formatDate used by updateCalendarEvent to validate and normalize date strings to ISO8601 format.
    function formatDate(date: Date | string | null): string | null {
      if (!date) return null;
    
      try {
        // If it's already a Date object, just return ISO string
        if (date instanceof Date) {
          if (isNaN(date.getTime())) return null;
          return date.toISOString();
        }
    
        // Handle string input
        const dateStr = date.trim();
    
        // Try parsing the date string as-is first
        let dateObj = new Date(dateStr);
        
        // If the direct parse failed, try alternative formats
        if (isNaN(dateObj.getTime())) {
          // Handle forward slash format
          if (dateStr.includes('/')) {
            dateObj = new Date(dateStr.replace(/\//g, '-'));
          }
          // Handle space instead of T
          else if (dateStr.includes(' ')) {
            dateObj = new Date(dateStr.replace(' ', 'T'));
          }
        }
    
        if (isNaN(dateObj.getTime())) {
          console.error('Invalid date format:', dateStr);
          return null;
        }
    
        return dateObj.toISOString();
      } catch (error) {
        console.error('Date formatting error:', error);
        return null;
      }
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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/shadowfax92/apple-calendar-mcp'

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