Skip to main content
Glama
KyrieTangSheng

National Parks MCP Server

getAlerts

Retrieve current national park alerts for closures, hazards, and important safety information to plan visits safely.

Instructions

Get current alerts for national parks including closures, hazards, and important information

Input Schema

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

Implementation Reference

  • The main getAlerts tool handler: sets limit, calls NPS API for alerts, formats data, groups by park, returns structured JSON response.
    export async function getAlertsHandler(args: z.infer<typeof GetAlertsSchema>) { // 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.getAlerts(requestParams); // Format the response for better readability by the AI const formattedAlerts = formatAlertData(response.data); // Group alerts by park code for better organization const alertsByPark: { [key: string]: any[] } = {}; formattedAlerts.forEach(alert => { if (!alertsByPark[alert.parkCode]) { alertsByPark[alert.parkCode] = []; } alertsByPark[alert.parkCode].push(alert); }); const result = { total: parseInt(response.total), limit: parseInt(response.limit), start: parseInt(response.start), alerts: formattedAlerts, alertsByPark }; return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; }
  • Zod input schema for getAlerts tool defining optional parameters: parkCode, limit, start, q.
    export const GetAlertsSchema = z.object({ parkCode: z.string().optional().describe('Filter alerts 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 alerts 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 alerts by title or description') });
  • src/server.ts:53-57 (registration)
    Tool registration in ListTools handler: defines name, description, and converts Zod schema to JSON schema for tool metadata.
    { name: "getAlerts", description: "Get current alerts for national parks including closures, hazards, and important information", inputSchema: zodToJsonSchema(GetAlertsSchema), },
  • src/server.ts:95-98 (registration)
    Tool dispatch in CallToolRequest handler: parses arguments using schema and invokes getAlertsHandler.
    case "getAlerts": { const args = GetAlertsSchema.parse(request.params.arguments); return await getAlertsHandler(args); }

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