Skip to main content
Glama
KyrieTangSheng

National Parks MCP Server

getVisitorCenters

Find visitor center details and operating hours for U.S. National Parks using park codes or search terms.

Instructions

Get information about visitor centers and their operating hours

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
parkCodeNoFilter visitor centers by park code (e.g., "yose" for Yosemite). Multiple parks can be comma-separated (e.g., "yose,grca").
limitNoMaximum number of visitor centers to return (default: 10, max: 50)
startNoStart position for results (useful for pagination)
qNoSearch term to filter visitor centers by name or description

Implementation Reference

  • The main handler function that executes the getVisitorCenters tool logic. It processes input arguments, calls the NPS API client to fetch visitor centers data, formats the response, groups by park, and returns a structured JSON response.
    export async function getVisitorCentersHandler(args: z.infer<typeof GetVisitorCentersSchema>) { // 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.getVisitorCenters(requestParams); // Format the response for better readability by the AI const formattedCenters = formatVisitorCenterData(response.data); // Group visitor centers by park code for better organization const centersByPark: { [key: string]: any[] } = {}; formattedCenters.forEach(center => { if (!centersByPark[center.parkCode]) { centersByPark[center.parkCode] = []; } centersByPark[center.parkCode].push(center); }); const result = { total: parseInt(response.total), limit: parseInt(response.limit), start: parseInt(response.start), visitorCenters: formattedCenters, visitorCentersByPark: centersByPark }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
  • Zod schema defining the input parameters for the getVisitorCenters tool, including optional filters for park code, limit, start, and search query.
    export const GetVisitorCentersSchema = z.object({ parkCode: z.string().optional().describe('Filter visitor centers 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 visitor centers to return (default: 10, max: 50)'), start: z.number().optional().describe('Start position for results (useful for pagination)'), q: z.string().optional().describe('Search term to filter visitor centers by name or description') });
  • src/server.ts:58-62 (registration)
    Tool registration in the ListToolsRequestHandler, defining the tool's name, description, and input schema for discovery.
    { name: "getVisitorCenters", description: "Get information about visitor centers and their operating hours", inputSchema: zodToJsonSchema(GetVisitorCentersSchema), },
  • src/server.ts:100-103 (registration)
    Dispatch logic in the CallToolRequestHandler switch statement that parses arguments and calls the getVisitorCentersHandler.
    case "getVisitorCenters": { const args = GetVisitorCentersSchema.parse(request.params.arguments); return await getVisitorCentersHandler(args); }
  • NPS API client method that makes the HTTP request to the /visitorcenters endpoint to fetch raw visitor centers data.
    async getVisitorCenters(params: VisitorCenterQueryParams = {}): Promise<NPSResponse<VisitorCenterData>> { try { const response = await this.api.get('/visitorcenters', { params }); return response.data; } catch (error) { console.error('Error fetching visitor centers data:', error); throw error; } }

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