get_event_registrations
Retrieve all attendee registrations for a specific event using the event ID. This tool is designed for event organizers to view registration details.
Instructions
Get all registrations for an event. Only available to the event organizer.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_id | Yes | The ID of the event |
Implementation Reference
- src/index.ts:249-277 (registration)Registers the 'get_event_registrations' tool with MCP server, including input schema and handler function.server.tool( 'get_event_registrations', 'Get all registrations for an event. Only available to the event organizer.', { event_id: z.number().describe('The ID of the event') }, async ({ event_id }) => { try { const apiClient = getClient(); const registrations = await apiClient.getEventRegistrations(event_id); if (registrations.length === 0) { return { content: [{ type: 'text', text: 'No registrations found for this event.' }] }; } const formatted = registrations.map(formatRegistration).join('\n\n---\n\n'); return { content: [{ type: 'text', text: `Found ${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/index.ts:255-276 (handler)Handler function that fetches event registrations using apiClient, formats them with formatRegistration, and returns formatted text content or error.async ({ event_id }) => { try { const apiClient = getClient(); const registrations = await apiClient.getEventRegistrations(event_id); if (registrations.length === 0) { return { content: [{ type: 'text', text: 'No registrations found for this event.' }] }; } const formatted = registrations.map(formatRegistration).join('\n\n---\n\n'); return { content: [{ type: 'text', text: `Found ${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/index.ts:252-254 (schema)Input schema for the tool using Zod: requires event_id as number.{ event_id: z.number().describe('The ID of the event') },
- src/api-client.ts:173-180 (helper)API client method that performs HTTP GET to fetch registrations for a specific event from the backend API.async getEventRegistrations(eventId: number): Promise<Registration[]> { try { const response: AxiosResponse<Registration[]> = await this.client.get(`/api/events/${eventId}/registrations/`); return response.data; } catch (error) { throw new Error(`Failed to get registrations for event ${eventId}: ${getErrorMessage(error)}`); } }
- src/index.ts:41-49 (helper)Utility function to format a Registration object into a human-readable string for display in tool responses.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}`; }