create_event
Create new events by specifying title, description, times, location, and capacity for event management on the EventHorizon platform.
Instructions
Create a new event. Requires title, description, start/end times, location, and capacity.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Title of the event | |
| description | Yes | Description of the event | |
| start_time | Yes | Start time in ISO 8601 format (e.g., 2024-12-25T10:00:00Z) | |
| end_time | Yes | End time in ISO 8601 format (e.g., 2024-12-25T18:00:00Z) | |
| location | Yes | Location of the event | |
| capacity | Yes | Maximum number of attendees |
Implementation Reference
- src/index.ts:108-140 (registration)Registers the 'create_event' tool with the MCP server, including Zod input schema, description, and the handler function that delegates to the API client.server.tool( 'create_event', 'Create a new event. Requires title, description, start/end times, location, and capacity.', { title: z.string().describe('Title of the event'), description: z.string().describe('Description of the event'), start_time: z.string().describe('Start time in ISO 8601 format (e.g., 2024-12-25T10:00:00Z)'), end_time: z.string().describe('End time in ISO 8601 format (e.g., 2024-12-25T18:00:00Z)'), location: z.string().describe('Location of the event'), capacity: z.number().describe('Maximum number of attendees') }, async ({ title, description, start_time, end_time, location, capacity }) => { try { const apiClient = getClient(); const event = await apiClient.createEvent({ title, description, start_time, end_time, location, capacity }); return { content: [{ type: 'text', text: `Event created successfully!\n\n${formatEvent(event)}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/api-client.ts:130-137 (handler)The underlying API client handler that performs the HTTP POST request to create the event on the EventHorizon backend.async createEvent(eventData: EventCreateRequest): Promise<Event> { try { const response: AxiosResponse<Event> = await this.client.post('/api/events/', eventData); return response.data; } catch (error) { throw new Error(`Failed to create event: ${getErrorMessage(error)}`); } }
- src/api-client.ts:53-61 (schema)TypeScript interface defining the structure of data required to create an event, used by the API client.export interface EventCreateRequest { title: string; description: string; start_time: string; end_time: string; location: string; capacity: number; registration_schema?: Record<string, unknown>[]; }
- src/index.ts:29-38 (helper)Helper function used by the create_event handler to format the created event for display in the response.function formatEvent(event: Event): string { return `Event: ${event.title} (ID: ${event.id}) Description: ${event.description} Location: ${event.location} Start: ${event.start_time} End: ${event.end_time} Capacity: ${event.capacity} Organizer: ${event.organizer.username} Registered: ${event.is_registered ? 'Yes' : 'No'}`; }
- src/index.ts:17-26 (helper)Lazy-initializes and returns the EventHorizonClient instance, used by all tool handlers including create_event.function getClient(): EventHorizonClient { if (!client) { const errors = validateConfig(); if (errors.length > 0) { throw new Error(`Configuration errors: ${errors.join('; ')}`); } client = new EventHorizonClient(); } return client; }