OpenGovtData-MCP / README.md
sakasurya's picture
Release
6abd773 verified
|
Raw History Blame Contribute Delete
5.67 kB
---
license: cc-by-nc-sa-4.0
title: OpenGovtData-MCP
sdk: docker
app_port: 7860
short_description: MCP server + HTTP API over India open government data tables
emoji: ๐Ÿ“Š
colorFrom: indigo
colorTo: green
pinned: false
tags:
- mcp
- india
- open-government-data
- tables
---
# OpenGovtData-MCP
<!-- jm:top -->
Licence: CC BY-NC-SA 4.0 โ€” research and non-commercial use only; derivatives must be shared under the same licence. Commercial use: contact surya@judicialmind.ai or hello@judicialmind.ai
<!-- /jm:top -->
MCP server and HTTP API over [IndiaTables](https://huggingface.co/datasets/judicialmind/IndiaTables)
(data.gov.in + NITI Aayog NDAP, snapshot May 2026). Tools: `search_tables`, `describe_table`, `query_table`
(one read-only DuckDB `SELECT`, row cap, timeout, no file or network access) and `cite`. Every answer carries
the snapshot date and a completeness flag (complete / truncated / duplicated / metadata_only).
This Space bundles a demo subset (`demo_store/`, see `demo_store/demo_info.json`): 1,000 small, complete tables
without personal-data columns, balanced across 226 ministries. Search here is keyword search over the table cards.
## Quickstart
MCP clients (streamable HTTP): add `https://<space-host>/mcp` as a server, e.g. in a client config
```json
{"mcpServers": {"ogd": {"url": "https://<space-host>/mcp"}}}
```
HTTP API: input = a query string or one SQL statement naming tables by uuid in double quotes; output = JSON with
`snapshot`, `results` / `rows` and per-table `completeness` and `attribution`.
```python
import requests
BASE = "https://<space-host>" # or http://localhost:7860 when running the container locally
print(requests.get(f"{BASE}/").json()) # {"name": "OpenGovtData-MCP", "demo_tables": 1000, ...}
hits = requests.get(f"{BASE}/search", params={"q": "rainfall district", "k": 3}).json()["results"]
for h in hits:
print(h["uuid"], h["title"], h["completeness"])
uuid = hits[0]["uuid"]
print(requests.get(f"{BASE}/describe/{uuid}").json()["table"]["columns"][:3])
rows = requests.post(f"{BASE}/query", json={"sql": f'SELECT * FROM "{uuid}" LIMIT 3'}).json()
print(rows["columns"], rows["rows"])
print(requests.get(f"{BASE}/cite/{uuid}").json()["cite"]["attribution"])
```
Endpoints: `GET /search?q=&k=&state=&district=&year=&ministry=&level=`, `GET /describe/<uuid>`,
`GET /cite/<uuid>`, `POST /query` with `{"sql": "SELECT * FROM \"<uuid>\" LIMIT 5", "max_rows": 200}`,
`GET /health`; OpenAPI at `/docs`.
Run the Space locally:
```bash
git clone https://huggingface.co/spaces/judicialmind/OpenGovtData-MCP && cd OpenGovtData-MCP
docker build -t ogd-mcp . && docker run -p 7860:7860 ogd-mcp
# or without Docker:
pip install -r requirements.txt && uvicorn app:app --port 7860
```
## Full index (local)
The same server runs over the full IndiaTables store (266,707 tables) with hybrid BM25 + IndiaTables-Embed-0.6B
search:
```bash
huggingface-cli download judicialmind/IndiaTables --repo-type dataset --local-dir store
pip install -r requirements.txt bm25s sentence-transformers
python -m ogd.mcp.index --store store --out index --model judicialmind/IndiaTables-Embed-0.6B # GPU recommended
python -m ogd.mcp.server --store store --index index --transport stdio # or streamable-http / http-api --port 8000
```
Without `--model` the index is BM25 only (CPU, a few minutes). `python -m ogd.mcp.server --store store --dry-run`
runs every tool once and prints a JSON summary.
## Files
| File | What |
|---|---|
| `app.py`, `Dockerfile`, `requirements.txt` | The Space: FastAPI routes + MCP streamable HTTP at `/mcp` |
| `ogd/mcp/core.py` | Backend: search, describe, read-only SQL (DuckDB), cite |
| `ogd/mcp/server.py` | MCP server (stdio / streamable HTTP) and the FastAPI app |
| `ogd/mcp/index.py` | BM25 + dense index over IndiaTables cards |
| `ogd/common/attribution.py` | GODL-India attribution strings |
| `demo_store/` | `catalog.parquet`, `cards.parquet` and `tables/` for the 1,000 demo tables |
## Source data
Demo tables and catalog rows from IndiaTables: published on the Open Government Data Platform India
(data.gov.in) and NITI Aayog's NDAP, snapshot May 2026. Each table's provider, title and resource URL are in
the `attribution` column and in every `cite` / `query` response.
<!-- jm:source -->
Original data: published by the ministries, departments and State governments named per table in the `attribution` column on the Open Government Data Platform India ([data.gov.in](https://data.gov.in)) and, where marked, NITI Aayog's National Data and Analytics Platform ([NDAP](https://ndap.niti.gov.in)), under the [Government Open Data License - India](https://data.gov.in/government-open-data-license-india) (GODL-India). The original public data remains under GODL-India; the CC BY-NC-SA 4.0 licence of this repository covers JudicialMind's compilation, derived fields, annotations, benchmarks and models.
<!-- /jm:source -->
## Citation
```bibtex
@misc{judicialmind2026ogdmcp,
title={OpenGovtData-MCP: an MCP server over India's open government data tables},
author={JudicialMind},
year={2026},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/spaces/judicialmind/OpenGovtData-MCP}}
}
```
<!-- jm:license -->
## License
[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/) (see `LICENSE`): research, academic, personal and other non-commercial use, with attribution to JudicialMind and to the original data publishers; adaptations must be shared under the same licence. Commercial use requires a separate licence.
Commercial use: contact surya@judicialmind.ai or hello@judicialmind.ai.
<!-- /jm:license -->