search_ticketmaster
Search for Ticketmaster events, venues, or attractions by keyword, date, location, or category to find specific event details and purchase options.
Instructions
Search for events, venues, or attractions on Ticketmaster
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Type of search to perform | |
| keyword | No | Search keyword or term | |
| startDate | No | Start date in YYYY-MM-DD format | |
| endDate | No | End date in YYYY-MM-DD format | |
| city | No | City name | |
| stateCode | No | State code (e.g., NY, CA) | |
| countryCode | No | Country code (e.g., US, CA) | |
| venueId | No | Specific venue ID to search | |
| attractionId | No | Specific attraction ID to search | |
| classificationName | No | Event classification/category (e.g., "Sports", "Music") | |
| format | No | Output format (defaults to json) | json |
Implementation Reference
- src/index.ts:111-192 (handler)The CallToolRequestSchema handler that executes the search_ticketmaster tool logic. It extracts parameters, calls the appropriate client method based on search type, and formats the response.
this.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name !== 'search_ticketmaster') { throw new McpError( ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}` ); } const { type, format = 'json', keyword, startDate, endDate, ...otherParams } = request.params.arguments as { type: SearchType; format?: 'json' | 'text'; keyword?: string; startDate?: string; endDate?: string; city?: string; stateCode?: string; countryCode?: string; venueId?: string; attractionId?: string; classificationName?: string; }; try { const query = { keyword, startDateTime: startDate ? new Date(startDate) : undefined, endDateTime: endDate ? new Date(endDate) : undefined, ...otherParams }; let results; switch (type) { case 'event': results = await this.client.searchEvents(query); break; case 'venue': results = await this.client.searchVenues(query); break; case 'attraction': results = await this.client.searchAttractions(query); break; default: throw new McpError( ErrorCode.InvalidParams, `Invalid search type: ${type}` ); } const content = format === 'json' ? JSON.stringify(results, null, 2) : formatResults(type, results, format !== 'text'); return { content: [ { type: 'text', text: content, }, ], }; } catch (error) { if (error instanceof Error) { return { content: [ { type: 'text', text: `Error: ${error.message}`, }, ], isError: true, }; } throw error; } }); - src/TicketmasterClient.ts:50-146 (handler)Core implementation methods: search(), searchEvents(), searchVenues(), and searchAttractions() that handle API calls to Ticketmaster Discovery API with query parameters.
async search<T extends TicketmasterEvent | TicketmasterVenue | TicketmasterAttraction>( type: SearchType, query: { keyword?: string; startDateTime?: Date; endDateTime?: Date; city?: string; stateCode?: string; countryCode?: string; venueId?: string; attractionId?: string; classificationName?: string; size?: number; } = {} ): Promise<T[]> { try { const endpoint = `${this.baseUrl}/${type}s`; const params: Record<string, string | number> = { apikey: this.apiKey, size: query.size || 20 }; if (query.keyword) { params.keyword = query.keyword; } if (query.startDateTime && query.endDateTime) { const dateRange = this.formatDateRange(query.startDateTime, query.endDateTime); params.startDateTime = dateRange.split(',')[0]; params.endDateTime = dateRange.split(',')[1]; } if (query.city) { params.city = query.city; } if (query.stateCode) { params.stateCode = query.stateCode; } if (query.countryCode) { params.countryCode = query.countryCode; } if (query.venueId) { params.venueId = query.venueId; } if (query.attractionId) { params.attractionId = query.attractionId; } if (query.classificationName) { params.classificationName = query.classificationName; } const response = await axios.get<TicketmasterResponse>(endpoint, { params }); const items = response.data._embedded?.[`${type}s` as keyof typeof response.data._embedded] as T[] || []; return items; } catch (error) { if (axios.isAxiosError(error)) { const axiosError = error as AxiosError<TicketmasterError>; const apiError = axiosError.response?.data?.fault; throw new TicketmasterApiError( apiError?.faultstring || 'Failed to fetch results', apiError?.detail?.errorcode, axiosError.response?.status ); } throw error; } } /** * Search for events */ async searchEvents(query: Parameters<typeof this.search>[1] = {}): Promise<TicketmasterEvent[]> { return this.search<TicketmasterEvent>('event', query); } /** * Search for venues */ async searchVenues(query: Parameters<typeof this.search>[1] = {}): Promise<TicketmasterVenue[]> { return this.search<TicketmasterVenue>('venue', query); } /** * Search for attractions */ async searchAttractions(query: Parameters<typeof this.search>[1] = {}): Promise<TicketmasterAttraction[]> { return this.search<TicketmasterAttraction>('attraction', query); } - src/index.ts:48-109 (registration)Tool registration in ListToolsRequestSchema handler defining the search_ticketmaster tool with its input schema including type, keyword, dates, location, and format options.
private setupToolHandlers() { this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'search_ticketmaster', description: 'Search for events, venues, or attractions on Ticketmaster', inputSchema: { type: 'object', properties: { type: { type: 'string', enum: ['event', 'venue', 'attraction'], description: 'Type of search to perform' }, keyword: { type: 'string', description: 'Search keyword or term' }, startDate: { type: 'string', description: 'Start date in YYYY-MM-DD format' }, endDate: { type: 'string', description: 'End date in YYYY-MM-DD format' }, city: { type: 'string', description: 'City name' }, stateCode: { type: 'string', description: 'State code (e.g., NY, CA)' }, countryCode: { type: 'string', description: 'Country code (e.g., US, CA)' }, venueId: { type: 'string', description: 'Specific venue ID to search' }, attractionId: { type: 'string', description: 'Specific attraction ID to search' }, classificationName: { type: 'string', description: 'Event classification/category (e.g., "Sports", "Music")' }, format: { type: 'string', enum: ['json', 'text'], description: 'Output format (defaults to json)', default: 'json' } }, required: ['type'], }, }, ], })); - src/types.ts:1-123 (schema)Type definitions for SearchType, TicketmasterEvent, TicketmasterVenue, TicketmasterAttraction, TicketmasterResponse, and TicketmasterApiError used throughout the tool.
export type SearchType = 'event' | 'venue' | 'attraction'; export interface TicketmasterEvent { id: string; name: string; type: string; url: string; locale: string; dates: { start: { localDate: string; localTime: string; dateTime: string; }; timezone?: string; status: { code: string; }; }; priceRanges?: Array<{ type: string; currency: string; min: number; max: number; }>; images: Array<{ ratio: string; url: string; width: number; height: number; }>; _embedded?: { venues?: TicketmasterVenue[]; attractions?: TicketmasterAttraction[]; }; } export interface TicketmasterVenue { id: string; name: string; type: string; url?: string; locale: string; postalCode?: string; timezone?: string; city: { name: string; }; state: { name: string; stateCode: string; }; country: { name: string; countryCode: string; }; address: { line1: string; }; location?: { longitude: string; latitude: string; }; } export interface TicketmasterAttraction { id: string; name: string; type: string; url?: string; locale: string; images?: Array<{ ratio: string; url: string; width: number; height: number; }>; classifications?: Array<{ primary: boolean; segment: { id: string; name: string; }; genre: { id: string; name: string; }; }>; } export interface TicketmasterResponse { _embedded?: { events?: TicketmasterEvent[]; venues?: TicketmasterVenue[]; attractions?: TicketmasterAttraction[]; }; page: { size: number; totalElements: number; totalPages: number; number: number; }; } export interface TicketmasterError { fault: { faultstring: string; detail: { errorcode: string; }; }; } export class TicketmasterApiError extends Error { constructor( message: string, public readonly code?: string, public readonly status?: number ) { super(message); this.name = 'TicketmasterApiError'; } } - src/formatters.ts:51-68 (helper)formatResults() helper function that formats search results as readable text when format parameter is set to 'text'.
export function formatResults( type: 'event' | 'venue' | 'attraction', results: Array<TicketmasterEvent | TicketmasterVenue | TicketmasterAttraction>, structured = true ): string { if (results.length === 0) { return 'No results found.'; } const formatters = { event: formatEvent, venue: formatVenue, attraction: formatAttraction, }; const formatter = formatters[type]; return results.map(item => formatter(item as any, structured)).join('\n\n'); }