get_my_hosted_events
Retrieve all events you have organized on the EventHorizon platform to manage and review your hosted activities.
Instructions
Get all events organized by the current user.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:364-390 (handler)MCP server tool registration and handler implementation for 'get_my_hosted_events'. Fetches user's hosted events using the API client, formats them with formatEvent, and returns formatted text content or error.server.tool( 'get_my_hosted_events', 'Get all events organized by the current user.', {}, async () => { try { const apiClient = getClient(); const events = await apiClient.getUserHostedEvents(); if (events.length === 0) { return { content: [{ type: 'text', text: 'You are not organizing any events.' }] }; } const formatted = events.map(formatEvent).join('\n\n---\n\n'); return { content: [{ type: 'text', text: `You are organizing ${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/api-client.ts:210-217 (helper)API client method that performs the HTTP GET request to '/api/events/' with organizer='me' parameter to retrieve events hosted by the current user.async getUserHostedEvents(): Promise<Event[]> { try { const response: AxiosResponse<Event[]> = await this.client.get('/api/events/', { params: { organizer: 'me' } }); return response.data; } catch (error) { throw new Error(`Failed to get user hosted events: ${getErrorMessage(error)}`); } }
- src/index.ts:29-38 (helper)Helper function to format an individual Event object into a readable string for tool output.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:27-41 (schema)TypeScript interface defining the structure of an Event object used throughout the codebase.export interface Event { id: number; title: string; slug: string; description: string; start_time: string; end_time: string; location: string; capacity: number; organizer: User; registration_schema: Record<string, unknown>[]; is_registered: boolean; created_at: string; updated_at: string; }
- src/index.ts:17-26 (helper)Lazy-initializes and returns the shared EventHorizonClient instance used by all tools.function getClient(): EventHorizonClient { if (!client) { const errors = validateConfig(); if (errors.length > 0) { throw new Error(`Configuration errors: ${errors.join('; ')}`); } client = new EventHorizonClient(); } return client; }