MCP server for searching, downloading, and analyzing datasets from Ontario, Toronto, and Ottawa open data portals
Project description
ontario-data-mcp
[!IMPORTANT]
Beta: This project is under active development. The data structure and tool interfaces may change. LLM-generated analysis may contain errors. Always verify critical findings against the returned source data.
This is an MCP server for discovering, downloading, querying, and analyzing datasets from Ontario's Open Data portals. It allows asking questions of the data in English (or Spanish, Chinese, French, etc).
It currently supports the Ontario, Toronto, and Ottawa portals, and utilizes a shared DuckDB cache for fast SQL queries, statistical analysis, and geospatial operations.
Contributing
Contributions welcome! To get started, see Installation below.
Found a bug? Have an idea? Discovered something interesting? Open an issue here: https://github.com/sprine/ontario-data-mcp/issues
Features
find- search across supported Ontario open data portalsdownload- retrieve and cache datasetsquery- run SQL, statistical, and geospatial analysis via DuckDBvalidate— verify that data claims are supported by query results- A shared DuckDB cache for high-performance analytics
Portal APIs find → Dataset download → DuckDB cache → MCP tools (find, download, query)
Installation
With Claude Code
claude mcp add ontario-data -- uvx ontario-data-mcp
To auto-approve all tool calls (no confirmation prompts), add to your Claude Code settings:
{
"permissions": {
"allow": ["mcp:ontario-data:*"]
}
}
Tools are annotated as read-only or destructive per the MCP spec. Download tools populate the local cache but are read-only (no remote mutations). Destructive tools (cache_manage, refresh_cache) only modify local cached data.
With VS Code
Add to .vscode/mcp.json:
{
"mcpServers": {
"ontario-data": {
"command": "uvx",
"args": ["ontario-data-mcp"]
}
}
}
From Source
git clone https://github.com/sprine/ontario-data-mcp
cd ontario-data-mcp
uv sync
uv run ontario-data-mcp
To connect from source to Claude Code:
Note: MCP subprocesses don't inherit your shell's PATH, so you must use the absolute path to
uv(find it withwhich uv).
claude mcp add ontario-data -- /absolute/path/to/uv run --directory /path/to/ontario-data-mcp ontario-data-mcp
Supported Portals
All searches fan out to every portal by default — no need to select a portal. Dataset and resource IDs are prefixed with their portal (e.g. toronto:abc123).
| Portal | Platform | Datasets |
|---|---|---|
ontario |
CKAN | ~5,700 |
toronto |
CKAN | ~533 |
ottawa |
ArcGIS Hub | ~665 |
List of tools available to the AI agent
Discovery (5 tools)
| Tool | Description |
|---|---|
search_datasets |
Search for datasets across all portals (or narrow with portal=) |
list_portals |
List all available portals with platform type |
list_organizations |
List government ministries with dataset counts |
list_topics |
List all tags/topics in the catalogue |
find_related_datasets |
Find datasets related by tags and organization |
Metadata (4 tools)
| Tool | Description |
|---|---|
get_dataset_info |
Get full metadata for a dataset (use prefixed ID like toronto:abc123) |
list_resources |
List all files in a dataset with formats and sizes |
get_resource_schema |
Get column schema and sample values for a datastore resource |
compare_datasets |
Compare metadata side-by-side for multiple datasets (cross-portal) |
Retrieval & Caching (4 tools)
| Tool | Description |
|---|---|
download_resource |
Download a resource and cache it in DuckDB (use prefixed ID like toronto:abc123) |
cache_info |
Cache statistics + list all cached datasets with staleness |
cache_manage |
Remove a single cached resource or clear the entire cache |
refresh_cache |
Re-download cached resources with latest data |
Querying (4 tools)
| Tool | Description |
|---|---|
query_resource |
Query a resource via CKAN Datastore API (remote) |
sql_query |
Run SQL against the CKAN Datastore (remote) |
query_cached |
Run SQL against locally cached data in DuckDB |
preview_data |
Quick preview of first N rows of a resource |
Data Quality (3 tools)
| Tool | Description |
|---|---|
check_freshness |
Check if a dataset is current vs. its update schedule |
profile_data |
Statistical profile using DuckDB SUMMARIZE |
validate_result |
Validate that a data claim is supported by query results |
Geospatial (3 tools)
| Tool | Description |
|---|---|
load_geodata |
Cache a geospatial resource (SHP, KML, GeoJSON) into DuckDB |
spatial_query |
Run spatial queries against cached geospatial data |
list_geo_datasets |
Find datasets containing geospatial resources |
MCP Resources
Resources the agent can read for context without calling a tool:
| URI | Description |
|---|---|
ontario://cache/index |
List of all locally cached datasets with freshness info |
ontario://dataset/{dataset_id} |
Full metadata for a specific dataset (supports prefixed IDs) |
ontario://portal/stats |
Overview statistics across all data portals |
ontario://schema/{table_name} |
Column schema, types, sample values, and type warnings for a cached table |
ontario://guides/duckdb-sql |
DuckDB SQL reference for Ontario open data analysis |
Prompts
Context-aware guided workflow prompts:
explore_topic— Guided exploration of a topic (fetches live catalogue context)data_investigation— Deep dive into a specific dataset: schema, quality, statisticscompare_data— Side-by-side analysis of multiple datasets
Environment Variables
| Variable | Default | Purpose |
|---|---|---|
ONTARIO_DATA_CACHE_DIR |
~/.cache/ontario-data |
DuckDB storage + log file location |
ONTARIO_DATA_TIMEOUT |
30 |
HTTP timeout in seconds |
ONTARIO_DATA_RATE_LIMIT |
10 |
Max CKAN requests per second |
Development
uv sync
uv run python -m pytest tests/ -v
License
MIT — see LICENSE for the software.
Data accessed through this tool is provided under the following open government licences:
- Contains information licensed under the Open Government Licence – Ontario.
- Contains information licensed under the Open Government Licence – Toronto.
- Contains information licensed under the Open Government Licence – City of Ottawa.
Project details
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 ontario_data_mcp-0.2.0.tar.gz.
File metadata
- Download URL: ontario_data_mcp-0.2.0.tar.gz
- Upload date:
- Size: 1.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
363f1570102f16c501747e349d56964b177295bf907b0d636b96dc1c9fc78761
|
|
| MD5 |
5c09f22cb1094a3b5aa9e4f52678ecde
|
|
| BLAKE2b-256 |
92668914741c71ab849399965752d3913b3b973d8ce92ce50842c1688988025f
|
File details
Details for the file ontario_data_mcp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ontario_data_mcp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 53.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c0748d3b289c2bcb760b87ce0496b2cfe0ee30da54ea11a7822ad0164890c7c
|
|
| MD5 |
d26a7047b9d8681c646bf3d545d4ee09
|
|
| BLAKE2b-256 |
a2a7c01cb30c40f73f9945eae4c20f1bd3411186fa0775d2ddf461d1a6954551
|