Skip to main content
Glama

get_weather_alerts

Retrieve active weather alerts, road condition warnings, and incidents across British Columbia to monitor winter conditions, avalanche risks, fog advisories, and weather-related hazards for travel planning.

Instructions

Get active weather alerts, incidents, and road condition warnings across BC. Includes winter conditions, avalanche warnings, fog advisories, and weather-related incidents.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionNoFilter by BC region (optional)
alertTypeNoType of alert to retrieve (default: all weather-related)
severityMinimumNoMinimum severity level (default: MINOR)

Implementation Reference

  • The handler function that fetches active events, filters by region, type, severity, identifies weather-related events, sorts by severity, and formats the output.
    export async function handleWeatherAlerts(args: { region?: string; alertType?: EventType; severityMinimum?: 'MINOR' | 'MODERATE' | 'MAJOR'; }): Promise<string> { try { const params: EventQueryParams = { status: 'ACTIVE', }; if (args.region) { const regionId = findRegionId(args.region); if (!regionId) { return `Invalid region "${args.region}". Please use a valid BC region name.`; } params.area_id = regionId; } if (args.alertType) { params.event_type = args.alertType; } const events = await getEvents(params); let filteredEvents = events; if (!args.alertType) { filteredEvents = events.filter(isWeatherRelated); } const severityOrder = { MAJOR: 0, MODERATE: 1, MINOR: 2, UNKNOWN: 3 }; const minimumSeverity = args.severityMinimum ?? 'MINOR'; const minLevel = severityOrder[minimumSeverity]; filteredEvents = filteredEvents.filter( event => severityOrder[event.severity] <= minLevel ); const sortedEvents = filteredEvents.sort( (a, b) => severityOrder[a.severity] - severityOrder[b.severity] ); if (sortedEvents.length === 0) { const filters = []; if (args.region) filters.push(`region: ${args.region}`); if (args.alertType) filters.push(`type: ${args.alertType}`); const filterStr = filters.length > 0 ? ` (${filters.join(', ')})` : ''; return `No weather alerts found${filterStr}.`; } const lines: string[] = []; lines.push(`Found ${sortedEvents.length} weather alert(s):\n`); sortedEvents.forEach((event, index) => { lines.push(`${index + 1}. ${formatWeatherAlert(event)}`); lines.push(''); }); return lines.join('\n'); } catch (error) { if (error instanceof Error) { return `Error fetching weather alerts: ${error.message}`; } return 'Error fetching weather alerts: Unknown error'; } }
  • Tool definition including name, description, and input schema for validation.
    export const weatherAlertsTool = { name: 'get_weather_alerts', description: 'Get active weather alerts, incidents, and road condition warnings across BC. Includes winter conditions, avalanche warnings, fog advisories, and weather-related incidents.', inputSchema: { type: 'object' as const, properties: { region: { type: 'string', description: 'Filter by BC region (optional)', }, alertType: { type: 'string', enum: ['WEATHER_CONDITION', 'ROAD_CONDITION', 'INCIDENT'], description: 'Type of alert to retrieve (default: all weather-related)', }, severityMinimum: { type: 'string', enum: ['MINOR', 'MODERATE', 'MAJOR'], description: 'Minimum severity level (default: MINOR)', }, }, required: [], }, };
  • src/index.ts:69-71 (registration)
    Registration in the tool call handler switch statement, dispatching to the handler function.
    case 'get_weather_alerts': result = await handleWeatherAlerts(args as any); break;
  • src/index.ts:41-46 (registration)
    Registration in the list tools handler, including the tool in the available tools list.
    tools: [ highwayConditionsTool, regionalConditionsTool, roadClosuresTool, weatherAlertsTool, ],
  • Helper function to determine if an event is weather-related by type or keywords.
    function isWeatherRelated(event: Event): boolean { const weatherKeywords = [ 'weather', 'snow', 'ice', 'avalanche', 'fog', 'rain', 'wind', 'storm', 'winter', 'slippery', 'visibility', ]; const weatherTypes: EventType[] = ['WEATHER_CONDITION', 'ROAD_CONDITION']; if (weatherTypes.includes(event.event_type)) { return true; } const textToCheck = `${event.headline} ${event.description || ''}`.toLowerCase(); return weatherKeywords.some(keyword => textToCheck.includes(keyword)); }

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/infil00p/DriveBC_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server