Skip to main content
Glama
README.md
# Neta MCP

**Ask an AI about any Indian MP and get answers from real parliamentary records, with sources.**

> "Who raised NEET in Parliament?" ยท "Give me the report card of my MP from Jorhat." ยท
> "Compare Supriya Sule and Gaurav Gogoi." ยท "Do MPs in safe seats work less?"

Neta MCP is a [Model Context Protocol](https://modelcontextprotocol.io) server and web API
covering all **540 sitting MPs of the 18th Lok Sabha**. It joins three public sources into
one dataset:

| | |
|---|---|
| ๐Ÿ“‹ **57,717 questions** and **10,400 debate entries**, every one with its title and date | PRS Legislative Research |
| ๐Ÿ—“๏ธ Attendance overall **and per session**, with national and state averages | PRS Legislative Research |
| โš–๏ธ Declared criminal cases, assets, liabilities and education (2024 affidavits) | MyNeta / ADR |
| ๐Ÿ—ณ๏ธ 2024 winning margin and runner-up | Election Commission of India |

Parliament data covers 24 June 2024 to 13 August 2026. See [data/SOURCES.md](data/SOURCES.md)
for licences, the known gaps and how to rebuild the data.

## What makes it different

Most MP trackers show one number per MP. Neta lets you ask **what MPs actually talk about**
and **how the numbers relate**:

| Tool | What it answers |
|---|---|
| `search_parliament` | **Who raised a topic?** It searches all 68,000 question and debate titles. E.g. *NEET*: 56 MPs raised it, and 23 of them are from Congress. |
| `report_card` | One MP compared with the national and state averages: attendance **session by session**, which ministries they question most, their affidavit and their margin |
| `home_focus_pct` | A new measure: how often an MP's questions and debates name **their own constituency or state** (median: 15.9%) |
| `safe_seat_effect` | Do MPs who won narrowly work harder? (Finding below) |
| `compare_mps` | Two MPs side by side, showing who leads on each measure |
| `rank_mps`, `party_summary`, `state_summary`, `find_mp`, `mps_in_state` | Rankings and averages, filtered by state or party |

### First findings

- **A safe seat doesn't make MPs lazier, and a close one doesn't make them work harder.**
  The correlation between winning margin and attendance is โˆ’0.03, close to zero. MPs who won
  by less than 25,000 votes and MPs who won by more than 2.5 lakh both average 88% attendance.
- Median attendance is **90%**, but **17 MPs** attended fewer than half the sittings. Among MPs
  whose activity PRS tracks, **18** asked no questions at all.
- **218 of the 478 MPs** with affidavit data declared at least one pending criminal case.
  These are cases the MPs declared themselves, not convictions.

## Built carefully

- **Ministers aren't penalised.** Ministers (57 of them) and the Leader of Opposition don't sign
  the attendance register or ask questions. Their activity is marked *not tracked*, never 0%.
- **No wrong matches.** Affidavit and election data are attached only when the seat **and** the
  person's name both match. By-election winners are detected from their term-start date.
  For example, at Nanded the son replaced his late father, and their names share two words.
  Tests guard all of this.
- **Every answer carries its sources and caveats**, so the AI can cite them.

## How it works

```
You ask a question โ”€โ”€โ–บ AI assistant โ”€โ”€โ–บ server.py (MCP tools)     โ”
                                                                  โ”œโ”€โ”€โ–บ neta/data.py (pandas) โ”€โ”€โ–บ data/*.csv
A website / app   โ”€โ”€โ–บ api.py (FastAPI, /docs)                     โ”˜
                                                                      โ–ฒ
                       scripts/fetch_*.py โ”€โ”€โ–บ scripts/build_dataset.pyโ”˜   (PRS ยท MyNeta ยท ECI)
```

| File | What it does |
|---|---|
| `neta/data.py` | All the logic, in plain pandas. Start reading here. |
| `server.py` | Exposes those functions as MCP tools for Claude and other assistants |
| `api.py` | The same functions as a web API |
| `explore.py` | Prints some findings, with no AI involved |
| `scripts/` | Downloads the sources and builds the CSVs |
| `test_data.py`, `test_api.py` | 24 automated checks |

## Setup (Windows)

```powershell
cd neta-mcp
python -m venv .venv
.\.venv\Scripts\python -m pip install -r requirements.txt
.\.venv\Scripts\python explore.py       # see the findings
.\.venv\Scripts\python -m pytest        # run the tests
```

**Use it with Claude Code:** open Claude Code inside this folder and approve the `neta` server
(configured in `.mcp.json`). Then ask, for example: *"Using the neta tools, who in Bihar raised
floods the most?"*

**Use the web API:**

```powershell
.\.venv\Scripts\python -m uvicorn api:app --reload
```

Then open <http://127.0.0.1:8000/docs> to try every endpoint in the browser.

## Roadmap

- [x] Real data from PRS, MyNeta and ECI, with sources recorded
- [x] MCP server: report cards, topic search, comparisons, the safe-seat analysis
- [x] FastAPI web API
- [ ] A simple website: "find your MP" by PIN code
- [ ] Topic trends over time (e.g. how often "unemployment" comes up each session)
- [ ] Rajya Sabha and state MLAs

## Credits and licence

Code: MIT. Parliament data: [PRS Legislative Research](https://prsindia.org/mptrack) (CC BY 4.0).
Affidavit data: [MyNeta / ADR](https://myneta.info). Election results: ECI via
[OpenCity](https://data.opencity.in). This project isn't affiliated with any of them.