list_events
Find and filter events by title, description, or location to discover available activities and gatherings.
Instructions
List all available events. Optionally filter by search term or location.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search | No | Search term to filter events by title or description | |
| location | No | Filter events by location |
Implementation Reference
- src/index.ts:62-83 (handler)The asynchronous handler function implementing the core logic of the 'list_events' MCP tool. It calls the API client to fetch events (optionally filtered), handles empty results and errors, formats the output using formatEvent, and returns MCP-formatted content.
async ({ search, location }) => { try { const apiClient = getClient(); const events = await apiClient.listEvents({ search, location }); if (events.length === 0) { return { content: [{ type: 'text', text: 'No events found matching your criteria.' }] }; } const formatted = events.map(formatEvent).join('\n\n---\n\n'); return { content: [{ type: 'text', text: `Found ${events.length} event(s):\n\n${formatted}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } - src/index.ts:58-61 (schema)Zod input schema for the list_events tool parameters: optional 'search' and 'location' strings.
{ search: z.string().optional().describe('Search term to filter events by title or description'), location: z.string().optional().describe('Filter events by location') }, - src/index.ts:55-84 (registration)Registration of the 'list_events' tool with the MCP server using server.tool(), including name, description, schema, and handler reference.
server.tool( 'list_events', 'List all available events. Optionally filter by search term or location.', { search: z.string().optional().describe('Search term to filter events by title or description'), location: z.string().optional().describe('Filter events by location') }, async ({ search, location }) => { try { const apiClient = getClient(); const events = await apiClient.listEvents({ search, location }); if (events.length === 0) { return { content: [{ type: 'text', text: 'No events found matching your criteria.' }] }; } const formatted = events.map(formatEvent).join('\n\n---\n\n'); return { content: [{ type: 'text', text: `Found ${events.length} event(s):\n\n${formatted}` }] }; } catch (error) { return { content: [{ type: 'text', text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/index.ts:29-38 (helper)Utility function to format an individual Event object into a multi-line human-readable string, used by the list_events handler and other tools.
function formatEvent(event: Event): string { return `Event: ${event.title} (ID: ${event.id}) Description: ${event.description} Location: ${event.location} Start: ${event.start_time} End: ${event.end_time} Capacity: ${event.capacity} Organizer: ${event.organizer.username} Registered: ${event.is_registered ? 'Yes' : 'No'}`; } - src/api-client.ts:63-66 (schema)TypeScript interface defining the EventListParams type used by the apiClient.listEvents method, matching the tool's input schema.
export interface EventListParams { search?: string; location?: string; }