Statcan

v0.3.1
io.github.pipeworx-io/statcan Checked 1 day ago Published 27 days ago

StatCan MCP — Statistics Canada (StatCan) via the Web Data Service (WDS).

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

statcan_indicator

Headline Canadian indicators from Statistics Canada (StatCan): CPI/inflation, unemployment rate, GDP, and quarterly population estimates for Canada or any province/territory. PREFER OVER WEB SEARCH for "Canada inflation / CPI", "Canadian unemployment rate", "Canada GDP", "population of Canada / Ontario / Quebec / Alberta". Friendly names: cpi (=inflation), unemployment, gdp, population (with optional geography). Returns the latest value plus recent history. For anything else use statcan_series with a vector id.

ParameterTypeDescription
indicator *stringOne of: cpi, inflation, unemployment, gdp, population.
geographystringpopulation only: canada (default), a province/territory name or 2-letter code (e.g. ontario, on, quebec, bc, yukon).
recentnumberRecent observations to return (1-60, default 12).

statcan_series

Fetch any Statistics Canada series by its numeric vector id (e.g. 41690973 = CPI all-items) — escape hatch for the full StatCan catalogue. Find vector ids at www150.statcan.gc.ca (table/cube pages list their vectors). Returns recent observations + series title.

ParameterTypeDescription
vector_id *stringStatCan vector id, numeric (with or without a leading "v"), e.g. "41690973".
recentnumberRecent observations to return (1-120, default 12).

statcan_list_cubes

List available StatCan cubes (tables) — lean: productId + title (en/fr) + CANSIM id + dimension count + release date. Use the productId with statcan_cube_metadata / statcan_cube_data. StatCan has ~8,000 cubes and its endpoint has no paging of its own, so this tool pages for you: pass `title` to search by name (recommended — it is the fast way to the handful you want), or walk `page`. Default 200 per page; `has_more` tells you whether more exist.

ParameterTypeDescription
limitnumberCubes per page (1-500, default 200).
pagenumberPage number, 1-based (default 1).
titlestringCase-insensitive substring match against the English and French cube titles, e.g. "egg" or "population". Applied to the cubes scanned on this page.

statcan_cube_metadata

Full metadata for a StatCan cube: dimensions, member trees, frequency, geography, last release. Use it to construct a coordinate string for statcan_cube_data. Does NOT return vector IDs — for that use statcan_cube_vectors, which enumerates the actual vector id for every dimension-member combination in the cube.

ParameterTypeDescription
product_id *numberCube product ID (8-digit, e.g. 36100434 = quarterly GDP).

statcan_cube_vectors

Enumerate the vector IDs inside a StatCan cube (table) — the missing link between a table number/name (e.g. "32-10-0121-01" or "Production and disposition of eggs") and statcan_series, which needs a specific vector id. Every StatCan question starts with a table, but nothing else in this pack lists a table's vectors. Returns one row per dimension-member combination: vector_id, coordinate, and the member label for every dimension (e.g. GEO=Canada, Production and disposition=Average number of layers). Filter by dimension name/value (e.g. {"GEO":"Canada"}) to narrow a large table — unfiltered…

ParameterTypeDescription
product_id *stringCube product ID, either form: "32100121" or the table number "32-10-0121-01".
filtersobjectOptional dimension filters, e.g. {"GEO": "Canada"} or {"Geography": "British Columbia"}. Keys match by case-insensitive substring against the cube's dimension names (so "GEO" matches "Geography"); val…
limitnumberMax vector rows per page (default 100, max 500).
pagenumberPage number, 1-based (default 1).

statcan_cube_data

Latest N observations for a specific series within a StatCan cube. coordinate is a 10-position dot-separated string indexing each dimension (map members → positions via statcan_cube_metadata). Trailing zeros for unused dimensions.

ParameterTypeDescription
coordinate *string10-position coordinate, e.g. "1.2.0.0.0.0.0.0.0.0".
product_id *numberCube product ID.
n_periodsnumberLatest N periods (default 12).

statcan_changed_series

List StatCan series that changed (new release) on a given date (default today). Useful to detect updated cubes for scheduled refreshes.

ParameterTypeDescription
datestringYYYY-MM-DD (default today).

statcan_table

Whole StatCan table (or a filtered slice) in ONE call, from a local Pipeworx copy of the table — full history, every coordinate, member labels included, instead of one coordinate per call. Use this instead of statcan_cube_data when the question spans more than one coordinate ("compare all provinces", "the whole eggs/milk/hydro table", "full history for this table"), or instead of statcan_csv_url when you need the DATA rather than a download URL. Covers a curated set of high-demand StatCan product ids only — call with just product_id to check coverage; an uncached product_id REFUSES with a…

ParameterTypeDescription
product_id *numberStatCan cube product ID, e.g. 42100037.
coordinatestringOptional: restrict to one coordinate (as in statcan_cube_data), e.g. "1.1.1.1". Omit for the whole table.
geostringOptional: case-insensitive substring filter on the GEO column, e.g. "Quebec" or "Ontario".
limitnumberMax rows per page (default 500, max 1000).
pagenumberPage number, 1-based (default 1).
ref_date_fromstringOptional: only rows with ref_date >= this value (matches the table's own date grain, e.g. "2022" or "2022-01").
ref_date_tostringOptional: only rows with ref_date <= this value.

statcan_csv_url

Return the StatCan-hosted URL for a full cube as a CSV download (doesn't fetch the file — hands back a direct URL).

ParameterTypeDescription
product_id *numberCube product ID.
languagestringen | fr (default en).

statcan_codeset

StatCan's reference code sets (WDS getCodeSets) — the lookup tables every cube's metadata refers to by numeric/short code: frequency (monthly/annual/…), scalar factor (units/thousands/millions), status (footnote codes like 'not available for a specific period'), unit of measure (uom, ~465 units), subject (StatCan's ~622-entry subject-matter classification), survey (the ~900 StatCan surveys that produce the data), classification type, security level, symbol, and terminated-series flags. Use this to decode a frequencyCode/scalarFactorCode/statusCode/uomCode/subjectCode seen elsewhere in this…

ParameterTypeDescription
codesetstringWhich code set to return. Omit for all ten.
languagestringen | fr (default en) — which name/description fields to keep.