Skip to main content
Glama

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; } }

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