updateCalendarEvent
Modify existing events in Apple Calendars by updating details such as title, start and end dates, location, and notes using the MCP Apple Calendars server.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| calendarId | Yes | ||
| endDate | No | ||
| eventId | Yes | ||
| location | No | ||
| notes | No | ||
| startDate | No | ||
| title | No |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"calendarId": {
"type": "string"
},
"endDate": {
"type": "string"
},
"eventId": {
"type": "string"
},
"location": {
"type": "string"
},
"notes": {
"type": "string"
},
"startDate": {
"type": "string"
},
"title": {
"type": "string"
}
},
"required": [
"calendarId",
"eventId"
],
"type": "object"
}
Implementation Reference
- src/index.ts:174-232 (handler)MCP server tool handler that processes input parameters, prepares updates object, calls the calendars.updateCalendarEvent helper, handles date format errors specifically, and returns structured response or error.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 }; } }
- src/index.ts:165-173 (schema)Zod schema defining the input parameters for the updateCalendarEvent tool, with required calendarId and eventId, and optional fields for updating.{ 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() },
- src/index.ts:163-233 (registration)Registration of the 'updateCalendarEvent' tool with the MCP server using server.tool, including name, input schema, and handler function.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 }; } } );
- src/calendars.ts:172-216 (helper)Helper function that performs the actual API call to update the calendar event via axios PUT to the bridge API, including date formatting using formatDate utility.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}`); } }