calendar-update-event
Modify calendar event details including title, time, location, attendees, and description to keep schedules current and accurate.
Instructions
Update an existing calendar event
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| eventId | Yes | Event ID | |
| calendarId | No | Calendar ID - Available options: 'primary' (Primary Calendar) | primary |
| summary | No | Event title/summary | |
| description | No | Event description | |
| location | No | Event location | |
| startDateTime | No | Start date/time in ISO format | |
| endDateTime | No | End date/time in ISO format | |
| attendees | No | Array of attendee email addresses |
Implementation Reference
- src/calendar.ts:465-538 (handler)Implements the core logic for updating a Google Calendar event: fetches existing event, merges updates, calls Google Calendar API events.update, formats response with Markdown.// Update event function export async function updateEvent( params: z.infer<ReturnType<typeof updateEventSchema>> ) { try { const auth = createCalendarAuth(); const calendar = google.calendar({ version: "v3", auth }); // First get the existing event const existingEvent = await calendar.events.get({ calendarId: params.calendarId, eventId: params.eventId, }); const updatedEvent: any = { ...existingEvent.data }; // Update only the provided fields if (params.summary !== undefined) updatedEvent.summary = params.summary; if (params.description !== undefined) updatedEvent.description = params.description; if (params.location !== undefined) updatedEvent.location = params.location; if (params.startDateTime !== undefined) { updatedEvent.start = { ...updatedEvent.start, dateTime: params.startDateTime, }; } if (params.endDateTime !== undefined) { updatedEvent.end = { ...updatedEvent.end, dateTime: params.endDateTime }; } if (params.attendees !== undefined) { updatedEvent.attendees = params.attendees.map((email) => ({ email })); } const response = await calendar.events.update({ calendarId: params.calendarId, eventId: params.eventId, requestBody: updatedEvent, sendUpdates: "all", }); const updatedEventData = { id: response.data.id, summary: response.data.summary, start: response.data.start, end: response.data.end, location: response.data.location, description: response.data.description, attendees: response.data.attendees, htmlLink: response.data.htmlLink, updated: response.data.updated, }; return { content: [ { type: "text" as const, text: `# Event Updated Successfully ✅\n\n${formatEventToMarkdown(updatedEventData)}`, }, ], }; } catch (error) { return { content: [ { type: "text" as const, text: `Error updating event: ${ error instanceof Error ? error.message : String(error) }`, }, ], }; } }
- src/calendar.ts:205-224 (schema)Zod schema defining input parameters for the updateEvent tool, including eventId, optional updates for summary, description, etc.export const updateEventSchema = () => z.object({ eventId: z.string().describe("Event ID"), calendarId: z .string() .default("primary") .describe(getCalendarDescription()), summary: z.string().optional().describe("Event title/summary"), description: z.string().optional().describe("Event description"), location: z.string().optional().describe("Event location"), startDateTime: z .string() .optional() .describe("Start date/time in ISO format"), endDateTime: z.string().optional().describe("End date/time in ISO format"), attendees: z .array(z.string()) .optional() .describe("Array of attendee email addresses"), });
- src/index.ts:242-249 (registration)Registers the 'calendar-update-event' tool with MCP server, providing name, description, schema, and handler wrapper.server.tool( "calendar-update-event", "Update an existing calendar event", updateEventSchema().shape, async (params) => { return await updateEvent(params); } );
- src/calendar.ts:9-43 (helper)Helper function to format event details into Markdown, used in the handler's success response.function formatEventToMarkdown(event: any): string { let markdown = `# ${event.summary || 'Untitled Event'}\n\n`; if (event.description) markdown += `${event.description}\n\n`; const startDate = event.start?.dateTime ? new Date(event.start.dateTime) : null; const endDate = event.end?.dateTime ? new Date(event.end.dateTime) : null; if (startDate) { markdown += `Start: ${startDate.toLocaleString()} \n`; } if (endDate) { markdown += `End: ${endDate.toLocaleString()} \n`; } if (event.location) markdown += `Location: ${event.location} \n`; if (event.attendees && event.attendees.length > 0) { markdown += `Attendees: ${event.attendees.map((a: any) => { let attendee = a.email || a; if (a.responseStatus) { const status = a.responseStatus === 'accepted' ? '✅' : a.responseStatus === 'declined' ? '❌' : a.responseStatus === 'tentative' ? '❓' : '⏳'; attendee += ` ${status}`; } return attendee; }).join(', ')} \n`; } if (event.htmlLink) markdown += `Calendar Link: [View Event](${event.htmlLink}) \n`; if (event.id) markdown += `Event ID: \`${event.id}\` \n`; return markdown; }