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:255-276 (handler)The core handler function for the 'get_event_registrations' tool. It retrieves the API client, fetches registrations for the given event ID, handles empty results and errors, formats the registrations using formatRegistration, and returns a formatted text response.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 definition using Zod, specifying 'event_id' as a required number with description.{ event_id: z.number().describe('The ID of the event') },
- src/index.ts:249-277 (registration)The server.tool() call that registers the 'get_event_registrations' tool with the MCP server, including name, description, 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/api-client.ts:173-180 (helper)API client helper method that performs the actual HTTP GET request to retrieve 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 single Registration object into a human-readable string, used in the tool handler to display results.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}`; }