update_event
Modify event details such as title, time, location, or capacity by providing only the fields you need to change.
Instructions
Update an existing event. Only provide the fields you want to change.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_id | Yes | The ID of the event to update | |
| title | No | New title for the event | |
| description | No | New description for the event | |
| start_time | No | New start time in ISO 8601 format | |
| end_time | No | New end time in ISO 8601 format | |
| location | No | New location for the event | |
| capacity | No | New capacity for the event |
Implementation Reference
- src/index.ts:142-176 (registration)Full registration of the 'update_event' MCP tool, including name, description, input schema, and handler function.server.tool( 'update_event', 'Update an existing event. Only provide the fields you want to change.', { event_id: z.number().describe('The ID of the event to update'), title: z.string().optional().describe('New title for the event'), description: z.string().optional().describe('New description for the event'), start_time: z.string().optional().describe('New start time in ISO 8601 format'), end_time: z.string().optional().describe('New end time in ISO 8601 format'), location: z.string().optional().describe('New location for the event'), capacity: z.number().optional().describe('New capacity for the event') }, async ({ event_id, title, description, start_time, end_time, location, capacity }) => { try { const apiClient = getClient(); const updateData: Record<string, unknown> = {}; if (title !== undefined) updateData.title = title; if (description !== undefined) updateData.description = description; if (start_time !== undefined) updateData.start_time = start_time; if (end_time !== undefined) updateData.end_time = end_time; if (location !== undefined) updateData.location = location; if (capacity !== undefined) updateData.capacity = capacity; const event = await apiClient.updateEvent(event_id, updateData); return { content: [{ type: 'text', text: `Event updated successfully!\n\n${formatEvent(event)}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/index.ts:154-175 (handler)The handler function for the 'update_event' tool. It constructs a partial update object from provided parameters and calls the apiClient.updateEvent method, returning formatted success or error response.async ({ event_id, title, description, start_time, end_time, location, capacity }) => { try { const apiClient = getClient(); const updateData: Record<string, unknown> = {}; if (title !== undefined) updateData.title = title; if (description !== undefined) updateData.description = description; if (start_time !== undefined) updateData.start_time = start_time; if (end_time !== undefined) updateData.end_time = end_time; if (location !== undefined) updateData.location = location; if (capacity !== undefined) updateData.capacity = capacity; const event = await apiClient.updateEvent(event_id, updateData); return { content: [{ type: 'text', text: `Event updated successfully!\n\n${formatEvent(event)}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/index.ts:145-153 (schema)Zod input schema defining parameters for the 'update_event' tool.{ event_id: z.number().describe('The ID of the event to update'), title: z.string().optional().describe('New title for the event'), description: z.string().optional().describe('New description for the event'), start_time: z.string().optional().describe('New start time in ISO 8601 format'), end_time: z.string().optional().describe('New end time in ISO 8601 format'), location: z.string().optional().describe('New location for the event'), capacity: z.number().optional().describe('New capacity for the event') },
- src/api-client.ts:139-146 (helper)API client helper method 'updateEvent' that performs the HTTP PUT request to update an event via the EventHorizon API.async updateEvent(eventId: number, eventData: Partial<EventCreateRequest>): Promise<Event> { try { const response: AxiosResponse<Event> = await this.client.put(`/api/events/${eventId}/`, eventData); return response.data; } catch (error) { throw new Error(`Failed to update event ${eventId}: ${getErrorMessage(error)}`); } }