india-gov-data-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@india-gov-data-mcp Find recent wheat mandi prices in Gujarat and include the dataset citation."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
india-gov-data-mcp
Open-source Model Context Protocol (MCP) server giving AI agents direct, queryable, and citation-backed access to India's Open Government Data (data.gov.in) platform.
What Is data.gov.in & What Can You Search?
data.gov.in is the Open Government Data (OGD) Platform India, set up by the National Informatics Centre (NIC) under the Ministry of Electronics and Information Technology (MeitY) in line with the National Data Sharing and Accessibility Policy (NDSAP). It serves as a single-window portal where central ministries, departments, and state governments publish shareable, non-sensitive public datasets and APIs—generally made available under the Government Open Data License – India (GODL)—for research, analytics, journalism, and application building.
What Data It Provides
The portal hosts public datasets across central and state bodies at national, state, and district levels across domains such as:
Agriculture & Markets: Daily wholesale APMC mandi prices, arrivals, varieties, grades, and agricultural statistics.
Environment & Monitoring: Real-time/station-level Air Quality Index (AQI) and pollutant readings (such as CPCB monitoring stations) as well as water and environmental datasets.
Governance, Schemes & Infrastructure: Public schemes, development indicators, transport, energy, and regional records.
Economy & Social Sectors: Finance, health, education, demographic, and sectoral datasets.
Examples of What You Can Search
With this MCP server connected to your AI agent, you can ask natural-language questions instead of hunting through dataset IDs manually:
Road safety: "Search
data.gov.infor state-wise road accident datasets, inspect the schema, and summarize trends for Gujarat."Infrastructure & utilities: "Find state-level energy or water datasets, join them by state, and export a CSV summary."
Education & economy: "Search education or economic datasets, filter by state or category, and include a citation."
Related MCP server: datagovin-mcp
Why We Built This
Connecting LLMs directly to api.data.gov.in typically fails in four ways. india-gov-data-mcp solves each of them at the protocol layer:
Opaque UUID Resource IDs —
data.gov.inexposes 150,000+ datasets behind opaque UUIDs (e.g.,9ef84268-d588-465a-a308-a864a43d0070). Our local SQLite FTS5 seed/cache index paired with live catalog search lets agents discover datasets by natural-language keywords.Exact-String Filter Traps — The API enforces strict, case-sensitive filter matching (e.g.,
"gram"returns 0 rows when the dataset stores"Bengal Gram(Gram)(Whole)", or"Kozhikode"vs"Kozhikode(Calicut)").find_filter_valuesand automatic smart-fallback resolution discover and apply the exact API strings.Token Bloat & Arithmetic Hallucinations — Dumping thousands of raw JSON rows into an LLM context window wastes tokens and leads to mental-math errors. An embedded in-memory DuckDB analytical engine (
aggregate_datasetandjoin_on_geography) computes exactSUM,AVG,MIN,MAX,COUNT, and normalized State/District joins deterministically.Missing Data Provenance — Every analysis needs verifiable attribution.
get_citationreturns the official ministry, dataset title,resource_id, portal URL, applied filters, and UTC retrieval timestamp.
Available MCP Tools
Tool | Description |
| Search datasets by keyword across the local SQLite FTS5 index (instant) with a 5-second live |
| Fetch 5 sample rows, infer column types ( |
| Sample distinct column values and return exact, substring, and fuzzy matches so filters never miss due to parentheticals or casing. |
| Auto-paginate past the 100-row API limit (up to |
| Load filtered records into in-memory DuckDB and compute deterministic |
| Canonicalize Indian State/UT or District spelling variants across two datasets (e.g., |
| Export normalized records locally to |
| Generate a structured citation block with dataset title, |
Prerequisites: Get a Free data.gov.in API Key
Visit https://www.data.gov.in/ and register for a free account (or sign in).
Open My Account from the top navigation menu.
Generate and copy your personal API Key (used as
DATA_GOV_API_KEY).
Installation
Method 1: Zero-Install via uvx (Recommended)
uvx india-gov-data-mcp --helpMethod 2: Install Globally via pip
pip install india-gov-data-mcp
python -m datagov_mcp.server --helpMethod 3: Install from Source (GitHub)
git clone https://github.com/tirthharshi-debug/India-gov-data-MCP
cd India-gov-data-mcp
python -m venv .venvActivate the virtual environment:
Windows (PowerShell):
.venv\Scripts\Activate.ps1macOS / Linux:
source .venv/bin/activate
Install in editable mode with dev dependencies and run the test suite:
pip install -e ".[dev]"
pytestOptional: Pre-Sync the Local Catalog (datagov-sync-catalog)
Pre-populate a local offline SQLite FTS5 index of 1,500+ datasets from api.data.gov.in:
datagov-sync-catalog --pages 15Connecting to Any AI Agent
Note on
uvxvspython: The examples below useuvx. Ifuvxis not installed on your system, replace"command": "uvx"and"args": ["india-gov-data-mcp"]with"command": "python"(or the full path to your.venvPython executable, e.g.,C:\\path\\to\\.venv\\Scripts\\python.exe) and"args": ["-m", "datagov_mcp.server"].
1. Google Antigravity
Config file: ~/.gemini/config/mcp_config.json (Windows: %USERPROFILE%\.gemini\config\mcp_config.json)
{
"mcpServers": {
"india-gov-data-mcp": {
"command": "uvx",
"args": ["india-gov-data-mcp"],
"env": {
"DATA_GOV_API_KEY": "your_data_gov_api_key_here"
}
}
}
}2. Claude Desktop
Config file:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"india-gov-data-mcp": {
"command": "uvx",
"args": ["india-gov-data-mcp"],
"env": {
"DATA_GOV_API_KEY": "your_data_gov_api_key_here"
}
}
}
}3. Cursor
Config file: ~/.cursor/mcp.json (Windows: %USERPROFILE%\.cursor\mcp.json)
{
"mcpServers": {
"india-gov-data-mcp": {
"command": "uvx",
"args": ["india-gov-data-mcp"],
"env": {
"DATA_GOV_API_KEY": "your_data_gov_api_key_here"
}
}
}
}4. Windsurf
Config file: ~/.codeium/windsurf/mcp_config.json (Windows: %USERPROFILE%\.codeium\windsurf\mcp_config.json)
{
"mcpServers": {
"india-gov-data-mcp": {
"command": "uvx",
"args": ["india-gov-data-mcp"],
"env": {
"DATA_GOV_API_KEY": "your_data_gov_api_key_here"
}
}
}
}5. Gemini CLI (@google/gemini-cli)
Config file: ~/.gemini/settings.json (Windows: %USERPROFILE%\.gemini\settings.json)
{
"mcpServers": {
"india-gov-data-mcp": {
"command": "uvx",
"args": ["india-gov-data-mcp"],
"env": {
"DATA_GOV_API_KEY": "your_data_gov_api_key_here"
}
}
}
}6. VS Code (GitHub Copilot Agent Mode)
Config file: .vscode/mcp.json (uses promptString inputs so API keys are never hardcoded in workspace files)
{
"inputs": [
{
"type": "promptString",
"id": "data_gov_api_key",
"description": "Your data.gov.in API Key",
"password": true
}
],
"servers": {
"india-gov-data-mcp": {
"command": "uvx",
"args": ["india-gov-data-mcp"],
"env": {
"DATA_GOV_API_KEY": "${input:data_gov_api_key}"
}
}
}
}Example Prompts to Try
Agriculture / Mandi Prices:
"Find the current wholesale mandi prices for Bengal Gram in Gujarat, compute the average modal price by district, and include the official data.gov.in citation."
CPCB Real-Time Air Quality Index (AQI) Telemetry:
"Search for real-time CPCB Air Quality Index data, inspect the schema, and show the average PM2.5 readings across cities in Maharashtra and Karnataka."
Multi-Market CSV Export:
"Query wholesale mandi prices for Wheat across Punjab and Haryana (up to 500 rows), normalize state names, and export the cleaned dataset to
exports/wheat_mandi_prices.csv."
Security & Engineering Standards
Strict SQL Identifier Validation: All dynamic DuckDB table and column identifiers are validated against
^[a-zA-Z_][a-zA-Z0-9_]*$and quoted before query execution; SQLite FTS5 queries sanitize special syntax operators with a parameterizedLIKEfallback.Export Path-Traversal Hardening:
export_datasetrejects..traversal, sensitive system directories, protected dotfiles (.env,.git), and mismatched file extensions (.csv,.json,.parquetonly).Environment-Based Secrets: API keys are read exclusively from
DATA_GOV_API_KEYand never logged or committed.Verified Quality: Backed by 100
pytestunit tests,banditstatic security analysis, andpip-auditdependency vulnerability scanning.
License
Licensed under the MIT License.
Available Tools
8 toolsaggregate_datasetAggregate DatasetA
Compute an exact aggregation over a data.gov.in dataset using DuckDB.
Fetches filtered data, loads it into an in-memory DuckDB table, and
runs a deterministic SUM, AVG, MIN, MAX, or COUNT
grouped by the specified column. Use this instead of asking the LLM
to do mental math — results are guaranteed correct.
Inputs: group_by (required), resource_id (required), metric_column (required), filters, +1 more. Returns: object
export_datasetExport DatasetA
Export records from a data.gov.in resource to CSV, JSON, or Parquet.
Normalizes column names to snake_case, canonicalizes Indian
state/district names, creates parent directories if needed, and
returns file metadata plus an official citation.
Inputs: output_path (required), resource_id (required), format, filters, +1 more. Returns: object
find_filter_valuesFind Filter ValuesA
Discover exact, case-sensitive filter values for a dataset column.
api.data.gov.in requires exact filter strings (for example
"Bengal Gram(Gram)(Whole)" instead of "Gram", or
"Kozhikode(Calicut)" instead of "Kozhikode"). Use this tool
before query_records or aggregate_dataset whenever a filter
value might have parenthetical suffixes or non-obvious casing.
Inputs: column (required), resource_id (required), search_term (required), sample_size. Returns: object
get_citationGet CitationA
Generate an official citation for a data.gov.in dataset.
Returns a citation block including the dataset title, resource_id, portal URL, any applied filters, and the UTC timestamp of retrieval. Use this to attribute data properly in reports and answers.
Inputs: resource_id (required), filters. Returns: object
inspect_schemaInspect SchemaA
Inspect the schema of a data.gov.in resource before querying it.
Fetches 5 sample rows, infers each column's type (numeric,
date, state, district, or text), and shows distinct
sample values for categorical columns so you know the exact casing
and spelling to use in filters.
Always call this before query_records or aggregate_dataset
to avoid guessing column names or filter values.
Inputs: resource_id (required). Returns: object
join_on_geographyJoin On GeographyA
Join two data.gov.in datasets on normalized Indian geography.
Normalizes state or district names in both datasets (e.g. maps
"Bangalore" → "Bengaluru", "Orissa" → "Odisha")
so they match, then performs an inner join via DuckDB.
Use case: Combine AQI data with health data by state, or merge crop production with rainfall data by district.
Inputs: resource_id_a (required), resource_id_b (required), filters_a, filters_b, +1 more. Returns: object
query_recordsQuery RecordsA
Fetch records from a data.gov.in resource with auto-pagination.
Automatically paginates past the 100-row API limit in batches,
normalizes field names to snake_case, and canonicalizes Indian
state/district names.
Inputs: resource_id (required), filters, max_rows. Returns: object
search_catalogSearch CatalogA
Search data.gov.in for datasets by keyword.
Returns up to limit matching datasets with their resource_id,
title, ministry/sector, and description. Use this FIRST to discover
the resource_id you need before calling other tools.
Examples of good queries:
"mandi prices agricultural commodities""air quality AQI pollution""census population state wise""electricity generation power""rural roads PMGSY"
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 8 tools
The eight tools map to clearly distinct stages of a data workflow: discovery (search_catalog), schema inspection (inspect_schema), retrieval (query_records), aggregation, joining, filtering, exporting, and citation. The only mild overlap is between inspect_schema and find_filter_values, both of which reveal exact filter values, but their descriptions draw a workable line between column/types and case-sensitive categorical values.
Every tool follows a snake_case verb_noun pattern (inspect_schema, search_catalog, query_records, aggregate_dataset, find_filter_values, export_dataset, get_citation), all describing a concrete action on a concrete object. The one deviation, get_citation using 'get' rather than search/find, is trivial and still consistent with the pattern.
Eight tools is well within the ideal 3-15 range and each one earns its place by covering a distinct step of the data access pipeline. There is no obvious filler or redundant tool.
The surface covers the full agent lifecycle from discovery through schema inspection, filtered retrieval, aggregation, geographic joins, export, and citation, with no real dead ends for ad-hoc analysis. Minor gaps exist: no direct metadata/resource-listing call, and no explicit control over pagination limits or catalog browsing by ministry/sector.
Maintenance
Related MCP Connectors
Search India datasets; inspect sources, licences and previews; get notebook and Python examples.
The all-in-one data stack for agents. Upload files, run SQL, evolve tables, and render charts.
Normalized official data with provenance, aggregations, insights, free samples and agent access.
Normalized official data with provenance, aggregations, insights, free samples and agent access.
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
- AlicenseAqualityDmaintenanceEnables natural-language access to India's Open Government Data platform, letting users discover datasets, inspect schemas, and query live data from data.gov.in.4MIT
- AlicenseAqualityBmaintenanceEnables LLMs to search and query India's Open Government Data platform, including catalog search, dataset schemas, filtered rows, and tidy time series for GDP, trade, agriculture, and other published datasets.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to discover the right dataset on a Huwise/Opendatasoft portal, understand its fields, join keys and lineage, and run validated ODSQL queries without wasting API quota. It serves token-budgeted compiled dataset cards with usage-boosted search and schema-checked query execution.MIT