getParkDetails
Retrieve comprehensive details about U.S. National Parks using park codes to access information about facilities, alerts, and visitor resources.
Instructions
Get detailed information about a specific national park
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| parkCode | Yes | The park code of the national park (e.g., "yose" for Yosemite, "grca" for Grand Canyon) |
Implementation Reference
- src/handlers/getParkDetails.ts:6-31 (handler)The main handler function implementing the getParkDetails tool. Fetches park details from NPS API using parkCode, handles not found cases, formats the data, and returns as JSON text content.export async function getParkDetailsHandler(args: z.infer<typeof GetParkDetailsSchema>) { const response = await npsApiClient.getParkByCode(args.parkCode); // Check if park was found if (!response.data || response.data.length === 0) { return { content: [{ type: "text", text: JSON.stringify({ error: 'Park not found', message: `No park found with park code: ${args.parkCode}` }, null, 2) }] }; } // Format the response for better readability by the AI const parkDetails = formatParkDetails(response.data[0]); return { content: [{ type: "text", text: JSON.stringify(parkDetails, null, 2) }] }; }
- src/schemas.ts:13-15 (schema)Zod input schema for the getParkDetails tool, requiring a parkCode string.export const GetParkDetailsSchema = z.object({ parkCode: z.string().describe('The park code of the national park (e.g., "yose" for Yosemite, "grca" for Grand Canyon)') });
- src/server.ts:48-52 (registration)Tool registration in the ListTools handler, defining name, description, and input schema for getParkDetails.{ name: "getParkDetails", description: "Get detailed information about a specific national park", inputSchema: zodToJsonSchema(GetParkDetailsSchema), },
- src/server.ts:90-93 (registration)Tool dispatch in the CallTool handler, parsing arguments with schema and calling the getParkDetailsHandler.case "getParkDetails": { const args = GetParkDetailsSchema.parse(request.params.arguments); return await getParkDetailsHandler(args); }