GovData MCPのロゴ

GovData MCP

コミュニティ
Chester-2026

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

公開者Chester-2026
リポジトリGov-Stat-MCP-Server
言語Python
フォーク
3
スター
21
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    GovData MCPは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには21件のスターと3件のフォークがあります。

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

GovData MCPのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度GovData MCPに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

GovData MCPをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. GovData MCPのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "gov-stat-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてGovData MCPのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. GovData MCPのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
GovData MCPを使ってこのタスクを手伝ってもらえますか?
GovData MCP
はい、読みました。
GovData MCPで調べた結果をお伝えします。

よくある質問

GovData MCP MCPサーバーは何に使いますか?

GovData MCPは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでGovData MCP MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでGovData MCPを利用できます。

TypingMindでGovData MCP MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。GovData MCPを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

GovData MCP MCPをTypingMindに接続するにはどうすればよいですか?

GovData MCPはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでGovData MCP MCPのどのようなツールを利用できますか?

GovData MCPはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

GovData MCP MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。GovData MCPで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇