register_for_event
Register users for events by providing an event ID and optional form answers. This tool handles attendee sign-ups through the EventHorizon platform.
Instructions
Register the current user for an event.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_id | Yes | The ID of the event to register for | |
| answers | No | Answers to registration form questions (if any) |
Implementation Reference
- src/index.ts:211-224 (handler)MCP tool handler function for 'register_for_event'. It retrieves the API client, calls registerForEvent on it with event_id and answers, formats the registration response, or returns an error.async ({ event_id, answers }) => { try { const apiClient = getClient(); const registration = await apiClient.registerForEvent(event_id, answers || {}); return { content: [{ type: 'text', text: `Successfully registered!\n\n${formatRegistration(registration)}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/index.ts:207-210 (schema)Zod input schema for the 'register_for_event' tool, defining event_id (required number) and optional answers (record).{ event_id: z.number().describe('The ID of the event to register for'), answers: z.record(z.unknown()).optional().describe('Answers to registration form questions (if any)') },
- src/index.ts:204-225 (registration)Registration of the 'register_for_event' tool with the MCP server using server.tool(), including description, input schema, and handler function.server.tool( 'register_for_event', 'Register the current user for an event.', { event_id: z.number().describe('The ID of the event to register for'), answers: z.record(z.unknown()).optional().describe('Answers to registration form questions (if any)') }, async ({ event_id, answers }) => { try { const apiClient = getClient(); const registration = await apiClient.registerForEvent(event_id, answers || {}); return { content: [{ type: 'text', text: `Successfully registered!\n\n${formatRegistration(registration)}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/api-client.ts:156-163 (helper)Helper method in EventHorizonClient that performs the actual API call to register for an event via POST to /api/events/{eventId}/register/.async registerForEvent(eventId: number, answers: Record<string, unknown> = {}): Promise<Registration> { try { const response: AxiosResponse<Registration> = await this.client.post(`/api/events/${eventId}/register/`, { answers }); return response.data; } catch (error) { throw new Error(`Failed to register for event ${eventId}: ${getErrorMessage(error)}`); } }
- src/api-client.ts:43-51 (schema)TypeScript interface defining the Registration object returned by the API, used in the tool's response formatting.export interface Registration { id: number; event: Event | number; user: User | number; status: 'pending' | 'approved' | 'waitlisted' | 'cancelled'; answers: Record<string, unknown>; registered_at: string; updated_at: string; }