Skip to main content

Toronto Open Data MCP Server

An MCP (Model Context Protocol) server that provides direct access to Toronto's Open Data through the CKAN API. This server allows LLM agents to efficiently discover, explore, and query Toronto's 500+ public datasets.

Features

  • 🔍 Smart Dataset Discovery: Search through 500+ Toronto datasets with intelligent suggestions
  • 🧠 Intelligent Data Helper: Automatically handles both API and CSV data sources
  • 📊 Flexible Querying: Support for filtering, sorting, and field selection on API datasets
  • 📁 CSV Support: Automatic fetching and preview of downloadable CSV datasets
  • 🤝 LLM-Friendly: Designed for collaborative use with web search when additional context is needed
  • ✅ Robust Error Handling: Clear error messages with actionable suggestions

Installation

Option 1: Using uvx (Recommended for MCP)

The easiest way to use this server with any MCP client:

brew install uv
# No installation needed! uvx will handle everything
# Just use in your MCP client configuration:
uvx toronto-open-data-mcp-server

Option 2: Development Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/toronto-open-data-mcp-server.git
    cd toronto-open-data-mcp-server
    
  2. Install dependencies:

    # Install main dependencies
    pip install -e .
    
    # Install test dependencies (optional)
    pip install -e ".[test]"
    
  3. Run the server:

    python main.py
    

MCP Client Configuration

Using uvx (Easiest Method)

Add this to your MCP client configuration:

{
  "mcpServers": {
    "Toronto Open Data Server": {
      "command": "uvx",
      "args": ["toronto-open-data-mcp-server"]
    }
  }
}

Configuration File Locations

  • Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Cursor: Check Cursor's MCP documentation for config location
  • Other MCP clients: Refer to your client's documentation

Usage

Quick Start

The server provides several tools designed for LLM agents:

  1. toronto_start_here() - Essential first call that explains the workflow
  2. toronto_search_datasets(query) - Find relevant datasets by keywords
  3. toronto_smart_data_helper(dataset_id, user_question) - Intelligent data retrieval
  4. toronto_popular_datasets() - Quick access to commonly used datasets

Example Workflow

# 1. Start with guidance
toronto_start_here()

# 2. Search for relevant data
toronto_search_datasets("restaurant inspection")

# 3. Get data intelligently
toronto_smart_data_helper("dinesafe", "recent restaurant inspection failures")

# 4. Advanced filtering (if needed)
toronto_query_dataset_data("dinesafe", 
                           filters={"establishment_status": "Conditional Pass"},
                           sort="inspection_date desc",
                           limit=10)

Popular Datasets

  • dinesafe - Restaurant inspections and health scores
  • traffic-signals - Traffic light locations and timing
  • parks-facilities - Parks, pools, and recreation facilities
  • business-licences - Licensed businesses in Toronto
  • building-permits - Construction and renovation permits

Testing

This project includes comprehensive tests covering unit tests, integration tests, and workflow tests.

Prerequisites

Install test dependencies:

pip install -e ".[test]"

Running Tests

Quick Test Commands

# Run unit tests only (recommended for development)
python run_tests.py

# Run with verbose output
python run_tests.py --verbose

# Run with coverage report
python run_tests.py --coverage

# Run integration tests (hits real Toronto API)
python run_tests.py --integration

# Run all tests (unit + integration)
python run_tests.py --all

API Reference

Core Tools

toronto_start_here() -> str

Essential first call that provides workflow guidance and server capabilities.

toronto_search_datasets(query: str, limit: int = 10) -> str

Search Toronto datasets by keywords.

toronto_smart_data_helper(dataset_id: str, user_question: str, limit: int = 10) -> str

Intelligent helper that automatically handles both API and CSV data sources.

toronto_query_dataset_data(dataset_id: str, filters: Dict = None, fields: List = None, limit: int = 10, sort: str = None) -> str

Advanced querying with filtering and sorting for API datasets.

Utility Tools

toronto_popular_datasets() -> str

Quick access to commonly used datasets.

toronto_get_dataset_schema(dataset_id: str) -> str

Get field names and types for API datasets.

toronto_fetch_csv_data(csv_url: str, max_lines: int = 50) -> str

Fetch and preview CSV file content.

Architecture

  • FastMCP Framework: Built on the FastMCP framework for easy tool definition
  • CKAN API: Direct integration with Toronto's CKAN-based Open Data portal
  • Collaborative Design: Works alongside web search rather than replacing it
  • Error Recovery: Intelligent error handling with actionable suggestions

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Run the test suite: python run_tests.py --all
  5. Submit a pull request

Metadata

Release files for toronto-open-data-mcp-server 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for toronto-open-data-mcp-server 0.2.0
File Size Uploaded Provenance
toronto_open_data_mcp_server-0.2.0.tar.gz 16.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for toronto-open-data-mcp-server 0.2.0
File Interpreter ABI Platform
toronto_open_data_mcp_server-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 30.9 kB

Release files / toronto_open_data_mcp_server-0.2.0.tar.gz

Download URL toronto_open_data_mcp_server-0.2.0.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
908675555ebf91f514c4f3c20542f9bd41134283e29cb5d7c845eb4accf6fd92
BLAKE2b-256 checksum
How to use checksums
1ee86f1cd9567969a34551b11b5b7586bbbc91888f8f070f2d358f923e751b9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.13

Release files / toronto_open_data_mcp_server-0.2.0-py3-none-any.whl

Download URL toronto_open_data_mcp_server-0.2.0-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
67206e24be103823831ed6f5dcb23cb31eceed66a80137d5cbd3c203472421aa
BLAKE2b-256 checksum
How to use checksums
2125c5cfbe78858fea9999def94a11046bbc605dbf53a5db67f51ecbe836e50d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.13

Security for toronto-open-data-mcp-server 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page