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."
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_catalog |
Search datasets by keyword across the local SQLite FTS5 index (instant) with a 5-second live api.data.gov.in fallback. |
inspect_schema |
Fetch 5 sample rows, infer column types (numeric, date, state, district, text), and list sample categorical values. |
find_filter_values |
Sample distinct column values and return exact, substring, and fuzzy matches so filters never miss due to parentheticals or casing. |
query_records |
Auto-paginate past the 100-row API limit (up to max_rows), normalize keys to snake_case, canonicalize Indian State/District names, and auto-resolve unambiguous filters. |
aggregate_dataset |
Load filtered records into in-memory DuckDB and compute deterministic sum, avg, min, max, or count grouped by any column. |
join_on_geography |
Canonicalize Indian State/UT or District spelling variants across two datasets (e.g., Orissa ↔ Odisha, Bangalore ↔ Bengaluru) and inner-join via DuckDB. |
export_dataset |
Export normalized records locally to csv, json, or parquet (via DuckDB COPY ... TO) with path-traversal protection and an official citation. |
get_citation |
Generate a structured citation block with dataset title, resource_id, portal URL, applied filters, and ISO-8601 UTC retrieval timestamp. |
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 --help
Method 2: Install Globally via pip
pip install india-gov-data-mcp
python -m datagov_mcp.server --help
Method 3: Install from Source (GitHub)
git clone https://github.com/tirthharshi-debug/India-gov-data-MCP
cd India-gov-data-mcp
python -m venv .venv
Activate the virtual environment:
- Windows (PowerShell):
.venv\Scripts\Activate.ps1
- macOS / Linux:
source .venv/bin/activate
Install in editable mode with dev dependencies and run the test suite:
pip install -e ".[dev]"
pytest
Optional: 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 15
Connecting 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.json - macOS:
~/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.
Metadata
Release files for india-gov-data-mcp 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| india_gov_data_mcp-0.2.1.tar.gz | 32.3 kB | With provenance | Details for india_gov_data_mcp-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| india_gov_data_mcp-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for india_gov_data_mcp-0.2.1-py3-none-any.whl |
Total release size: 63.0 kB
Release files / india_gov_data_mcp-0.2.1.tar.gz
| Download URL | india_gov_data_mcp-0.2.1.tar.gz |
|---|---|
| Size | 32.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8194b3e301f1fef8d3bc6992bad3793fd80a57acd91da3bf3da4d7d763b8aa6b
|
|
BLAKE2b-256 checksum How to use checksums |
6488769f62bf36df6ff8d56f625b20cb133b4c50b39e7e113abb6bf2d8174f51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logRelease files / india_gov_data_mcp-0.2.1-py3-none-any.whl
| Download URL | india_gov_data_mcp-0.2.1-py3-none-any.whl |
|---|---|
| Size | 30.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17666f94ac152e2ff5ed19f840f5f397d87fc8d9d1409956ad2394e2a9f4ee92
|
|
BLAKE2b-256 checksum How to use checksums |
a9233bbda2a5db1d8acee1905af08370ad4a6f07a496492de8c13a378257ed6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logSecurity for india-gov-data-mcp 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for india_gov_data_mcp-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.