getParkDetails
Retrieve comprehensive details about a specific U.S. national park by providing its unique park code. Access information on alerts, visitor centers, campgrounds, and upcoming events for informed planning.
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 primary handler function that executes the getParkDetails tool: fetches park data from NPS API by parkCode, handles not found case, formats details, and returns as JSON-formatted 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, defining the required parkCode parameter with description.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 metadata exposed via ListTools: name, description, and input schema.{ name: "getParkDetails", description: "Get detailed information about a specific national park", inputSchema: zodToJsonSchema(GetParkDetailsSchema), },
- src/server.ts:90-93 (registration)Dispatch logic in CallTool handler: parses arguments with schema and invokes the getParkDetailsHandler.case "getParkDetails": { const args = GetParkDetailsSchema.parse(request.params.arguments); return await getParkDetailsHandler(args); }