GovData MCP

by chester-2026

267 downloads
Not rated
GitHub

About

A Model Context Protocol (MCP) server that lets AI agents search, explore, and fetch open datasets from official government data portals. One unified tool interface across the United States, United Kingdom, Canada, and Australia, with per-portal quirks (API migrations, auth walls

Details

Author
chester-2026
Downloads
267
Categories
Database, Other, API, Developer Tools

- Unified interface for four national government data portals
- Searches, explores, and fetches open datasets
- Absorbs per-portal quirks (API changes, auth, bilingual metadata)
- Supports United States, United Kingdom, Canada, and Australia
- Built on the Model Context Protocol (MCP)

The README does not provide installation, configuration, or invocation instructions. A user would typically add the server to an MCP host/client and then call the exposed tools to search or fetch datasets. No specific commands or config keys are mentioned.

A Model Context Protocol (MCP) server that lets AI agentssearch, explore, and fetch open datasets from official government data portals. One unified tool interface across the United States, United Kingdom, Canada, and Australia — with per-portal quirks (API migrations, auth walls, bilingual metadata, stale DataStore flags) absorbed behind a common adapter layer.

Built for the typical agent workflow:"Is there a government dataset for X?"→ find candidates → inspect the files → preview rows or grab a download link and move on.

- Four national portals, one interface.US (data.gov v4 / DCAT), UK (data.gov.uk / CKAN), Canada (open.canada.ca / CKAN), Australia (data.gov.au / CKAN + DataStore).
- Token-frugal by design.Descriptions are HTML-stripped and truncated, search results are compact summaries, and large files are never inlined by accident.
- Row-level preview.Uses CKAN DataStore where available (Australia), and transparently falls back to reading the head of CSV/TSV files everywhere else.
- Agent-friendly failure modes.Errors are returned as actionable text ("useget_download_linkinstead", "retry withdataset_id", "available portals: …") — never raw tracebacks.
- Extensible registry.Adding another CKAN-based portal is a single config entry; non-CKAN portals plug in via a small adapter class.
- Dual transport.stdiofor local clients (Claude Desktop etc.), statelessstreamable-httpfor serverless deployment (Google Cloud Run).

- Python 3.11+
- Anapi.data.govAPI key for the US portal (free; other portals need no credentials)

git clone https://github.com/YOUR_ORG/Gov-Stat-MCP-Server.git cd Gov-Stat-MCP-Server # pip pip install -e ".[dev]" # or conda conda env create -f environment.yml conda activate opendata-mcp

Copy.env.exampleto.envand set your key:

Standard configfor most MCP clients (stdio transport):

{ "mcpServers": { "govdata": { "command": "govdata-mcp", "env": { "DATAGOV_API_KEY": "your-api-data-gov-key" } } } }
claude mcp add govdata -e DATAGOV_API_KEY=your-key -- govdata-mcp

Follow the MCP installguideand use the standard config above. Note:govdata-mcpmust be on the PATH Claude Desktop uses — provide an absolute path to the executable inside your virtualenv/conda env if needed, e.g./path/to/envs/mcp-env/bin/govdata-mcp.

Use the standard config above in the client's MCP settings file.

{ "mcpServers": { "govdata": { "url": "http://localhost:8080/mcp" } } }

The intended agent flow:list_portalssearch_datasetsget_datasetpreview_resource/fetch_resource/get_download_link.

- Description: List available government open-data portals and their capabilities.
- Parameters: None
- Read-only:true

- Description: Full-text search for datasets on a portal. Returns compact summaries with dataset ids.
- Parameters:

- portal(string): Portal code —us,uk,ca,au
- query(string): Search terms, e.g."air quality monitoring"
- limit(number, optional): Max results (default 10, max 50)
- org(string, optional): Publisher/organization slug filter (CKAN portals)
- format(string, optional): Resource format filter, e.g."CSV"(CKAN portals)

- Description: Full dataset metadata — organization, license, tags, description, and the list of downloadable resources with their ids, formats, and sizes.
- Parameters:

- portal(string): Portal code
- dataset_id(string): Dataset id/slug fromsearch_datasets

- Description: Preview rows from a tabular resource. Tries the portal DataStore first (row counts + text filtering); falls back to reading the head of CSV/TSV files. Non-tabular formats can't be previewed.
- Parameters:

- portal(string): Portal code
- resource_id(string): Resource id fromget_dataset
- rows(number, optional): Rows to return (default 20, max 100)
- query(string, optional): Full-text row filter (DataStore-backed resources only)
- dataset_id(string, optional): Parent dataset id — recommended; required onuk

- Description: Download a small text resource (CSV/JSON/XML/…) and return its content inline, truncated at a size cap on a clean line boundary. Binary content is refused with a pointer to the download URL.
- Parameters:

- portal(string): Portal code
- resource_id(string): Resource id fromget_dataset
- max_kb(number, optional): Max kilobytes to inline (default 256, cap 512)
- dataset_id(string, optional): Parent dataset id — recommended; required onuk

- Description: Return the direct download URL, format, and size for a resource so the agent can proceed on its own. Works for any format, including large/binary files.
- Parameters:

- portal(string): Portal code
- resource_id(string): Resource id fromget_dataset
- dataset_id(string, optional): Parent dataset id — recommended; required onuk

All settings are environment variables (or a local.envfile):

make docker-build # build image make docker-run # run on :8080, exactly as Cloud Run would

The image runs the HTTP transport in stateless mode and is ready for serverless platforms (Google Cloud Run deployment script included underdeploy/).

make run # stdio mode make run-http # HTTP mode on :8080 make inspect # MCP Inspector interactive UI (requires Node.js) make test # offline unit tests make test-live # live end-to-end tests against all four real portals make lint # ruff check + format check

The live suite (pytest -m live) verifies the full search → explore → preview → fetch chain per country plus portal-specific behavior (Canada's bilingual normalization, UK's dataset-scoped resource lookup, Australia's DataStore paths). Run it before deploying — government portals change without notice.

src/govdata_mcp/ ├── server.py # FastMCP instance + tool registration ├── config.py # env-driven settings ├── ckan/ # generic async CKAN client, models, typed errors ├── portals/ │ ├── registry.py # portal registry — single source of truth │ ├── base.py # Portal config + default (vanilla CKAN) adapter │ ├── us.py # data.gov v4 DCAT adapter (auth, cursor paging) │ ├── uk.py # dataset-scoped resource lookup │ └── ca.py # bilingual metadata normalization ├── tools/ # MCP tools: search, explore, fetch └── utils/ # formatting (token economy), CSV-head preview

Adding a portal:for a standard CKAN portal, add onePortal(...)entry toportals/registry.py— done. For portals with quirks, subclassPortalAdapterand override the narrow hooks (normalize_dataset,build_search_params) or, for non-CKAN APIs, the operation methods themselves (seeus.pyfor a full custom adapter).

- 🇨🇳 China portal support— no unified national open-data API exists; planned as a custom adapter targeting National Bureau of Statistics data (via an existing stats package) with graceful degradation.
- 🇯🇵 Japan portal support— e-Gov Data Portal (
data.e-gov.go.jp) is CKAN-compatible and should slot into the existing registry; the richer e-Stat statistics API (app-ID auth, Japanese-language metadata) planned as a dedicated adapter.
- Offline unit test suite with recorded portal fixtures (respx) for CI
- Google Cloud Run deployment walkthrough (service is container-ready; script indeploy/)
- US v4 publisher/format search filters (pending API documentation)
- More CKAN portals (New Zealand
data.govt.nzis a near-free addition)
- Content-type sniffing to rescue mislabeled resource formats

- This server isread-onlytoward the portals — no tool can create, modify, or delete anything.
- fetch_resourceandpreview_resourcedownload from URLs contained in portal metadata; content is size-capped and binary-checked before being returned to the model, but treat fetched content as untrusted input.
- The server itself has no authentication. For remote deployment, put it behind an authenticating proxy or platform-level auth (e.g. Cloud Run with--no-allow-unauthenticated).
- KeepDATAGOV_API_KEYin.env/ secret manager — never commit it.

Access Israeli Government Open Data from the data.gov.il portal.

Access Socrata Open Data APIs from government data portals.

Slingshot MCP introduces Slingshot Aerospace’s space data platform in your AI chat—explore satellites, orbits, and Portal insights through Slingshot’s hosted server.

A modular server providing unified access to multiple astronomical datasets, including astroquery services and DESI data sources.

Access data on 261 countries and 13.4 million cities — population, GDP, geography, rankings, and comparisons. Built for Claude, Cursor, and AI agents.

Access live U.S. congressional data from the Congress.gov API.

A nutrition analysis platform integrating Canada's Food Guide recipes with Health Canada's official nutrition databases.

A read-only MCP server for querying live data from various APIs using the CData JDBC Driver for API Driver.

Query and manage data through CData Connect Cloud, providing a unified interface to various data sources.

Access charity and nonprofit organization data from the IRS database via CharityAPI.org.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.