Calgary Open Data MCP Server
Enables AI assistants to search, explore, and query Calgary's open data portal using SoQL, with tools for dataset discovery, metadata inspection, and data querying.
README
Calgary Open Data MCP Server
An MCP (Model Context Protocol) server that gives AI assistants access to the Calgary Open Data portal. Search datasets, inspect schemas, and query any dataset using SoQL — all through a unified MCP interface.
Disclaimer: This project is unofficial and is not affiliated with, endorsed by, or connected to the City of Calgary. It queries publicly available data through the Socrata Open Data API.
Quick Start
Use the hosted server (no setup required)
Connect any MCP-compatible client to the hosted endpoint:
https://calgary-open-data.baobabtech.app/mcp
Run locally with npx
npx calgary-open-data-mcp
This starts a local stdio MCP server — no cloning or configuration needed.
Tools
The server exposes three tools:
search_datasets
Search the Calgary Open Data catalog by keyword, category, or tag.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | no | Keyword search term |
categories |
string | no | Filter by category name |
tags |
string | no | Filter by tag |
limit |
number | no | Results per page (1-100, default 10) |
offset |
number | no | Pagination offset |
get_dataset_metadata
Get the full schema and metadata for a specific dataset.
| Parameter | Type | Required | Description |
|---|---|---|---|
datasetId |
string | yes | Socrata four-by-four ID (e.g. 35ra-9556) |
Returns column names, field names, data types, descriptions, tags, license, and last updated timestamp.
query_dataset
Query any dataset using SoQL (Socrata Query Language).
| Parameter | Type | Required | Description |
|---|---|---|---|
datasetId |
string | yes | Socrata four-by-four ID |
select |
string | no | Columns to return ($select). E.g. name, address, count(*) |
where |
string | no | Filter condition ($where). E.g. year > 2020 |
order |
string | no | Sort order ($order). E.g. date DESC |
group |
string | no | Group by columns ($group). E.g. ward |
having |
string | no | Post-aggregation filter ($having). E.g. count(*) > 10 |
q |
string | no | Full-text search across all text columns |
limit |
number | no | Max rows to return (1-50000, default 100) |
offset |
number | no | Pagination offset |
Client Configuration
All examples below use the hosted endpoint. Replace the URL with http://localhost:3000/mcp for local development.
Claude Desktop
Settings > Connectors > Add custom connector, enter:
https://calgary-open-data.baobabtech.app/mcp
Claude Code
claude mcp add --transport http calgary-open-data https://calgary-open-data.baobabtech.app/mcp
Cursor
In .cursor/mcp.json:
{
"mcpServers": {
"calgary-open-data": {
"url": "https://calgary-open-data.baobabtech.app/mcp"
}
}
}
ChatGPT
Settings > Apps & Connectors > Advanced settings, enable Developer mode, click Create, enter:
https://calgary-open-data.baobabtech.app/mcp
npx (stdio) for any MCP client
{
"mcpServers": {
"calgary-open-data": {
"command": "npx",
"args": ["-y", "calgary-open-data-mcp"]
}
}
}
Self-Hosting
Vercel
The root of this repo is a Next.js app ready to deploy on Vercel.
git clone https://github.com/baobab-tech/calgary-open-data-mcp.git
cd calgary-open-data-mcp
pnpm install
Deploy via the Vercel CLI or connect the repo in the Vercel dashboard.
Optional: Set a SOCRATA_APP_TOKEN environment variable in your Vercel project settings for higher Socrata API rate limits. Register for a free app token at data.calgary.ca.
Cloudflare Workers
A self-contained Cloudflare Worker lives in the cloudflare/ directory.
cd cloudflare
pnpm install
pnpm run login # authenticate with Cloudflare (first time only)
pnpm run dev # local development
pnpm run cf:deploy # deploy to Cloudflare
Optional: Set a SOCRATA_APP_TOKEN secret:
npx wrangler secret put SOCRATA_APP_TOKEN
Development
Prerequisites
Setup
git clone https://github.com/baobab-tech/calgary-open-data-mcp.git
cd calgary-open-data-mcp
pnpm install
Running locally
Vercel (Next.js) dev server:
pnpm dev
MCP endpoint available at http://localhost:3000/mcp.
Cloudflare Worker dev server:
cd cloudflare
pnpm install
pnpm run dev
CLI (stdio):
pnpm build:cli
node dist/cli.js
Type checking
# Root project (Vercel + CLI)
pnpm tsc --noEmit
# Cloudflare Worker
cd cloudflare && pnpm tsc --noEmit
Building the CLI for npm
pnpm build:cli
This produces dist/cli.js — the file referenced by the bin field in package.json.
Project Structure
src/
lib/
socrata.ts Socrata API client (Discovery, Metadata, SODA)
tools.ts Shared MCP tool definitions
cli.ts npx entry point (stdio transport)
app/
[transport]/route.ts Vercel HTTP endpoint (Streamable HTTP)
page.tsx Landing page
layout.tsx
cloudflare/
src/index.ts Cloudflare Worker (self-contained)
wrangler.toml
package.json
The Vercel deployment and the npx CLI share tool definitions via src/lib/tools.ts. The Cloudflare Worker is self-contained since CF Workers use a different module runtime.
How It Works
This server wraps three layers of the Socrata Open Data API that powers data.calgary.ca:
- Discovery API — catalog search across all datasets on the portal
- Metadata API — detailed schema and column information per dataset
- SODA API — the data query layer, using SoQL (a SQL-like query language)
Every dataset on the portal has a unique four-by-four ID (e.g. 35ra-9556). Use search_datasets to find IDs, get_dataset_metadata to understand the schema, then query_dataset to pull the data.
Transport
All remote endpoints use Streamable HTTP — the current MCP transport standard. The npx CLI uses stdio transport for local use.
Contributing
Contributions are welcome! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/my-feature) - Make your changes
- Run type checking (
pnpm tsc --noEmit) - Commit your changes (
git commit -m 'Add my feature') - Push to the branch (
git push origin feature/my-feature) - Open a Pull Request
Ideas for contributions
- Additional tools (e.g. dataset export, geospatial queries)
- Support for other Socrata-powered open data portals
- Caching layer for frequently accessed metadata
- Better error messages and input validation
- Tests
Please open an issue first if you're planning a large change so we can discuss the approach.
License
MIT
Acknowledgements
- City of Calgary Open Data for making public data accessible
- Socrata / Tyler Data & Insights for the API platform
- Model Context Protocol for the open standard
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。