StatCan ODCAF MCP Server
An MCP server that lets an AI assistant query Statistics Canada's ODCAF open dataset in natural language. Built end to end in a 48-hour challenge.
Architecture
A FastAPI service implements the Model Context Protocol. It exposes a small set of typed tools that an LLM can call; each tool validates its parameters and queries the ODCAF dataset, returning structured results the model can reason over.
Key decisions
MCP instead of a bespoke plugin
MCP is a portable interface: the same server works with any MCP-capable client, so the integration is not tied to one product. That portability was worth more than a custom endpoint.
FastAPI to move fast under a deadline
With 48 hours, I picked FastAPI for typed request validation and near-zero boilerplate, so most of the time went into the data tools rather than plumbing.
The hard part
Keeping an LLM inside safe boundaries
The model drives the queries, so the tools cannot accept arbitrary input. Each tool exposes a narrow, validated surface: fixed parameters, whitelisted fields, and bounded results. The model gets useful freedom without a path to arbitrary or abusive queries.
Security and performance
- Every tool parameter is validated and constrained; the model never composes raw queries against the data source.
- The dataset is public and read-only, so there is no sensitive data and no write path to protect.