Skip to main content
Glama
KyrieTangSheng

National Parks MCP Server

getEvents

Discover upcoming events at U.S. National Parks by filtering by park code, date range, or search term. Use this tool to easily plan visits and explore park activities.

Instructions

Find upcoming events at parks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateEndNoEnd date for filtering events (format: YYYY-MM-DD)
dateStartNoStart date for filtering events (format: YYYY-MM-DD)
limitNoMaximum number of events to return (default: 10, max: 50)
parkCodeNoFilter events by park code (e.g., "yose" for Yosemite). Multiple parks can be comma-separated (e.g., "yose,grca").
qNoSearch term to filter events by title or description
startNoStart position for results (useful for pagination)

Implementation Reference

  • The getEventsHandler function that executes the tool logic: processes input args, enforces limit, calls NPS API client to fetch events, formats and groups data by park, returns formatted JSON response.
    export async function getEventsHandler(args: z.infer<typeof GetEventsSchema>) { // Set default limit if not provided or if it exceeds maximum const limit = args.limit ? Math.min(args.limit, 50) : 10; // Format the request parameters const requestParams = { limit, ...args }; const response = await npsApiClient.getEvents(requestParams); // Format the response for better readability by the AI const formattedEvents = formatEventData(response.data); // Group events by park code for better organization const eventsByPark: { [key: string]: any[] } = {}; formattedEvents.forEach(event => { if (!eventsByPark[event.parkCode]) { eventsByPark[event.parkCode] = []; } eventsByPark[event.parkCode].push(event); }); const result = { total: parseInt(response.total), limit: parseInt(response.limit), start: parseInt(response.start), events: formattedEvents, eventsByPark: eventsByPark }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
  • Zod input schema for getEvents tool defining optional parameters: parkCode, limit, start, dateStart, dateEnd, q.
    export const GetEventsSchema = z.object({ parkCode: z.string().optional().describe('Filter events by park code (e.g., "yose" for Yosemite). Multiple parks can be comma-separated (e.g., "yose,grca").'), limit: z.number().optional().describe('Maximum number of events to return (default: 10, max: 50)'), start: z.number().optional().describe('Start position for results (useful for pagination)'), dateStart: z.string().optional().describe('Start date for filtering events (format: YYYY-MM-DD)'), dateEnd: z.string().optional().describe('End date for filtering events (format: YYYY-MM-DD)'), q: z.string().optional().describe('Search term to filter events by title or description') });
  • src/server.ts:69-72 (registration)
    Tool registration in ListTools handler: defines name, description, and inputSchema for getEvents.
    name: "getEvents", description: "Find upcoming events at parks", inputSchema: zodToJsonSchema(GetEventsSchema), },
  • src/server.ts:110-113 (registration)
    Tool dispatch in CallTool handler: parses arguments with schema and calls getEventsHandler.
    case "getEvents": { const args = GetEventsSchema.parse(request.params.arguments); return await getEventsHandler(args); }
  • NPSApiClient.getEvents method: fetches events from NPS /events API endpoint using axios.
    async getEvents(params: EventQueryParams = {}): Promise<NPSResponse<EventData>> { try { const response = await this.api.get('/events', { params }); return response.data; } catch (error) { console.error('Error fetching events data:', error); throw error; } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/KyrieTangSheng/mcp-server-nationalparks'

If you have feedback or need assistance with the MCP directory API, please join our Discord server