Skip to main content
Glama
datagovin-mcp

datagovin-mcp

datagovin-mcp

Claude(または任意のMCPクライアント)に、インドの政府公開データプラットフォーム data.gov.in への自然言語アクセスを提供する MCP サーバーです。空質、農業、健康、燃料価格、国勢調査、教育、降雨など、10万以上の公開データセットをカバーしています。

このサーバーはデータを一切持たず*ありません。薄くて行儀の良いラッパーであり、すべてのクエリは、あなた自身の無料APIキーを使った data.gov.in へのライブ呼び出しです。このサーバーが追加するのは欠けていた層——データセットの発見とクリーンなクエリ実行です。これにより、言語モデルは「今のデリーのAQIは?」という質問から実際のデータ行まで到達でき、あなたが手作業でデータセットのUUIDを探す必要はありません。

どうして存在するのか

data.gov.in は膨大なカタログを持つ一方、きちんとした全文検索APIがありません。通常のワークフローは、Webサイトを閲覧し、そのデータセットのリソースIDを「API」ボタンからコピーするというものです。これは大規模な言語モデルには不向きです。このサーバーは、キーワードで検索できる厳選された検証済みインデックスと、データセットのスキーマを取得してフィルタ済みの行をライブで取り出すツールを提供し、そのギャップを埋めます。また、上流APIの粗い部分(大文字小文字を区別するフィルタ、ときどきCSVで返ること、最後のページングの動作などを)を吸収するので、モデルがそれに対応する必要はありません。

Related MCP server: bharatlas-mcp

ツール

ツール

機能

search_datasets(query, limit)

キュレーションしたインデックスからキーワードでデータセットの resource_id を検索します。

list_sectors()

カタログにあるセクターを一覧表示します。

get_dataset_info(resource_id)

ライブのスキーマ: タイトル、説明、行数、正確なフィールド名と型。

query_dataset(resource_id, filters, fields, limit, offset)

フィルタを適用した実際のデータ行をライブで取得します。

セットアップ

1. 無料APIキーを取得する。 data.gov.in に登録し、プロフィールページからキーを発行します。無料で、公開されたレート制限はありません。

2. インストールする。

git clone https://github.com/<your-username>/datagovin-mcp.git
cd datagovin-mcp
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

3. キーを設定する。

cp .env.example .env
# edit .env and paste your key, or just export it:
export DATA_GOV_IN_API_KEY="your_key_here"

4. Claude Desktop に接続する。 これをMCPクライアント設定(claude_desktop_config.json)に追加します:

{
  "mcpServers": {
    "datagovin": {
      "command": "python",
      "args": ["/absolute/path/to/datagovin-mcp/server.py"],
      "env": { "DATA_GOV_IN_API_KEY": "your_key_here" }
    }
  }
}

クライアントを再起動すると、4つのツールが表示されます。

会話例

あなた: 大気質に関するどのようなデータセットがありますか? Claude: (search_datasets("air quality") を呼び出し) → 駅別のリアルタイム大気質指数。

あなた: どのようなフィールドがありますか? Claude: (get_dataset_info(...) を呼び出し) → country, state, city, station, pollutant_id, pollutant_avg, last_update…

あなた: デリーのPM2.5の測定値を表示してください。 Claude: (query_dataset(resource_id, filters={"city": "Delhi", "pollutant_id": "PM2.5"}) を呼び出し) → ライブのデータ行。

カタログの拡張

カタログには検証済みのデータセットが初めから含まれており、定期的に増えることを前提としています。任意のデータセットを追加するには、その data.gov.in のページの「API」ボタンからリソースIDをコピーして、次を実行します:

python scripts/add_dataset.py <resource_id> --sector Agriculture --keywords "wheat,crop,production"

このスクリプトは、データセットの実際のタイトルとスキーマをライブで取得し、検証済みのエントリを data/catalog.json に追記します。 --sector と --keywords は任意です。

アップストリームAPIに関する注意点

このサーバーが代わりに処理してくれる data.gov.in の振る舞いをいくつか紹介します。

  • フィルタのフィールド名は大文字・小文字を区別します(filters[State] ≠ filters[State])。これはドキュメントに記載されておらず、常に get_dataset_info が返す正確なフィールド id を使用してください。

  • 一部のレガシーデータセットは、format=json を指定してもCSVを返します。クライアントはContent-Typeでそのことを検出し、そのままパースします。

  • 最後のページのページングでは、空の records 配列と status: ok; が返ることがあります。総件数が正数なのに件数が0件の結果を得た場合、最後のページを超えてページングしていることになります。

  • 1リクエストで最大 ~100 行まで — 大きなセットは offset でページングしてください.

プロジェクト構成

datagovin-mcp/
├── server.py              # MCP entry point (stdio); defines the four tools
├── datagovin/
│   ├── client.py          # async data.gov.in API wrapper (quirk handling)
│   └── catalog.py         # curated catalog load + keyword search
├── data/catalog.json      # verified, extensible dataset index
├── scripts/add_dataset.py # enrich the catalog by resource ID
├── requirements.txt
└── pyproject.toml

ライセンス

MIT

Available Tools

4 tools
get_dataset_infoA

Get the schema of a specific dataset: its title, description, total row count, and the exact list of field names and types.

Call this BEFORE query_dataset when you need to know which fields exist or how to spell a filter field. Field names on data.gov.in are CASE-SENSITIVE (e.g. "State" is not "state"), so always use the exact id returned here when building filters.

Args: resource_id: The dataset UUID, e.g. from search_datasets or the portal.

Inputs: resource_id (required). Returns: result

list_sectorsA

List the sectors covered by the curated dataset catalog (e.g. Environment, Agriculture, Health). Useful for orienting the user before a search.

Inputs: no named parameters. Returns: result

query_datasetA

Pull actual rows from a data.gov.in dataset, optionally filtered.

Fetches live data using the user's API key. limit is capped at 100 rows per call (the upstream maximum); page through larger result sets with offset. If a call returns zero rows but a positive total, you have paged past the end.

IMPORTANT: filter field names are case-sensitive and must match a field id from get_dataset_info exactly. If a filter returns nothing unexpectedly, check the capitalisation of the field name first.

Args: resource_id: The dataset UUID (from search_datasets or the portal). filters: Optional {field_id: value} pairs, e.g. {"city": "Delhi"}. fields: Optional list of field ids to return (projection). Omit for all. limit: Rows to return, 1-100 (default 10). offset: Row offset for pagination (default 0).

Inputs: resource_id (required), limit, fields, offset, +1 more. Returns: result

search_datasetsA

Find datasets on India's Open Government Data platform by keyword.

Use this FIRST when the user asks about Indian public data (air quality, crop production, fuel prices, census, health, education, rainfall, etc.) and you don't already have a resource ID. Returns matching datasets with their resource_id, which the other tools need.

Searches a curated local index of verified data.gov.in datasets. If nothing matches, tell the user they can add any dataset by copying its resource ID from the dataset's "API" button on data.gov.in, then running scripts/add_dataset.py.

Args: query: Plain-language keywords, e.g. "air quality delhi" or "wheat production". limit: Max results to return (default 10).

Inputs: query (required), limit. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a distinct responsibility: discover datasets (search_datasets), browse categories (list_sectors), inspect schema (get_dataset_info), and retrieve rows (query_dataset). No two tools could be confused for the same action.

    Naming Consistency5/5

    All four tool names follow a uniform verb_noun pattern (search_datasets, list_sectors, get_dataset_info, query_dataset). While the verbs differ, each one accurately maps to its unique action, and the snake_case style is consistent throughout.

    Tool Count5/5

    With only 4 tools, the server is tightly scoped to the core use case of discovering and retrieving Indian open government data. Each tool is necessary and none feel redundant, making the tool count highly appropriate.

    Completeness4/5

    The tool surface covers the end-to-end read-only workflow: search, sector overview, schema inspection, and data extraction with pagination. Minor gaps include no direct way to list every dataset in the catalog and limited dataset metadata (e.g., update date), but agents can work around these via search and get_dataset_info.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Description: Query India's open geo data in natural language. 8 tools: list layers, inspect schemas, filter/group any column, point-in-polygon locate, spatial proximity search, downloads in 5 formats. Covers admin boundaries (state to village), city wards, forests, rivers, dams, hospitals, highways, airports, and more.
      17
      43
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables querying and analyzing over 90,000 public datasets from the Spanish Government Open Data Portal (datos.gob.es) using natural language, with tools for search, filtering, metadata access, and SPARQL queries.
      10
      5
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides AI-ready access to Indian government statistics through MCP, enabling natural language queries for economic, demographic, and social indicators.
      148
      MIT