MCP Server for interacting with Statistics Canada Web Data Services API
Project description
Statistics Canada MCP Server
MCP server for Statistics Canada's Web Data Service (WDS) and SDMX REST API. Gives any MCP client โ Claude, ChatGPT, Gemini,Cursor, VS Code Copilot, and more โ structured access to Canadian statistical data.
Currently Hosting!
๐ Use the hosted version (easiest)
Last Hosting Update: Feb 28/2026
No installation required, connect to the public server if you the link below works
Claude Desktop
- Go to Settings (โ,) โ Connectors โ Add Custom Connector
- Add mcp-statcan to
name - Add https://mcp-statcan.onrender.com/mcp to
Remote MCP Server URL - Restart Claude Desktop
๐ป Can also be Self-host locally (full features and additional SQLite database support!)
Two setup modes:
| Mode | Tools available | DB/Storage? | Best for |
|---|---|---|---|
| HTTP (self-hosted) | WDS + SDMX (~15 tools) | No | Most users โ data access without local storage |
| stdio (full) | All tools incl. SQLite | Yes | Power users โ multi-series analysis, SQL queries |
Table of Contents
Examples
Chat demos
| Dataset | Query | Demo | Source |
|---|---|---|---|
| Canada's Greenhouse Gas Emissions (2018-2022) | "Create a simple visualization for greenhouse emissions for Canada as a whole over the last 4 years" | View | Table 38-10-0097-01 |
| Canada's International Trade in Services | "Create a quick analysis for international trade in services for the last 6 months with a visualization" | View | Table 12-10-0144-01 |
| Ontario Building Construction Price Index | "Generate a visualization for Ontario's Building Price index from Q4 2023 to Q4 2024" | View | Table 18-10-0289-01 |
Dashboard example
| Dataset | Link | Source |
|---|---|---|
| Labour force characteristics by province, territory and economic region, annual | Dashboard | Table 14-10-0464-01 |
Quick Start
Requires uv:
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
HTTP mode โ WDS + SDMX, no DB (recommended)
Start the server in a terminal and leave it running:
uvx statcan-mcp-server --transport http
# Server running at http://localhost:8000 | /health | /mcp
Then configure your client to connect to http://localhost:8000/mcp โ see Setup by Client below.
Full mode โ add SQLite DB tools
Run via stdio โ no separate server process needed:
uvx statcan-mcp-server
Configure your client with the stdio snippets in Setup by Client.
Setup by Client
| Mode | DB tools? | Tools available |
|---|---|---|
| HTTP (self-hosted, start server first) | No | WDS + SDMX (~15 tools) |
| stdio (full) | Yes | All tools incl. SQLite |
HTTP mode โ WDS + SDMX (no DB)
Before configuring your client: start the server in a separate terminal:
uvx statcan-mcp-server --transport httpKeep it running while using your client. Verify at
http://localhost:8000/health.
Most clients use mcp-proxy to bridge stdio โ HTTP. Claude Code connects natively.
Claude Desktop
Navigate to: Claude Desktop โ Settings (โ,) โ Developer โ Edit Config
{
"mcpServers": {
"statcan": {
"command": "uvx",
"args": ["mcp-proxy", "--transport", "streamablehttp", "http://localhost:8000/mcp"]
}
}
}
Restart Claude Desktop after saving.
Claude Code
claude mcp add statcan --transport http http://localhost:8000/mcp --scope global
Cursor
In .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
{
"mcpServers": {
"statcan": {
"command": "uvx",
"args": ["mcp-proxy", "--transport", "streamablehttp", "http://localhost:8000/mcp"]
}
}
}
VS Code (GitHub Copilot)
In .vscode/mcp.json:
{
"servers": {
"statcan": {
"type": "stdio",
"command": "uvx",
"args": ["mcp-proxy", "--transport", "streamablehttp", "http://localhost:8000/mcp"]
}
}
}
Google Antigravity
Open the config via the UI: three dots (โฎ) โ MCP Servers โ Manage MCP Servers โ View raw config, or edit directly:
- macOS / Linux:
~/.gemini/antigravity/mcp_config.json - Windows:
C:\Users\<you>\.gemini\antigravity\mcp_config.json
{
"mcpServers": {
"statcan": {
"command": "uvx",
"args": ["mcp-proxy", "--transport", "streamablehttp", "http://localhost:8000/mcp"]
}
}
}
Full mode โ WDS + SDMX + SQLite DB tools
No separate server process. uvx downloads and runs statcan-mcp-server from PyPI automatically.
Claude Desktop
Navigate to: Claude Desktop โ Settings (โ,) โ Developer โ Edit Config
{
"mcpServers": {
"statcan": {
"command": "uvx",
"args": ["statcan-mcp-server", "--db-path", "/Users/<you>/.statcan-mcp/statcan_data.db"]
}
}
}
Note: Pass
--db-pathwith an absolute path. Claude Desktop overrides the subprocessHOMEenv var, which breaks the default~/.statcan-mcp/path resolution.
Restart Claude Desktop after saving.
Claude Code
claude mcp add statcan --scope global -- uvx statcan-mcp-server
Cursor
In .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
{
"mcpServers": {
"statcan": {
"command": "uvx",
"args": ["statcan-mcp-server"]
}
}
}
VS Code (GitHub Copilot)
In .vscode/mcp.json:
{
"servers": {
"statcan": {
"type": "stdio",
"command": "uvx",
"args": ["statcan-mcp-server"]
}
}
}
Google Antigravity
Open the config via the UI: three dots (โฎ) โ MCP Servers โ Manage MCP Servers โ View raw config, or edit directly:
- macOS / Linux:
~/.gemini/antigravity/mcp_config.json - Windows:
C:\Users\<you>\.gemini\antigravity\mcp_config.json
{
"mcpServers": {
"statcan": {
"command": "uvx",
"args": ["statcan-mcp-server"]
}
}
}
Optional flags (full/stdio mode)
# Custom database path (recommended for Claude Desktop)
uvx statcan-mcp-server --db-path /your/path/statcan_data.db
# Environment variable alternative
STATCAN_DB_FILE=/your/path/statcan_data.db uvx statcan-mcp-server
Features & Tools
SDMX Tools โ recommended for data fetching
Server-side filtered observations. Only the requested slice is returned โ no downloading full tables.
| Tool | Description |
|---|---|
get_sdmx_structure |
Fetch dimension codelists + key syntax for a table. Call this before get_sdmx_data. |
get_sdmx_data |
Fetch filtered observations by productId + key. Supports lastNObservations, startPeriod, endPeriod. |
get_sdmx_vector_data |
Fetch observations for a single vectorId via SDMX. |
Key syntax (passed to get_sdmx_data):
"1.2.1"โ Geography=1, Gender=2, Age=1".2.1"โ all geographies (wildcard), Gender=2, Age=1lastNObservations=12โ last 12 periods (e.g. 1 year of monthly data)- Limitation:
lastNObservationscannot combine withstartPeriod/endPeriod(StatCan returns 406)
WDS Discovery & Metadata
| Tool | Description |
|---|---|
search_cubes_by_title |
Full-text search across all StatCan tables. AND logic on multiple keywords, capped at 25 results. |
get_all_cubes_list |
Paginated table inventory with dimension details (offset/limit, default 100/page). |
get_all_cubes_list_lite |
Same but lighter โ no dimension or footnote info. |
get_cube_metadata |
Dimension info, member lists, date ranges. summary=True (default) caps members at 10 per dimension. |
get_code_sets |
Decode StatCan numeric codes (frequency, UOM, scalar factor, status). |
WDS Series Resolution
| Tool | Description |
|---|---|
get_series_info |
Resolve one or more {productId, coordinate} pairs to vectorId + metadata in a single call. Replaces the old single + bulk coord tools. |
get_series_info_from_vector |
Resolve a vectorId to productId, coordinate, titles, frequency. |
WDS Change Detection
| Tool | Description |
|---|---|
get_changed_cube_list |
Tables updated on a specific date (YYYY-MM-DD). |
get_changed_series_list |
Series updated on a specific date. |
get_changed_series_data_from_cube_pid_coord |
Data points that changed for a coordinate. |
get_changed_series_data_from_vector |
Data points that changed for a vectorId. |
WDS Data Fetch
| Tool | Description |
|---|---|
get_bulk_vector_data_by_range |
Fetch multiple vectors filtered by release date range (YYYY-MM-DDTHH:MM). Use when you want "data released between date A and date B", not a reference period range. |
Composite Tools (local/stdio mode only)
| Tool | Description |
|---|---|
fetch_vectors_to_database |
Fetch multiple vectors by reference period range and store to SQLite in one call. Preferred workflow for multi-series analysis. |
store_cube_metadata |
Fetch full cube metadata and store into _statcan_dimensions + _statcan_members tables. Use SQL to browse all members and look up vectorIds without loading them into context. |
Database Tools (local/stdio mode only)
Persistent SQLite at ~/.statcan-mcp/statcan_data.db.
| Tool | Description |
|---|---|
create_table_from_data |
Create a table and insert rows in one step. |
insert_data |
Append rows to an existing table. |
query_database |
Read-only SQL (PRAGMA query_only = ON). |
list_tables |
List all tables. |
get_table_schema |
Schema for a table. |
drop_table |
Drop a table. |
Typical workflow (local mode)
1. search_cubes_by_title("unemployment rate")
โ find productId, e.g. 14100287
2. get_sdmx_structure(productId=14100287)
โ see dimensions + codes for key construction
3. get_sdmx_data(productId=14100287, key=".2.1", lastNObservations=24)
โ last 24 months, all geographies, seasonally adjusted
4. (optional) get_series_info(items=[{productId:14100287, coordinate:"1.2.1"}])
โ get vectorId for a specific series
5. (optional) fetch_vectors_to_database(vectorIds=[...], table_name="unemployment")
โ store for SQL analysis
Warning: LLMs may occasionally fabricate data when unable to retrieve actual information. Always verify important figures against official Statistics Canada sources.
Project Structure
src/
โโโ api/
โ โโโ cube_tools.py # WDS cube + search tools
โ โโโ vector_tools.py # WDS vector tools
โ โโโ sdmx_tools.py # SDMX REST tools
โ โโโ composite_tools.py # fetch_vectors_to_database, store_cube_metadata
โ โโโ metadata_tools.py # get_code_sets
โโโ db/ # SQLite connection, schema, queries
โโโ models/ # Pydantic input models
โโโ util/
โ โโโ registry.py # ToolRegistry โ @decorator โ MCP Tool schema
โ โโโ truncation.py # Response truncation + pagination guidance
โ โโโ sdmx_json.py # SDMX-JSON โ tabular rows
โ โโโ cache.py # 1-hour TTL cache for cube list
โ โโโ coordinate.py # Pad WDS coordinate to 10 dimensions
โโโ config.py # BASE_URL, SDMX_BASE_URL, DB_FILE, TRANSPORT, PORT
โโโ server.py # create_server(), transport wiring, CLI entrypoint
Known Issues
- "Unable to open database file" on Claude Desktop: Pass
--db-path /Users/<you>/.statcan-mcp/statcan_data.dbin your config (see Setup). Claude Desktop overrides the subprocessHOMEenv var. - SSL verification disabled:
VERIFY_SSL = Falsein all StatCan API calls. This is a known limitation โ StatCan's certificate chain causes verification failures in some environments. - SDMX OR-key geography labels: Using
+syntax for multiple geographies (e.g."1+2.2.1") produces incorrect Geography labels for series 2+. Use wildcard (omit the dimension:".2.1") instead โ this is a StatCan API bug. lastNObservations+ date range: StatCan SDMX returns 406 when combininglastNObservationswithstartPeriod/endPeriod. Use one or the other.- Rate limits: StatCan's API may throttle during high-demand periods.
GitHub โข Report Bug โข Statistics Canada
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file statcan_mcp_server-0.4.0.tar.gz.
File metadata
- Download URL: statcan_mcp_server-0.4.0.tar.gz
- Upload date:
- Size: 155.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0f40d626bca375bd3417ea0c3ad0ae78e9ebb55206aff36b900f11196835fd2
|
|
| MD5 |
70c6ee7fedad8482d65b5c1c561b3c21
|
|
| BLAKE2b-256 |
ebc0c1c2e2ef3a7441a9bc736d6c60d430f4a8ecd37787bb32c749fe58596e53
|
Provenance
The following attestation bundles were made for statcan_mcp_server-0.4.0.tar.gz:
Publisher:
publish-mcp-registry.yml on Aryan-Jhaveri/mcp-statcan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statcan_mcp_server-0.4.0.tar.gz -
Subject digest:
e0f40d626bca375bd3417ea0c3ad0ae78e9ebb55206aff36b900f11196835fd2 - Sigstore transparency entry: 1005779277
- Sigstore integration time:
-
Permalink:
Aryan-Jhaveri/mcp-statcan@38090d28f694c12e6391cf35a00818e4d6144fcd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Aryan-Jhaveri
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-mcp-registry.yml@38090d28f694c12e6391cf35a00818e4d6144fcd -
Trigger Event:
push
-
Statement type:
File details
Details for the file statcan_mcp_server-0.4.0-py3-none-any.whl.
File metadata
- Download URL: statcan_mcp_server-0.4.0-py3-none-any.whl
- Upload date:
- Size: 48.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f15737191b0dfc04261879b096712738e3ea11973dffed5b2d038059c519757e
|
|
| MD5 |
6ae79e45c0722306eb4ffe2e989bf631
|
|
| BLAKE2b-256 |
5dfc133833d95de3eec0d0a9e8a08badb56c9b6bfac2ae344ab3711de5713a3e
|
Provenance
The following attestation bundles were made for statcan_mcp_server-0.4.0-py3-none-any.whl:
Publisher:
publish-mcp-registry.yml on Aryan-Jhaveri/mcp-statcan
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
statcan_mcp_server-0.4.0-py3-none-any.whl -
Subject digest:
f15737191b0dfc04261879b096712738e3ea11973dffed5b2d038059c519757e - Sigstore transparency entry: 1005779285
- Sigstore integration time:
-
Permalink:
Aryan-Jhaveri/mcp-statcan@38090d28f694c12e6391cf35a00818e4d6144fcd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Aryan-Jhaveri
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-mcp-registry.yml@38090d28f694c12e6391cf35a00818e4d6144fcd -
Trigger Event:
push
-
Statement type: