Skip to main content
Glama
KyrieTangSheng

National Parks MCP Server

getCampgrounds

Search and filter campgrounds in U.S. National Parks by park code, name, or description. Retrieve details on amenities and availability, with pagination for easy navigation.

Instructions

Get information about available campgrounds and their amenities

Input Schema

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

Implementation Reference

  • The main handler function that implements the core logic for the getCampgrounds tool, including parameter processing, API call to NPS, response formatting, grouping by park, and returning structured JSON content.
    export async function getCampgroundsHandler(args: z.infer<typeof GetCampgroundsSchema>) { // 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.getCampgrounds(requestParams); // Format the response for better readability by the AI const formattedCampgrounds = formatCampgroundData(response.data); // Group campgrounds by park code for better organization const campgroundsByPark: { [key: string]: any[] } = {}; formattedCampgrounds.forEach(campground => { if (!campgroundsByPark[campground.parkCode]) { campgroundsByPark[campground.parkCode] = []; } campgroundsByPark[campground.parkCode].push(campground); }); const result = { total: parseInt(response.total), limit: parseInt(response.limit), start: parseInt(response.start), campgrounds: formattedCampgrounds, campgroundsByPark: campgroundsByPark }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
  • Zod schema defining the input parameters and validation for the getCampgrounds tool.
    export const GetCampgroundsSchema = z.object({ parkCode: z.string().optional().describe('Filter campgrounds 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 campgrounds 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 campgrounds by name or description') });
  • src/server.ts:64-67 (registration)
    Tool registration in the ListTools handler, defining the tool name, description, and input schema for getCampgrounds.
    name: "getCampgrounds", description: "Get information about available campgrounds and their amenities", inputSchema: zodToJsonSchema(GetCampgroundsSchema), },
  • src/server.ts:105-108 (registration)
    Tool execution registration in the CallToolRequestSchema switch statement, parsing arguments and calling the getCampgroundsHandler.
    case "getCampgrounds": { const args = GetCampgroundsSchema.parse(request.params.arguments); return await getCampgroundsHandler(args); }
  • Helper method in NPS API client that fetches campgrounds data from the NPS API endpoint, used by the handler.
    async getCampgrounds(params: CampgroundQueryParams = {}): Promise<NPSResponse<CampgroundData>> { try { const response = await this.api.get('/campgrounds', { params }); return response.data; } catch (error) { console.error('Error fetching campgrounds 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