chicago-data-analyst
by gordlf11
README.md
# chicago-data-analyst
An MCP server that lets Claude (or Cursor, or any MCP client) read Chicago's open data and City
Council roll calls, straight from the source. Ask about crime, permits, 311, grants or a vote in
plain English; it queries the City of Chicago Data Portal and the City Clerk live, and the data
comes back with a citation to repeat. No account, no key, no telemetry.
Version 1.0.0. MIT licensed.
## Install
You need Python 3.12 or newer. The quickest path uses [`uv`](https://docs.astral.sh/uv/), which
fetches the right Python for you if you don't have it.
**a. Claude Code.** One line:
```bash
claude mcp add chicago -- uvx --from git+https://github.com/gordlf11/chicago-data-analyst chicago-data-analyst mcp
```
**b. Claude Desktop or Cursor, by config.** Add this to Claude Desktop's config
(Settings → Developer → Edit Config) or to Cursor's `~/.cursor/mcp.json`, then restart the app:
```json
{
"mcpServers": {
"chicago": {
"command": "uvx",
"args": [
"--from", "git+https://github.com/gordlf11/chicago-data-analyst",
"chicago-data-analyst", "mcp"
]
}
}
}
```
If the app says it can't find `uvx`, put the full path there instead (run `which uvx` to get it).
**c. Without `uv`.** Clone and install with pip (a virtual environment is a good idea):
```bash
git clone https://github.com/gordlf11/chicago-data-analyst
cd chicago-data-analyst
pip install .
```
Then use `chicago-data-analyst mcp` as the command — for example
`claude mcp add chicago -- chicago-data-analyst mcp`, or `"command": "chicago-data-analyst", "args": ["mcp"]`
in the config above.
To install `uv`: `brew install uv` on a Mac, or `curl -LsSf https://astral.sh/uv/install.sh | sh`.
**d. One-click bundle (Claude Desktop).** When a release carries a `.mcpb` file, you can download
it from this repo's [Releases page](https://github.com/gordlf11/chicago-data-analyst/releases)
and double-click it; Claude Desktop installs it for you. Until one is posted, use (b).
## Try these
1. How has reported crime moved in the 27th Ward over the last 12 months?
2. List the TIF-funded economic development projects in the 27th Ward.
3. Show me the roll call for O2022-883.
4. **A ward brief.** Pick a ward. Pull its crime, building permit and 311 trends, chart one of
them, then look up how its alderperson voted on a named ordinance.
5. **Follow the money.** List a ward's large Neighborhood Opportunity Fund grants. Pick one over
$250,000 — each of those was approved by City Council — find the ordinance that approved it,
and pull its roll call.
## The ten tools
| Tool | What it does |
|---|---|
| `list_categories` | Lists every category and subcategory, with how many watchlist datasets sit in each. |
| `list_datasets` | Lists the watchlist datasets in a category, optionally one subcategory. |
| `describe_dataset` | Describes one dataset: its metrics, geographies, related datasets, caveats and citation. |
| `search_dataset` | Searches the whole Chicago Data Portal by keyword, not just the watchlist. |
| `get_trend` | A time series for one dataset, citywide or for one area, with a period-over-period comparison. |
| `compare_datasets` | Compares two related datasets' trends over the same window. |
| `chart_figure` | Draws a chart (SVG plus its spec) of a dataset's trend. |
| `list_projects` | Lists the recipients of a grant or incentive program: who, which ward, when, how much, plus the count and dollar total. |
| `search_legislation` | Searches City Council legislation in the Clerk's record by keyword and date. |
| `get_roll_call` | Every recorded roll call on one matter: the tally and each member's vote, with ward. |
## The datasets
Fourteen datasets from the City of Chicago Data Portal.
**Public Safety**
- Crimes - 2001 to Present
**Transportation**
- Traffic Crashes
**Buildings**
- Building Permits
**Service Requests**
- 311 Service Requests
**Community & Economic Development**
- Business Licenses
- Grants & Incentives — seven Financial Incentive Projects tables:
- Neighborhood Opportunity Fund (NOF) Small
- Neighborhood Opportunity Fund (NOF) Large
- Small Business Improvement Fund (SBIF)
- TIF Works
- (TIF-Funded) Economic Development
- Property Tax Abatement - 2021-Current
- Property Tax Abatement - 2011-2022
**Health & Human Services**
- Food Inspections
**Administration & Finance**
- Budget - Appropriations (the 2024 budget)
`search_dataset` reaches the rest of the portal, so you can find other datasets by name. The trend
and chart tools work on these fourteen; `list_projects` works on the seven grant and incentive
tables.
## How it works
- **Live queries.** Each question goes to data.cityofchicago.org at the moment you ask. Results are
cached for one hour in `~/.chicago-data-analyst` (set `CHI_CACHE_DIR` to move it). Old cache files
are swept after seven days.
- **Council tools** read the City Clerk's eLMS (api.chicityclerkelms.chicago.gov) live.
- **Two hosts, nothing else.** Every request this tool makes goes to data.cityofchicago.org or
api.chicityclerkelms.chicago.gov. Portal search uses the portal's own catalog, too.
- **Citations.** `describe_dataset`, `get_trend`, `compare_datasets` (for each side) and
`list_projects` return a citation naming the dataset and its id. `get_roll_call` cites the Clerk's
record number; `search_legislation` cites the Clerk's eLMS. `chart_figure`'s spec names the dataset
it drew. The listing tools and `search_dataset` don't return one. Repeat the citation when you use
the number.
- **Caveats.** Most datasets carry notes on where they fall short: what they count, what they leave
out, which geographies they have. `describe_dataset` and `list_projects` return them; read them
before you quote a trend. Crimes, Building Permits and Business Licenses have none.
- **Partial periods.** `get_trend` returns `current_partial` and `last_complete`. The current month
is usually not over yet, so comparing it with a full month a year ago makes things look like they
dropped. When `current_partial` is true, quote `last_complete`.
- **The first roll call is slow.** On a fresh install, the first `get_roll_call` takes about 15
seconds: it looks up the ward for each of the ~50 members. Those lookups are cached for 30 days,
so later roll calls are much faster (the matter itself is still fetched live).
- **Searching legislation.** The Clerk's search matches any word and lists the newest first. So pass
a date — `on`, or `since`/`until` — whenever you know one. Searching "Morton Salt" with
`on=2022-03-23` returns O2022-883, which passed 48 Yea, 2 Absent.
## What is not here
The reviewed council scorecard. That's editorial work — I read the votes, decide what they mean and
publish that at [larryfgordon.com/chicago/council](https://larryfgordon.com/chicago/council).
This tool gives you the raw record so you can make your own read. `get_roll_call` returns the
Clerk's record as published. It doesn't say what a vote meant or whose side it was on.
## Limits
- Trends and charts cover the fourteen datasets above, not the whole portal. Project lists cover
the seven grant and incentive tables.
- Not every dataset has every geography. Food Inspections is by ZIP code only. Traffic Crashes is by
police beat only. The grant tables are by ward only.
- Some tables are stale. The portal last updated NOF Large and (TIF-Funded) Economic Development in
2023. The grant tables list a project only after its final payment.
- The budget is the 2024 appropriations only.
- `list_projects` doesn't return an ordinance number. To get from a grant to its vote, search the
legislation by name with the approval date.
- There's no "everything Ward N voted on" call. Search for the matter, then pull its roll call.
- Ward lookups on a roll call get 40 seconds. If some wards come back empty, ask again and they fill
in.
- Data can arrive late or be revised. A number you read today can change tomorrow.
- Without a token, the portal may throttle heavy use. See the next section.
## Optional: a Socrata app token
You don't need one. If you hit rate limits, create a token in your account's developer settings on
data.cityofchicago.org. It gives you a key id and a key secret. Pass them as environment variables:
```bash
claude mcp add chicago -e SOCRATA_KEY_ID=your-key-id -e SOCRATA_KEY_SECRET=your-key-secret \
-- uvx --from git+https://github.com/gordlf11/chicago-data-analyst chicago-data-analyst mcp
```
In a JSON config, add `"env": {"SOCRATA_KEY_ID": "...", "SOCRATA_KEY_SECRET": "..."}` next to
`"args"`.
## License
MIT — see [LICENSE](LICENSE). The data belongs to the City of Chicago; see [NOTICE.md](NOTICE.md)
for sources and terms. This project is not affiliated with or endorsed by the City. The data is
evidence, not advice.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues