get_regional_conditions
Retrieve real-time road conditions, closures, weather alerts, and traffic incidents for British Columbia regions to plan safe travel routes.
Instructions
Get road conditions and events for a specific BC region. Useful for planning trips within a geographic area.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| region | Yes | BC region name. Options: Lower Mainland, Vancouver Island, Thompson Okanagan, Kootenay Rockies, Cariboo, Northern BC | |
| eventType | No | Filter by event type (optional) | |
| limit | No | Maximum number of events to return (default: 50, max: 500) |
Implementation Reference
- src/tools/regional-conditions.ts:32-68 (handler)The handler function that executes the tool: validates region, fetches active events from DriveBC API for the region (filtered by eventType and limit if provided), formats and returns the list or appropriate messages.export async function handleRegionalConditions(args: { region: string; eventType?: EventType; limit?: number; }): Promise<string> { try { const regionId = findRegionId(args.region); if (!regionId) { const validRegions = Object.keys(BC_REGIONS).join(', '); return `Invalid region "${args.region}". Valid regions are: ${validRegions}`; } const params: EventQueryParams = { status: 'ACTIVE', area_id: regionId, limit: args.limit ?? 50, }; if (args.eventType) { params.event_type = args.eventType; } const events = await getEvents(params); if (events.length === 0) { return `No current events found for ${args.region} region.`; } return `Regional Conditions for ${args.region}\n\n${formatEventList(events)}`; } catch (error) { if (error instanceof Error) { return `Error fetching regional conditions: ${error.message}`; } return 'Error fetching regional conditions: Unknown error'; } }
- Tool metadata including name, description, and input schema defining parameters: region (required), eventType (optional enum), limit (optional number).export const regionalConditionsTool = { name: 'get_regional_conditions', description: 'Get road conditions and events for a specific BC region. Useful for planning trips within a geographic area.', inputSchema: { type: 'object' as const, properties: { region: { type: 'string', description: `BC region name. Options: ${Object.keys(BC_REGIONS).join(', ')}`, }, eventType: { type: 'string', enum: ['CONSTRUCTION', 'INCIDENT', 'WEATHER_CONDITION', 'ROAD_CONDITION', 'SPECIAL_EVENT'], description: 'Filter by event type (optional)', }, limit: { type: 'number', description: 'Maximum number of events to return (default: 50, max: 500)', minimum: 1, maximum: 500, }, }, required: ['region'], }, };
- src/index.ts:39-48 (registration)Registers the regionalConditionsTool in the listTools response.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ highwayConditionsTool, regionalConditionsTool, roadClosuresTool, weatherAlertsTool, ], }; });
- src/index.ts:56-75 (registration)Registers the handler in the callTool switch statement, mapping 'get_regional_conditions' to handleRegionalConditions.switch (name) { case 'get_highway_conditions': result = await handleHighwayConditions(args as any); break; case 'get_regional_conditions': result = await handleRegionalConditions(args as any); break; case 'get_road_closures': result = await handleRoadClosures(args as any); break; case 'get_weather_alerts': result = await handleWeatherAlerts(args as any); break; default: throw new Error(`Unknown tool: ${name}`); }
- src/index.ts:15-17 (registration)Import of the tool schema and handler from the tools module.regionalConditionsTool, handleRegionalConditions, } from './tools/regional-conditions.js';