Skip to main content
Glama
KyrieTangSheng

National Parks MCP Server

getCampgrounds

Find campgrounds in U.S. National Parks with amenities, search by park code or name, and filter results for trip planning.

Instructions

Get information about available campgrounds and their amenities

Input Schema

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

Implementation Reference

  • The primary handler function for the 'getCampgrounds' tool. It validates input, calls the NPS API client to fetch campgrounds data, formats the response, groups by park, and returns a JSON-formatted text content response.
    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 for the getCampgrounds tool, including optional filters for parkCode, limit, start, and search query.
    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:63-67 (registration)
    Tool registration in the ListTools response, defining the 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)
    Dispatch handler in the CallToolRequest switch statement that parses arguments with the schema and calls the getCampgroundsHandler.
    case "getCampgrounds": { const args = GetCampgroundsSchema.parse(request.params.arguments); return await getCampgroundsHandler(args); }
  • Helper method in NPS API client that makes the HTTP request to the NPS campgrounds endpoint and returns the raw API response.
    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; } }

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