ontario-data-mcp
An MCP server for discovering, downloading, querying, and analyzing datasets from Ontario's open data portals, allowing natural language questions and high-performance analytics via DuckDB.
README
<!-- mcp-name: ontario-data-mcp -->
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, Ottawa, Waterloo, Kitchener, and Region of Waterloo 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
Architecture
flowchart TD
Client["AI Client<br/>(Claude Code · VS Code · etc.)"]
subgraph Server["ontario-data-mcp (FastMCP)"]
direction TB
subgraph Tools["MCP Tools"]
direction LR
T1["Discovery"]
T2["Metadata"]
T3["Retrieval"]
T4["Querying"]
T5["Geospatial"]
T6["Quality & Validation"]
end
PC["Portal Clients<br/>CKANClient · ArcGISHubClient"]
Cache[("DuckDB Cache<br/>~/.cache/ontario-data/")]
Tools -->|"fan out to all portals"| PC
T3 & T5 -->|"download → store"| Cache
T4 & T6 -->|"SQL queries"| Cache
end
subgraph Portals["Open Data Portals"]
direction LR
CKAN["Ontario · Toronto<br/>CKAN API"]
ArcGIS["Ottawa · Waterloo · Kitchener<br/>Region of Waterloo<br/>ArcGIS Hub"]
end
Client <-->|"MCP Protocol"| Tools
PC -->|"CKAN 2.8"| CKAN
PC -->|"OGC Records / Hub v3"| ArcGIS
Data flow: Discovery and metadata tools fan out to all portals in parallel. Retrieval tools download data and store it in a local DuckDB cache. Querying and quality tools run fast SQL locally against the cache — no repeated API calls.
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.
<details> <summary>With VS Code</summary>
Add to .vscode/mcp.json:
{
"mcpServers": {
"ontario-data": {
"command": "uvx",
"args": ["ontario-data-mcp"]
}
}
}
</details>
<details> <summary>From Source</summary>
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
</details>
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 |
waterloo |
ArcGIS Hub | ~129 |
kitchener |
ArcGIS Hub | ~219 |
region-waterloo |
ArcGIS Hub | ~125 |
List of tools available to the AI agent
<details> <summary><b>Discovery</b> (5 tools)</summary>
| 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 |
</details>
<details> <summary><b>Metadata</b> (4 tools)</summary>
| 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) |
</details>
<details> <summary><b>Retrieval & Caching</b> (4 tools)</summary>
| 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 |
</details>
<details> <summary><b>Querying</b> (4 tools)</summary>
| 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 |
</details>
<details> <summary><b>Data Quality</b> (3 tools)</summary>
| 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 |
</details>
<details> <summary><b>Geospatial</b> (3 tools)</summary>
| 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 |
</details>
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.
- Contains information licensed under the City of Waterloo Open Data Licence.
- Contains information licensed under the Open Government Licence - The Corporation of the City of Kitchener.
- Contains information licensed under the Region of Waterloo Open Data Licence v.2.0.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。