get_my_registrations
Retrieve all events you have registered for through the EventHorizon platform. View your current event registrations and manage your attendance.
Instructions
Get all events the current user is registered for.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:336-362 (handler)Full MCP tool definition including registration, empty input schema, and handler logic. The handler retrieves the user's registrations via the API client, formats them using formatRegistration, handles empty list and errors, and returns formatted text content.server.tool( 'get_my_registrations', 'Get all events the current user is registered for.', {}, async () => { try { const apiClient = getClient(); const registrations = await apiClient.getUserRegistrations(); if (registrations.length === 0) { return { content: [{ type: 'text', text: 'You are not registered for any events.' }] }; } const formatted = registrations.map(formatRegistration).join('\n\n---\n\n'); return { content: [{ type: 'text', text: `You have ${registrations.length} registration(s):\n\n${formatted}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } );
- src/api-client.ts:201-208 (helper)EventHorizonClient helper method that implements the core API call (GET /api/registrations/) to fetch the current user's registrations, with error handling.async getUserRegistrations(): Promise<Registration[]> { try { const response: AxiosResponse<Registration[]> = await this.client.get('/api/registrations/'); return response.data; } catch (error) { throw new Error(`Failed to get user registrations: ${getErrorMessage(error)}`); } }
- src/api-client.ts:43-51 (schema)TypeScript interface defining the structure of Registration objects used by the tool's API response and formatting logic.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; }
- src/index.ts:41-49 (helper)Helper function to format individual Registration objects into a human-readable string for inclusion in the tool's response.function formatRegistration(reg: Registration): string { const eventInfo = typeof reg.event === 'object' ? reg.event.title : `Event ID: ${reg.event}`; const userInfo = typeof reg.user === 'object' ? reg.user.username : `User ID: ${reg.user}`; return `Registration (ID: ${reg.id}) Event: ${eventInfo} User: ${userInfo} Status: ${reg.status} Registered at: ${reg.registered_at}`; }