get_my_hosted_events
Retrieve 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 (registration)MCP tool registration for 'get_my_hosted_events', including empty input schema and the handler function that fetches user's hosted events via API client, formats them using formatEvent, and returns formatted text response 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/index.ts:368-389 (handler)The core handler function executing the tool logic: initializes API client, calls getUserHostedEvents, formats events with formatEvent, and constructs MCP response.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 helper method that performs the HTTP GET 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 a single Event object into a human-readable string, used in the tool response.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 Event type used for API responses in getUserHostedEvents and formatting.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; }