datagovin-mcp
datagovin-mcp
一个 MCP 服务器,为 Claude(或任何 MCP 客户端)提供对 印度开放政府数据平台(data.gov.in)的自然语言访问——100,000+ 个公共数据集,涵盖空气质量、农业、健康、燃料价格、人口普查、教育、降雨等更多领域。
本服务器 不附带任何自有数据。它是一个轻量且规范的包装层:每次查询都是使用 你自己的 免费 API 密钥对 data.gov.in 进行的实时调用。它所补充的正是缺失的那一层——数据集发现与简洁查询——让语言模型可以从“现在德里的 AQI 是多少?”直接得到真实数据行,而无需你手动查找数据集 UUID。
为什么存在
data.gov.in 有庞大的目录,但没有好用的全文搜索 API:通常的流程是浏览网站,然后从某个数据集的“API”按钮复制其资源 ID。这对 LLM 来说并不友好。这个服务器用一份经过整理、已验证且可按关键词搜索的索引来弥补这一空缺,并提供工具实时获取数据集的结构、拉取实时数据行。它还处理了上游 API 的边缘问题(区分大小写的筛选字段、偶尔返回 CSV 响应、最后一项分页的刺痛),因此模型无需这些。
Related MCP server: bharatlas-mcp
工具
工具 | 作用 |
| 按照整理好的索引中的关键词查找数据集的 |
| 列出索引中存在的所有领域。 |
| 实时获取结构:标题、描述、行数、字段名称 + 类型。 |
| 实时拉取经过筛选的实际数据行。 |
设置
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.txt3. 设置你的密钥。
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" }
}
}
}重启客户端,这四个工具就会显示出来。
示例对话
你: 你有什么关于空气质量的数据集? 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。部分旧版数据集被返回为 CSV,即使传递
format=json也一样;客户端通过 Content-Type 识别这种情况,然后仍然解析该 CSV。最后一页的分页 可能返回一个空的
records数组,同时报status: ok;如果返回数据的Total为 0,而总数为 > 0,说明你已经翻过最后一页。每次请求最大约 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 toolsget_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
Scored across 4 tools
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.
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.
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.
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.
Related MCP Connectors
Search India datasets; inspect sources, licences and previews; get notebook and Python examples.
Query India's open geo data, and author collect maps: register a link, moderate, publish.
Indian government statistics and public data: economy, elections, health, agriculture and more
Discover, resolve, and query official Brazilian economic data with semantic search and provenance.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceExposes India's open government data (data.gov.in) APIs via the Model Context Protocol, enabling agentic AI data exploration.2MIT
- AlicenseAqualityBmaintenanceDescription: 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.1744MIT
- AlicenseAqualityDmaintenanceEnables 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.105MIT

MoSPI MCP Serverofficial
AlicenseNot gradedqualityCmaintenanceProvides AI-ready access to Indian government statistics through MCP, enabling natural language queries for economic, demographic, and social indicators.149MIT