statcan(2)

MCP

An MCP server for Statistics Canada data.

Connect an AI agent to every Statistics Canada table. Generate chart images ready to share.

Connect

Every client uses one server URL. No key or sign-in is needed.

https://statcan2.ca/api/mcp

Claude

Settings → Connectors → Add custom connector. Paste the server URL.

Claude Code

claude mcp add --transport http statcan2 https://statcan2.ca/api/mcp

ChatGPT

Settings → Apps → Advanced settings → turn on Developer mode. Create an app, paste the server URL and choose No authentication. Needs a paid plan, on the web.

Codex

codex mcp add statcan2 --url https://statcan2.ca/api/mcp

Gemini CLI

gemini mcp add --transport http statcan2 https://statcan2.ca/api/mcp

Grok

In the xAI Responses API, add this remote MCP tool.

{"type":"mcp","server_url":"https://statcan2.ca/api/mcp","server_label":"statcan2"}

Le Chat

Intelligence → Connectors → Add connector → Custom MCP connector. Paste the server URL and choose no authentication.

Cursor

Add to ~/.cursor/mcp.json.

{"mcpServers":{"statcan2":{"url":"https://statcan2.ca/api/mcp"}}}

VS Code · Copilot

code --add-mcp '{"name":"statcan2","type":"http","url":"https://statcan2.ca/api/mcp"}'

Windsurf

Add to ~/.codeium/windsurf/mcp_config.json.

{"mcpServers":{"statcan2":{"serverUrl":"https://statcan2.ca/api/mcp"}}}

OpenCode

Add to opencode.json.

{"mcp":{"statcan2":{"type":"remote","url":"https://statcan2.ca/api/mcp"}}}

Run locally

Run the server over stdio from a checkout of this repo, with your own data build.

{"mcpServers":{"statcan2":{"command":"npm","args":["run","--silent","mcp"],"cwd":"<repo>/api","env":{"STATCAN_BUILD":"<data>/build","STATCAN_NORMALIZED":"<data>/normalized","STATCAN_CODESETS":"<data>/codeSets.json"}}}}

Tools 10

search_tablesSearch the Statistics Canada table inventory by whitespace-separated terms; every term must match the table ID, title, dimension names, member names, or notes.q search words · archived archived or current · queryable only tables with data · limit page size
search_seriesSearch series (one line of a table: one vector, or one coordinate in Census tables).q search words · pid table ID · place_id place ID · unit_family unit type · limit page size
get_placeGet a place: its level, schema and geo_code, every vintage of it (same schema and geo_code, e.g. Ontario 2011, 2016, 2021 DGUIDs), its parent, and every table that covers it, grouped by subject, with the member ID to filter on (m1), the number of series, and a citation per table.place_id place ID
get_tableGet one table's metadata: title, official frequency, subject and survey names, dimensions with every member and its member ID, notes, corrections, symbol legend, and the build report.pid table ID
get_seriesGet time series for a filter: one series per coordinate (the vector in WDS tables), each with member labels, unit, scale, period_kind, and points [ref_date, value_num, status, period_start, period_end].pid table ID · from start date · to end date · vector series ID · m1–m9 member ID per dimension
get_observationsGet observation rows for a filter, with member labels, place_id for dimension 1, unit_family, and period_start, period_end, period_kind.pid table ID · from start date · to end date · vector series ID · m1–m9 member ID per dimension · limit page size · offset rows to skip
get_cubeGet a chartable table's dimensions, member IDs, roles, defaults, units, and period range.pid table ID
run_viewRun a chart spec across table layers.spec chart spec
render_chartRender a chart spec as a 3200×1800 sharing PNG through the PNG API.spec chart spec
plan_chartTurn a question into an editable chart spec using the planner.q question

Chart images

Use plan_chart to get a spec, then render_chart to generate a 3200×1800 PNG through the image API. The tool returns the image, download and chart URLs, and data build IDs. If your client does not display images, open the returned download URL.

Example prompts

  • Compare food and gasoline inflation in Ontario over the past five years.
  • Show unemployment rates for the Prairies and Atlantic Canada.
  • Which Statistics Canada tables cover housing in Toronto?
  • Render a shareable PNG of food inflation in Ontario over the past five years.