reunion_get_road_traffic
Retrieve average daily traffic counts and heavy-vehicle statistics for any national road segment on Réunion island, sorted by year and traffic volume.
Instructions
Trafic Moyen Journalier Annuel (TMJA, average daily traffic) counts on Réunion national-road segments. Each row is a counted segment between two PR markers (points de repère) for a given year. Returns: route code, year, TMJA in vehicles/day, heavy-vehicle count and percentage, PR start/end, location name, commune, count type (manual vs automatic). Sorted by year then traffic descending. Source: DEAL Réunion via data.regionreunion.com.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| route | No | Exact national-road code, e.g. "RN1", "RN1A", "RN2", "RN3" | |
| year | No | Reference year of the count (4 digits, e.g. 2022) | |
| commune | No | Commune name prefix match | |
| limit | No | Max segments to return (1-500, default 50) |
Implementation Reference
- src/modules/transport.ts:19-60 (handler)The registerTransportTools function registers 'reunion_get_road_traffic' as a server.tool, with the handler (async callback at line 29) that queries the 'trafic-mja-rn-lareunion' dataset and returns TMJA (average daily traffic) data.
export function registerTransportTools(server: McpServer): void { server.tool( 'reunion_get_road_traffic', 'Trafic Moyen Journalier Annuel (TMJA, average daily traffic) counts on Réunion national-road segments. Each row is a counted segment between two PR markers (points de repère) for a given year. Returns: route code, year, TMJA in vehicles/day, heavy-vehicle count and percentage, PR start/end, location name, commune, count type (manual vs automatic). Sorted by year then traffic descending. Source: DEAL Réunion via data.regionreunion.com.', { route: z.string().optional().describe('Exact national-road code, e.g. "RN1", "RN1A", "RN2", "RN3"'), year: z.number().int().optional().describe('Reference year of the count (4 digits, e.g. 2022)'), commune: z.string().optional().describe('Commune name prefix match'), limit: z.number().int().min(1).max(500).default(50).describe('Max segments to return (1-500, default 50)'), }, async ({ route, year, commune, limit }) => { try { const data = await client.getRecords<RecordObject>(DATASET_TRAFFIC, { where: buildWhere([ route ? `route = ${quote(route)}` : undefined, year !== undefined ? `annee = ${year}` : undefined, commune ? `commune LIKE ${quote(`${commune}%`)}` : undefined, ]), order_by: 'annee DESC, tmja DESC', limit, }); return jsonResult({ total_segments: data.total_count, segments: data.results.map((row) => ({ route: pickString(row, ['route']), year: pickNumber(row, ['annee']), tmja_vehicles_per_day: pickNumber(row, ['tmja']), heavy_vehicles_count: pickString(row, ['nb_pl']), heavy_vehicles_pct: pickString(row, ['pourcentag']), pr_start: pickString(row, ['plod']), pr_end: pickString(row, ['plof']), lieudit: pickString(row, ['lieudit']), commune: pickString(row, ['commune']), count_type: pickString(row, ['type_compt']), })), }); } catch (error) { return errorResult(error instanceof Error ? error.message : 'Failed to fetch road traffic'); } } ); - src/modules/transport.ts:23-28 (schema)Zod input schema for reunion_get_road_traffic: optional route (string), year (int), commune (string), limit (int, default 50).
{ route: z.string().optional().describe('Exact national-road code, e.g. "RN1", "RN1A", "RN2", "RN3"'), year: z.number().int().optional().describe('Reference year of the count (4 digits, e.g. 2022)'), commune: z.string().optional().describe('Commune name prefix match'), limit: z.number().int().min(1).max(500).default(50).describe('Max segments to return (1-500, default 50)'), }, - src/modules/index.ts:53-53 (registration)registration line in registerAllTools that calls registerTransportTools(server) to register the tool.
registerTransportTools(server); - src/utils/helpers.ts:36-41 (helper)buildWhere helper used by the handler to construct ODSQL WHERE clauses.
export function buildWhere( conditions: Array<string | undefined | null | false> ): string | undefined { const valid = conditions.filter((condition): condition is string => Boolean(condition)); return valid.length > 0 ? valid.join(' AND ') : undefined; } - src/utils/helpers.ts:53-55 (helper)quote helper used by the handler to safely quote string literals for ODSQL queries.
export function quote(value: string): string { return `'${escapeOdSqlString(value)}'`; }