Logo GovData MCP

GovData MCP

Cộng đồng
Chester-2026

A Centralized MCP Server for Fetching Data from Many Countries' Govs

Nhà phát hànhChester-2026
Kho mãGov-Stat-MCP-Server
Ngôn ngữPython
Bản fork
3
Sao
21
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    GovData MCP cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    21 sao và 3 bản fork từ kho mã được liên kết.

GovData MCP

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, 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.

Key Features

  • 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 ("use get_download_link instead", "retry with dataset_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. stdio for local clients (Claude Desktop etc.), stateless streamable-http for serverless deployment (Google Cloud Run).

Supported Portals

CodePortalAPISearchExploreRow PreviewNotes
usdata.govdata.gov v4 (DCAT)✅✅CSV fallbackRequires free api.data.gov key
ukdata.gov.ukCKAN✅✅CSV fallbackResource lookups need the parent dataset_id
caopen.canada.caCKAN✅✅CSV fallbackBilingual titles normalized to English
audata.gov.auCKAN + DataStore✅✅✅ DataStoreFull row queries with text filtering

Requirements

  • Python 3.11+
  • An api.data.gov API key for the US portal (free; other portals need no credentials)

Installation

bash
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.example to .env and set your key:

bash
DATAGOV_API_KEY=your-api-data-gov-key

Getting Started

Standard config for most MCP clients (stdio transport):

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

Follow the MCP install guide and use the standard config above. Note: govdata-mcp must 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.

Run the server in HTTP mode:

bash
MCP_TRANSPORT=http govdata-mcp

Then point your client at the endpoint:

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

Tools

The intended agent flow: list_portals → search_datasets → get_dataset → preview_resource / fetch_resource / get_download_link.

  • list_portals

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

    • 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)
    • Read-only: true
  • get_dataset

    • 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 from search_datasets
    • Read-only: true
  • preview_resource

    • 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 from get_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 on uk
    • Read-only: true
  • fetch_resource

    • 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 from get_dataset
      • max_kb (number, optional): Max kilobytes to inline (default 256, cap 512)
      • dataset_id (string, optional): Parent dataset id — recommended; required on uk
    • Read-only: true
  • get_download_link

    • 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 from get_dataset
      • dataset_id (string, optional): Parent dataset id — recommended; required on uk
    • Read-only: true

Configuration

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

VariableDefaultDescription
MCP_TRANSPORTstdiostdio (local clients) or http (streamable-http server)
PORT8080Listen port for HTTP transport (injected automatically on Cloud Run)
DATAGOV_API_KEY—api.data.gov key for the US portal; falls back to DEMO_KEY (~30 req/hr)
LOG_LEVELINFOLogging verbosity (always written to stderr)
HTTP_TIMEOUT_SECONDS30Timeout for outbound portal requests
HTTP_MAX_RETRIES2Retries on transient portal errors (5xx / transport), exponential backoff
SEARCH_DEFAULT_LIMIT10Default number of search results
NOTES_TRUNCATE_CHARS200Description truncation length in search summaries
FETCH_MAX_BYTES524288Hard cap for inlined resource content

Docker

bash
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 under deploy/).

Development

bash
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.

Architecture

text
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 one Portal(...) entry to portals/registry.py — done. For portals with quirks, subclass PortalAdapter and override the narrow hooks (normalize_dataset, build_search_params) or, for non-CKAN APIs, the operation methods themselves (see us.py for a full custom adapter).

TODO / Roadmap

  • 🇨🇳 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 in deploy/)
  • US v4 publisher/format search filters (pending API documentation)
  • More CKAN portals (New Zealand data.govt.nz is a near-free addition)
  • Content-type sniffing to rescue mislabeled resource formats

Security Notes

  • This server is read-only toward the portals — no tool can create, modify, or delete anything.
  • fetch_resource and preview_resource download 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).
  • Keep DATAGOV_API_KEY in .env / secret manager — never commit it.

License

MIT

Dùng MCP GovData MCP với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối GovData MCP, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm GovData MCP làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của GovData MCP.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "gov-stat-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của GovData MCP, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của GovData MCP.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng GovData MCP giúp tôi làm việc này không?
GovData MCP
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng GovData MCP.

Câu hỏi thường gặp

Máy chủ MCP GovData MCP dùng để làm gì?

GovData MCP là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP GovData MCP với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng GovData MCP với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP GovData MCP với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối GovData MCP, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP GovData MCP với TypingMind?

GovData MCP hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP GovData MCP cung cấp những công cụ nào trong TypingMind?

GovData MCP cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP GovData MCP không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu GovData MCP yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇