register_for_event
Register users for events in the EventHorizon platform by providing event ID and optional form answers.
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 for 'register_for_event': calls apiClient to register and formats response.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:204-225 (registration)Registration of the 'register_for_event' tool with MCP server, including name, description, schema, and handler.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/index.ts:207-210 (schema)Zod input schema for the tool parameters: event_id (required number) and answers (optional 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/api-client.ts:156-163 (helper)Core API client method implementing the registration via HTTP POST to the backend API.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 response structure.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; }