Skip to main content
Glama

get_road_closures

Retrieve current road closures and restrictions across British Columbia, with options to filter by region, highway, or severity level.

Instructions

List all current road closures and major restrictions across BC or filtered by region/highway. Includes full closures, lane closures, and significant restrictions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
regionNoFilter by BC region (optional)
highwayNoFilter by specific highway (optional)
severityMinimumNoMinimum severity to include (default: MODERATE)

Implementation Reference

  • The handler function that implements the core logic: queries events API with filters, identifies closure-related events using keywords and severity, applies minimum severity filter, sorts by severity, and formats a numbered list of closures.
    export async function handleRoadClosures(args: { region?: string; highway?: string; 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.highway) { params.road_name = normalizeHighwayName(args.highway); } const events = await getEvents(params); const closureEvents = events.filter(isClosureRelated); const severityOrder = { MAJOR: 0, MODERATE: 1, MINOR: 2, UNKNOWN: 3 }; const minimumSeverity = args.severityMinimum ?? 'MODERATE'; const minLevel = severityOrder[minimumSeverity]; const filteredEvents = closureEvents.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.highway) filters.push(`highway: ${normalizeHighwayName(args.highway)}`); const filterStr = filters.length > 0 ? ` (${filters.join(', ')})` : ''; return `No road closures found${filterStr}.`; } const lines: string[] = []; lines.push(`Found ${sortedEvents.length} road closure(s):\n`); sortedEvents.forEach((event, index) => { lines.push(`${index + 1}. ${formatClosureInfo(event)}`); lines.push(''); }); return lines.join('\n'); } catch (error) { if (error instanceof Error) { return `Error fetching road closures: ${error.message}`; } return 'Error fetching road closures: Unknown error'; } }
  • Defines the tool metadata including name, description, and input schema for optional parameters: region, highway, severityMinimum.
    export const roadClosuresTool = { name: 'get_road_closures', description: 'List all current road closures and major restrictions across BC or filtered by region/highway. Includes full closures, lane closures, and significant restrictions.', inputSchema: { type: 'object' as const, properties: { region: { type: 'string', description: 'Filter by BC region (optional)', }, highway: { type: 'string', description: 'Filter by specific highway (optional)', }, severityMinimum: { type: 'string', enum: ['MINOR', 'MODERATE', 'MAJOR'], description: 'Minimum severity to include (default: MODERATE)', }, }, required: [], }, };
  • src/index.ts:39-48 (registration)
    Registers the roadClosuresTool (imported from road-closures.ts) in the list of tools returned by ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ highwayConditionsTool, regionalConditionsTool, roadClosuresTool, weatherAlertsTool, ], }; });
  • src/index.ts:65-67 (registration)
    In the CallToolRequestHandler switch, maps 'get_road_closures' tool calls to the handleRoadClosures function.
    case 'get_road_closures': result = await handleRoadClosures(args as any); break;
  • Helper function to determine if an event is related to road closures by checking keywords in headline/description or MAJOR severity.
    function isClosureRelated(event: Event): boolean { const closureKeywords = [ 'closure', 'closed', 'impassable', 'blocked', 'restricted', 'detour', ]; const textToCheck = `${event.headline} ${event.description || ''}`.toLowerCase(); return closureKeywords.some(keyword => textToCheck.includes(keyword)) || event.severity === 'MAJOR'; }

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