hmis-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hmis_mcp-0.1.0/LICENSE +14 -0
- hmis_mcp-0.1.0/PKG-INFO +319 -0
- hmis_mcp-0.1.0/README.md +298 -0
- hmis_mcp-0.1.0/pyproject.toml +43 -0
- hmis_mcp-0.1.0/pyproject.toml.orig +38 -0
- hmis_mcp-0.1.0/src/hmis_mcp/__init__.py +3 -0
- hmis_mcp-0.1.0/src/hmis_mcp/auth.py +265 -0
- hmis_mcp-0.1.0/src/hmis_mcp/codes.py +156 -0
- hmis_mcp-0.1.0/src/hmis_mcp/engine.py +349 -0
- hmis_mcp-0.1.0/src/hmis_mcp/model.py +363 -0
- hmis_mcp-0.1.0/src/hmis_mcp/privacy.py +132 -0
- hmis_mcp-0.1.0/src/hmis_mcp/sample.py +224 -0
- hmis_mcp-0.1.0/src/hmis_mcp/server.py +320 -0
- hmis_mcp-0.1.0/src/hmis_mcp/source.py +188 -0
hmis_mcp-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
BSD Zero Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2026 by the hmis-mcp contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
+
PERFORMANCE OF THIS SOFTWARE.
|
hmis_mcp-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hmis-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Aggregate-only MCP server for HMIS data: reports and analytics without exporting PII
|
|
5
|
+
Keywords: mcp,hmis,homelessness,hud,privacy,disclosure-control
|
|
6
|
+
License-Expression: 0BSD
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Information Technology
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
15
|
+
Requires-Dist: duckdb>=1.1
|
|
16
|
+
Requires-Dist: mcp>=2,<3
|
|
17
|
+
Requires-Python: >=3.12
|
|
18
|
+
Project-URL: Repository, https://github.com/dan-blanchard/hmis-mcp
|
|
19
|
+
Project-URL: Issues, https://github.com/dan-blanchard/hmis-mcp/issues
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# hmis-mcp
|
|
23
|
+
|
|
24
|
+
An MCP server that lets an AI agent answer questions about an agency's HMIS data
|
|
25
|
+
(how many people a shelter served, where they exited to, how full the beds were)
|
|
26
|
+
while only ever seeing aggregate numbers. The agent cannot retrieve a name, an
|
|
27
|
+
SSN, a birth date, a client ID, or a row about one person, because the server
|
|
28
|
+
has no tool that returns them and small counts are suppressed.
|
|
29
|
+
|
|
30
|
+
It reads the HUD HMIS CSV export, which every HMIS vendor is required to
|
|
31
|
+
produce, so it is not tied to one vendor or one state: WellSky Community
|
|
32
|
+
Services, Bitfocus Clarity, ClientTrack and the rest all export it.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
The only thing you install yourself is [uv](https://docs.astral.sh/uv/), a
|
|
37
|
+
small tool that fetches Python and this server when they are needed. There is
|
|
38
|
+
nothing to clone and no Python to set up. This works the same on Windows, macOS
|
|
39
|
+
and Linux.
|
|
40
|
+
|
|
41
|
+
On Windows, in PowerShell:
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
On macOS or Linux:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Open a new terminal afterwards so the `uvx` command is found. Then make a
|
|
54
|
+
synthetic export and check that the server can read it:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp sample hmis-sample
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp check --export hmis-sample
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`check` prints the export's layout, its date range and a few totals, then `OK`.
|
|
65
|
+
It never prints client data. For real data, run your HMIS's HUD CSV export for
|
|
66
|
+
your agency's projects and give `check` the zip or the folder instead.
|
|
67
|
+
|
|
68
|
+
To pick up a newer version later, add `--refresh` right after `uvx`.
|
|
69
|
+
|
|
70
|
+
### If you are an AI agent installing this for someone
|
|
71
|
+
|
|
72
|
+
1. Run `uvx --version`. If it is missing, ask before installing uv with the
|
|
73
|
+
command above for their operating system.
|
|
74
|
+
2. Ask where their HMIS CSV export is (a zip or a folder). Do not open, list,
|
|
75
|
+
print or read the export yourself. It holds client names, birth dates and
|
|
76
|
+
Social Security numbers, and keeping those out of your context is the point
|
|
77
|
+
of this server. Only pass its path along.
|
|
78
|
+
3. Run the `check` command above with that path. It prints counts only. If it
|
|
79
|
+
fails, show the person the message and stop.
|
|
80
|
+
4. Add the server to your own MCP configuration using the block under
|
|
81
|
+
"Agents that run a local command". Use absolute paths. In JSON on Windows,
|
|
82
|
+
write paths with forward slashes (`C:/Users/name/export.zip`).
|
|
83
|
+
5. If the app reports that `uvx` can't be found, which happens with desktop
|
|
84
|
+
apps that don't inherit the terminal's PATH, replace `"uvx"` with its full
|
|
85
|
+
path: `where uvx` on Windows, `which uvx` elsewhere.
|
|
86
|
+
6. Reload your MCP servers and call `describe_dataset` to confirm it answers.
|
|
87
|
+
7. Leave the HTTP transport and tunnels alone unless the person asks for them.
|
|
88
|
+
|
|
89
|
+
## Supported export formats
|
|
90
|
+
|
|
91
|
+
HUD has revised the CSV format three times since October 2021, and all three
|
|
92
|
+
revisions load:
|
|
93
|
+
|
|
94
|
+
| Revision | In effect from | What differs |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| FY2026 | October 2025 | `Sex` replaces the gender columns |
|
|
97
|
+
| FY2024 | October 2023 | Gender as `Woman`, `Man`, `NonBinary` and others; Hispanic/Latina/e/o is one of the race flags; three-digit living situation codes; two emergency shelter project types |
|
|
98
|
+
| FY2022 | October 2021 | Gender as `Female`, `Male`, `NoSingleGender`; a separate `Ethnicity` column; one- and two-digit living situation codes; one emergency shelter type plus `TrackingMethod`; CoC in `EnrollmentCoC.csv` |
|
|
99
|
+
|
|
100
|
+
The revision is read from the Client.csv header, not from the `CSVVersion` a
|
|
101
|
+
vendor wrote in Export.csv, and `describe_dataset` reports it. If the two
|
|
102
|
+
disagree the server says so. FY2022 data is translated into the current code
|
|
103
|
+
lists using the same crosswalk as HUD Data Lab's FY2022-to-FY2024 conversion,
|
|
104
|
+
so a question gets the same answer whichever revision the export is in. Two
|
|
105
|
+
things can't be recovered from an FY2022 export: which kind of rental subsidy
|
|
106
|
+
someone had (seven old codes became one), and Middle Eastern or North African
|
|
107
|
+
as a race, which FY2022 didn't collect.
|
|
108
|
+
|
|
109
|
+
FY2020 and earlier exports are refused with a message saying so. If detection
|
|
110
|
+
fails on an export you know is supported, pass `--csv-version 2022`, `2024` or
|
|
111
|
+
`2026`.
|
|
112
|
+
|
|
113
|
+
## Connecting agents
|
|
114
|
+
|
|
115
|
+
There are two ways in, and which one you need depends on whether the agent can
|
|
116
|
+
start a program on your computer.
|
|
117
|
+
|
|
118
|
+
### Agents that run a local command (stdio)
|
|
119
|
+
|
|
120
|
+
Claude Code, Claude Desktop, Codex CLI, Gemini CLI, Cursor and VS Code all
|
|
121
|
+
launch the server themselves. Nothing listens on the network. They all want the
|
|
122
|
+
same two facts, a command and its arguments, and differ only in which file
|
|
123
|
+
holds them:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"mcpServers": {
|
|
128
|
+
"hmis": {
|
|
129
|
+
"command": "uvx",
|
|
130
|
+
"args": [
|
|
131
|
+
"--from", "https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip",
|
|
132
|
+
"hmis-mcp", "--export", "/absolute/path/to/export.zip"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| Agent | Where it goes |
|
|
140
|
+
|---|---|
|
|
141
|
+
| Claude Desktop | `claude_desktop_config.json` |
|
|
142
|
+
| Claude Code | `claude mcp add hmis -- uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp --export /absolute/path/to/export.zip` |
|
|
143
|
+
| Cursor | `.cursor/mcp.json` |
|
|
144
|
+
| Gemini CLI | `~/.gemini/settings.json` |
|
|
145
|
+
| VS Code | `.vscode/mcp.json`, with the top-level key `servers` instead of `mcpServers` |
|
|
146
|
+
| Codex CLI | `~/.codex/config.toml`, as a `[mcp_servers.hmis]` table with `command` and `args` |
|
|
147
|
+
|
|
148
|
+
These file locations change between releases. If one doesn't work, check that
|
|
149
|
+
agent's MCP documentation; the command and args stay the same.
|
|
150
|
+
|
|
151
|
+
### Agents that connect to a URL (HTTP)
|
|
152
|
+
|
|
153
|
+
ChatGPT cannot start a local program. Its servers call yours, so the server
|
|
154
|
+
needs a public `https://` address. The same goes for the OpenAI Responses API
|
|
155
|
+
and most hosted agent platforms.
|
|
156
|
+
|
|
157
|
+
Make a secret. This writes it to a file in your home folder, readable only by
|
|
158
|
+
you on macOS and Linux, and by whoever can read your user profile on Windows:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp secret --out ~/.hmis-mcp-secret
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Give the server a public address. The server itself stays bound to
|
|
165
|
+
`127.0.0.1`; a tunnel carries HTTPS traffic to it. With Cloudflare's:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
cloudflared tunnel --url http://127.0.0.1:8000
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
That prints an address like `https://something.trycloudflare.com`. Start the
|
|
172
|
+
server with it:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp --export /absolute/path/to/export.zip --transport http --public-url https://something.trycloudflare.com --secret-file ~/.hmis-mcp-secret
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The MCP endpoint is the public address plus `/mcp`.
|
|
179
|
+
|
|
180
|
+
**ChatGPT.** Add a custom MCP server in ChatGPT's settings (OpenAI has moved
|
|
181
|
+
this menu more than once; look under connectors, apps or plugins), give it the
|
|
182
|
+
`/mcp` URL, and choose OAuth. ChatGPT registers itself and sends your browser
|
|
183
|
+
to this server's approval page. Paste the secret there. Tokens refresh on their
|
|
184
|
+
own after that, and approvals survive a restart.
|
|
185
|
+
|
|
186
|
+
**Agents that send headers.** Use the secret as a bearer token:
|
|
187
|
+
`Authorization: Bearer <secret>`. For the OpenAI Responses API that is an `mcp`
|
|
188
|
+
tool with `server_url` set to the `/mcp` URL and `authorization` set to the
|
|
189
|
+
secret.
|
|
190
|
+
|
|
191
|
+
The server will not start on HTTP without a secret unless you pass `--no-auth`,
|
|
192
|
+
and it accepts `--no-auth` only on a loopback address with no public URL.
|
|
193
|
+
|
|
194
|
+
Before you expose this, understand what changes. Over stdio, aggregates go to
|
|
195
|
+
whichever model your local agent uses. Over HTTP with ChatGPT, they go to
|
|
196
|
+
OpenAI, and anyone who obtains the secret can query your agency's statistics
|
|
197
|
+
from anywhere. No client-level data is reachable either way, but aggregate
|
|
198
|
+
numbers about a small shelter are still your agency's data. Stop the tunnel
|
|
199
|
+
when you are not using it.
|
|
200
|
+
|
|
201
|
+
## Options
|
|
202
|
+
|
|
203
|
+
| Option | Env var | Default | |
|
|
204
|
+
|---|---|---|---|
|
|
205
|
+
| `--export` | `HMIS_EXPORT_PATH` | required | Export directory or zip |
|
|
206
|
+
| `--min-cell-size` | `HMIS_MIN_CELL_SIZE` | 11 | Smallest client count released. Floor is 5. |
|
|
207
|
+
| `--csv-version` | `HMIS_CSV_VERSION` | detected | Force the HUD CSV revision: 2022, 2024 or 2026 |
|
|
208
|
+
| `--audit-log` | `HMIS_AUDIT_LOG` | off | One JSON line per query: the request and how many cells were released or suppressed. No results. |
|
|
209
|
+
| `--transport` | `HMIS_MCP_TRANSPORT` | `stdio` | `stdio` or `http` |
|
|
210
|
+
| `--host`, `--port` | | `127.0.0.1`, `8000` | Where the HTTP transport listens |
|
|
211
|
+
| `--public-url` | `HMIS_MCP_PUBLIC_URL` | | The `https://` address clients use |
|
|
212
|
+
| `--secret-file` | `HMIS_MCP_SECRET` (the secret itself) | | Access secret, at least 24 characters |
|
|
213
|
+
| `--state-file` | `HMIS_MCP_STATE` | `~/.hmis-mcp/oauth-state.json` | Approved clients and token hashes |
|
|
214
|
+
|
|
215
|
+
## Tools
|
|
216
|
+
|
|
217
|
+
- `describe_dataset`: export period, privacy rules, and every valid measure,
|
|
218
|
+
cohort, dimension and dimension value.
|
|
219
|
+
- `list_projects`: project names, types, organizations, bed inventory.
|
|
220
|
+
- `query_aggregate`: counts of clients, enrollments or households, and mean or
|
|
221
|
+
median length of stay, broken down by up to three dimensions, with filters, a
|
|
222
|
+
cohort (active, entered, exited) and a reporting period.
|
|
223
|
+
- `bed_utilization`: monthly bed nights and utilization per project.
|
|
224
|
+
|
|
225
|
+
Dimensions cover project, organization, project type, CoC, age group,
|
|
226
|
+
race/ethnicity, sex (FY2026) or gender (FY2024), veteran status, household
|
|
227
|
+
type, relationship to head of household, disabling condition, DV survivor
|
|
228
|
+
status, prior living situation, exit destination, length of stay, income at
|
|
229
|
+
entry, and entry/exit month, quarter and year.
|
|
230
|
+
|
|
231
|
+
The agent picks from that vocabulary. It never writes SQL.
|
|
232
|
+
|
|
233
|
+
## How the privacy protection works
|
|
234
|
+
|
|
235
|
+
Threat model first, because it determines what the rest is worth. The person
|
|
236
|
+
running this server already holds the export and is authorized to see it. The
|
|
237
|
+
thing being protected against is client data reaching a model provider, a chat
|
|
238
|
+
transcript, or a generated report. The server is not built to stop a determined
|
|
239
|
+
insider with unlimited queries from learning something about a client; that
|
|
240
|
+
person can open the CSV.
|
|
241
|
+
|
|
242
|
+
Within that model:
|
|
243
|
+
|
|
244
|
+
1. Names, SSNs and free-text fields are never read into the database. Each CSV
|
|
245
|
+
has a column allowlist and those columns are not on it.
|
|
246
|
+
2. Birth dates and a per-client index stay in the in-memory database, because
|
|
247
|
+
ages and distinct counts need them, but no tool returns them. Ages come out
|
|
248
|
+
as bands and dates as months.
|
|
249
|
+
3. Any cell covering fewer than 11 clients is suppressed. Eleven is the CMS
|
|
250
|
+
convention; you can change it, down to 5.
|
|
251
|
+
4. If one suppressed cell on a row or column could be recovered by subtracting
|
|
252
|
+
the others from a total, a second cell is suppressed as well.
|
|
253
|
+
5. The server remembers which client groups it has already answered about. A
|
|
254
|
+
later query whose group differs from an earlier one by fewer than 11 clients,
|
|
255
|
+
with one containing the other, is refused. That blocks the "everyone, then
|
|
256
|
+
everyone except the people who entered on March 3rd" trick.
|
|
257
|
+
6. Unexpected errors return a generic message, so a database error can't carry
|
|
258
|
+
data out.
|
|
259
|
+
7. Over HTTP, every request needs the access secret or a token issued after
|
|
260
|
+
someone typed it into the approval page. Only hashes of issued tokens are
|
|
261
|
+
stored. Ten wrong guesses lock the approval page for ten minutes.
|
|
262
|
+
|
|
263
|
+
Known limits, stated plainly:
|
|
264
|
+
|
|
265
|
+
- The differencing check is pairwise and lives in memory. Restarting the server
|
|
266
|
+
clears it, and an attack that combines three or more overlapping queries can
|
|
267
|
+
get past it.
|
|
268
|
+
- Attribute disclosure is not addressed. If all 14 clients in some cell share a
|
|
269
|
+
sensitive attribute, a breakdown will show that. Anyone who knows a person is
|
|
270
|
+
in the cell learns the attribute.
|
|
271
|
+
- A suppressed cell still shows that between 1 and 10 clients are in it.
|
|
272
|
+
- Small projects will see a lot of suppression on detailed breakdowns. That is
|
|
273
|
+
the rule working. Use coarser dimensions or longer periods.
|
|
274
|
+
|
|
275
|
+
Have your HMIS lead review this before using it on real data. HUD has said
|
|
276
|
+
publicly that general-purpose AI tools are not appropriate for client data, and
|
|
277
|
+
your CoC's privacy policy may have its own rules about AI and about minimum
|
|
278
|
+
cell sizes.
|
|
279
|
+
|
|
280
|
+
## What the numbers mean
|
|
281
|
+
|
|
282
|
+
These are counts from your export, not certified HUD reports. Where they can
|
|
283
|
+
differ from an APR or CAPER:
|
|
284
|
+
|
|
285
|
+
- Age is taken at the later of entry or period start, as HUD reports do.
|
|
286
|
+
- Household type is computed from members' ages at entry.
|
|
287
|
+
- Length of stay runs from entry to exit, or to the period end for people still
|
|
288
|
+
enrolled. It does not use move-in dates.
|
|
289
|
+
- Bed utilization uses entry and exit dates, move-in dates for permanent
|
|
290
|
+
housing, and bed-night records for night-by-night shelters.
|
|
291
|
+
- Chronic homelessness is not implemented.
|
|
292
|
+
|
|
293
|
+
## Adding a live backend
|
|
294
|
+
|
|
295
|
+
`hmis_mcp.source.DataSource` is the seam. A source fills `raw_*` tables using
|
|
296
|
+
HUD CSV column names, and everything after that is shared. WellSky does not
|
|
297
|
+
publish API documentation, so a live backend needs an arrangement with WellSky
|
|
298
|
+
or your HMIS lead before it can be written.
|
|
299
|
+
|
|
300
|
+
## Development
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
git clone https://github.com/dan-blanchard/hmis-mcp
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
cd hmis-mcp && uv run pytest
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
The tests build a synthetic export with planted names and SSNs, run every tool
|
|
311
|
+
across every dimension, and fail if any planted value appears in any output.
|
|
312
|
+
They also write the same population in each supported HUD CSV revision and
|
|
313
|
+
require identical answers, check that tool schemas avoid the JSON Schema
|
|
314
|
+
features some model providers reject, and drive the HTTP transport through a
|
|
315
|
+
full OAuth sign-in. CI runs them on Windows, macOS and Linux.
|
|
316
|
+
|
|
317
|
+
## License
|
|
318
|
+
|
|
319
|
+
0BSD. Do what you like with it; no attribution needed.
|
hmis_mcp-0.1.0/README.md
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# hmis-mcp
|
|
2
|
+
|
|
3
|
+
An MCP server that lets an AI agent answer questions about an agency's HMIS data
|
|
4
|
+
(how many people a shelter served, where they exited to, how full the beds were)
|
|
5
|
+
while only ever seeing aggregate numbers. The agent cannot retrieve a name, an
|
|
6
|
+
SSN, a birth date, a client ID, or a row about one person, because the server
|
|
7
|
+
has no tool that returns them and small counts are suppressed.
|
|
8
|
+
|
|
9
|
+
It reads the HUD HMIS CSV export, which every HMIS vendor is required to
|
|
10
|
+
produce, so it is not tied to one vendor or one state: WellSky Community
|
|
11
|
+
Services, Bitfocus Clarity, ClientTrack and the rest all export it.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
The only thing you install yourself is [uv](https://docs.astral.sh/uv/), a
|
|
16
|
+
small tool that fetches Python and this server when they are needed. There is
|
|
17
|
+
nothing to clone and no Python to set up. This works the same on Windows, macOS
|
|
18
|
+
and Linux.
|
|
19
|
+
|
|
20
|
+
On Windows, in PowerShell:
|
|
21
|
+
|
|
22
|
+
```powershell
|
|
23
|
+
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
On macOS or Linux:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Open a new terminal afterwards so the `uvx` command is found. Then make a
|
|
33
|
+
synthetic export and check that the server can read it:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp sample hmis-sample
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp check --export hmis-sample
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`check` prints the export's layout, its date range and a few totals, then `OK`.
|
|
44
|
+
It never prints client data. For real data, run your HMIS's HUD CSV export for
|
|
45
|
+
your agency's projects and give `check` the zip or the folder instead.
|
|
46
|
+
|
|
47
|
+
To pick up a newer version later, add `--refresh` right after `uvx`.
|
|
48
|
+
|
|
49
|
+
### If you are an AI agent installing this for someone
|
|
50
|
+
|
|
51
|
+
1. Run `uvx --version`. If it is missing, ask before installing uv with the
|
|
52
|
+
command above for their operating system.
|
|
53
|
+
2. Ask where their HMIS CSV export is (a zip or a folder). Do not open, list,
|
|
54
|
+
print or read the export yourself. It holds client names, birth dates and
|
|
55
|
+
Social Security numbers, and keeping those out of your context is the point
|
|
56
|
+
of this server. Only pass its path along.
|
|
57
|
+
3. Run the `check` command above with that path. It prints counts only. If it
|
|
58
|
+
fails, show the person the message and stop.
|
|
59
|
+
4. Add the server to your own MCP configuration using the block under
|
|
60
|
+
"Agents that run a local command". Use absolute paths. In JSON on Windows,
|
|
61
|
+
write paths with forward slashes (`C:/Users/name/export.zip`).
|
|
62
|
+
5. If the app reports that `uvx` can't be found, which happens with desktop
|
|
63
|
+
apps that don't inherit the terminal's PATH, replace `"uvx"` with its full
|
|
64
|
+
path: `where uvx` on Windows, `which uvx` elsewhere.
|
|
65
|
+
6. Reload your MCP servers and call `describe_dataset` to confirm it answers.
|
|
66
|
+
7. Leave the HTTP transport and tunnels alone unless the person asks for them.
|
|
67
|
+
|
|
68
|
+
## Supported export formats
|
|
69
|
+
|
|
70
|
+
HUD has revised the CSV format three times since October 2021, and all three
|
|
71
|
+
revisions load:
|
|
72
|
+
|
|
73
|
+
| Revision | In effect from | What differs |
|
|
74
|
+
|---|---|---|
|
|
75
|
+
| FY2026 | October 2025 | `Sex` replaces the gender columns |
|
|
76
|
+
| FY2024 | October 2023 | Gender as `Woman`, `Man`, `NonBinary` and others; Hispanic/Latina/e/o is one of the race flags; three-digit living situation codes; two emergency shelter project types |
|
|
77
|
+
| FY2022 | October 2021 | Gender as `Female`, `Male`, `NoSingleGender`; a separate `Ethnicity` column; one- and two-digit living situation codes; one emergency shelter type plus `TrackingMethod`; CoC in `EnrollmentCoC.csv` |
|
|
78
|
+
|
|
79
|
+
The revision is read from the Client.csv header, not from the `CSVVersion` a
|
|
80
|
+
vendor wrote in Export.csv, and `describe_dataset` reports it. If the two
|
|
81
|
+
disagree the server says so. FY2022 data is translated into the current code
|
|
82
|
+
lists using the same crosswalk as HUD Data Lab's FY2022-to-FY2024 conversion,
|
|
83
|
+
so a question gets the same answer whichever revision the export is in. Two
|
|
84
|
+
things can't be recovered from an FY2022 export: which kind of rental subsidy
|
|
85
|
+
someone had (seven old codes became one), and Middle Eastern or North African
|
|
86
|
+
as a race, which FY2022 didn't collect.
|
|
87
|
+
|
|
88
|
+
FY2020 and earlier exports are refused with a message saying so. If detection
|
|
89
|
+
fails on an export you know is supported, pass `--csv-version 2022`, `2024` or
|
|
90
|
+
`2026`.
|
|
91
|
+
|
|
92
|
+
## Connecting agents
|
|
93
|
+
|
|
94
|
+
There are two ways in, and which one you need depends on whether the agent can
|
|
95
|
+
start a program on your computer.
|
|
96
|
+
|
|
97
|
+
### Agents that run a local command (stdio)
|
|
98
|
+
|
|
99
|
+
Claude Code, Claude Desktop, Codex CLI, Gemini CLI, Cursor and VS Code all
|
|
100
|
+
launch the server themselves. Nothing listens on the network. They all want the
|
|
101
|
+
same two facts, a command and its arguments, and differ only in which file
|
|
102
|
+
holds them:
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"hmis": {
|
|
108
|
+
"command": "uvx",
|
|
109
|
+
"args": [
|
|
110
|
+
"--from", "https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip",
|
|
111
|
+
"hmis-mcp", "--export", "/absolute/path/to/export.zip"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| Agent | Where it goes |
|
|
119
|
+
|---|---|
|
|
120
|
+
| Claude Desktop | `claude_desktop_config.json` |
|
|
121
|
+
| Claude Code | `claude mcp add hmis -- uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp --export /absolute/path/to/export.zip` |
|
|
122
|
+
| Cursor | `.cursor/mcp.json` |
|
|
123
|
+
| Gemini CLI | `~/.gemini/settings.json` |
|
|
124
|
+
| VS Code | `.vscode/mcp.json`, with the top-level key `servers` instead of `mcpServers` |
|
|
125
|
+
| Codex CLI | `~/.codex/config.toml`, as a `[mcp_servers.hmis]` table with `command` and `args` |
|
|
126
|
+
|
|
127
|
+
These file locations change between releases. If one doesn't work, check that
|
|
128
|
+
agent's MCP documentation; the command and args stay the same.
|
|
129
|
+
|
|
130
|
+
### Agents that connect to a URL (HTTP)
|
|
131
|
+
|
|
132
|
+
ChatGPT cannot start a local program. Its servers call yours, so the server
|
|
133
|
+
needs a public `https://` address. The same goes for the OpenAI Responses API
|
|
134
|
+
and most hosted agent platforms.
|
|
135
|
+
|
|
136
|
+
Make a secret. This writes it to a file in your home folder, readable only by
|
|
137
|
+
you on macOS and Linux, and by whoever can read your user profile on Windows:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp secret --out ~/.hmis-mcp-secret
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Give the server a public address. The server itself stays bound to
|
|
144
|
+
`127.0.0.1`; a tunnel carries HTTPS traffic to it. With Cloudflare's:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
cloudflared tunnel --url http://127.0.0.1:8000
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
That prints an address like `https://something.trycloudflare.com`. Start the
|
|
151
|
+
server with it:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
uvx --from https://github.com/dan-blanchard/hmis-mcp/archive/refs/heads/main.zip hmis-mcp --export /absolute/path/to/export.zip --transport http --public-url https://something.trycloudflare.com --secret-file ~/.hmis-mcp-secret
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The MCP endpoint is the public address plus `/mcp`.
|
|
158
|
+
|
|
159
|
+
**ChatGPT.** Add a custom MCP server in ChatGPT's settings (OpenAI has moved
|
|
160
|
+
this menu more than once; look under connectors, apps or plugins), give it the
|
|
161
|
+
`/mcp` URL, and choose OAuth. ChatGPT registers itself and sends your browser
|
|
162
|
+
to this server's approval page. Paste the secret there. Tokens refresh on their
|
|
163
|
+
own after that, and approvals survive a restart.
|
|
164
|
+
|
|
165
|
+
**Agents that send headers.** Use the secret as a bearer token:
|
|
166
|
+
`Authorization: Bearer <secret>`. For the OpenAI Responses API that is an `mcp`
|
|
167
|
+
tool with `server_url` set to the `/mcp` URL and `authorization` set to the
|
|
168
|
+
secret.
|
|
169
|
+
|
|
170
|
+
The server will not start on HTTP without a secret unless you pass `--no-auth`,
|
|
171
|
+
and it accepts `--no-auth` only on a loopback address with no public URL.
|
|
172
|
+
|
|
173
|
+
Before you expose this, understand what changes. Over stdio, aggregates go to
|
|
174
|
+
whichever model your local agent uses. Over HTTP with ChatGPT, they go to
|
|
175
|
+
OpenAI, and anyone who obtains the secret can query your agency's statistics
|
|
176
|
+
from anywhere. No client-level data is reachable either way, but aggregate
|
|
177
|
+
numbers about a small shelter are still your agency's data. Stop the tunnel
|
|
178
|
+
when you are not using it.
|
|
179
|
+
|
|
180
|
+
## Options
|
|
181
|
+
|
|
182
|
+
| Option | Env var | Default | |
|
|
183
|
+
|---|---|---|---|
|
|
184
|
+
| `--export` | `HMIS_EXPORT_PATH` | required | Export directory or zip |
|
|
185
|
+
| `--min-cell-size` | `HMIS_MIN_CELL_SIZE` | 11 | Smallest client count released. Floor is 5. |
|
|
186
|
+
| `--csv-version` | `HMIS_CSV_VERSION` | detected | Force the HUD CSV revision: 2022, 2024 or 2026 |
|
|
187
|
+
| `--audit-log` | `HMIS_AUDIT_LOG` | off | One JSON line per query: the request and how many cells were released or suppressed. No results. |
|
|
188
|
+
| `--transport` | `HMIS_MCP_TRANSPORT` | `stdio` | `stdio` or `http` |
|
|
189
|
+
| `--host`, `--port` | | `127.0.0.1`, `8000` | Where the HTTP transport listens |
|
|
190
|
+
| `--public-url` | `HMIS_MCP_PUBLIC_URL` | | The `https://` address clients use |
|
|
191
|
+
| `--secret-file` | `HMIS_MCP_SECRET` (the secret itself) | | Access secret, at least 24 characters |
|
|
192
|
+
| `--state-file` | `HMIS_MCP_STATE` | `~/.hmis-mcp/oauth-state.json` | Approved clients and token hashes |
|
|
193
|
+
|
|
194
|
+
## Tools
|
|
195
|
+
|
|
196
|
+
- `describe_dataset`: export period, privacy rules, and every valid measure,
|
|
197
|
+
cohort, dimension and dimension value.
|
|
198
|
+
- `list_projects`: project names, types, organizations, bed inventory.
|
|
199
|
+
- `query_aggregate`: counts of clients, enrollments or households, and mean or
|
|
200
|
+
median length of stay, broken down by up to three dimensions, with filters, a
|
|
201
|
+
cohort (active, entered, exited) and a reporting period.
|
|
202
|
+
- `bed_utilization`: monthly bed nights and utilization per project.
|
|
203
|
+
|
|
204
|
+
Dimensions cover project, organization, project type, CoC, age group,
|
|
205
|
+
race/ethnicity, sex (FY2026) or gender (FY2024), veteran status, household
|
|
206
|
+
type, relationship to head of household, disabling condition, DV survivor
|
|
207
|
+
status, prior living situation, exit destination, length of stay, income at
|
|
208
|
+
entry, and entry/exit month, quarter and year.
|
|
209
|
+
|
|
210
|
+
The agent picks from that vocabulary. It never writes SQL.
|
|
211
|
+
|
|
212
|
+
## How the privacy protection works
|
|
213
|
+
|
|
214
|
+
Threat model first, because it determines what the rest is worth. The person
|
|
215
|
+
running this server already holds the export and is authorized to see it. The
|
|
216
|
+
thing being protected against is client data reaching a model provider, a chat
|
|
217
|
+
transcript, or a generated report. The server is not built to stop a determined
|
|
218
|
+
insider with unlimited queries from learning something about a client; that
|
|
219
|
+
person can open the CSV.
|
|
220
|
+
|
|
221
|
+
Within that model:
|
|
222
|
+
|
|
223
|
+
1. Names, SSNs and free-text fields are never read into the database. Each CSV
|
|
224
|
+
has a column allowlist and those columns are not on it.
|
|
225
|
+
2. Birth dates and a per-client index stay in the in-memory database, because
|
|
226
|
+
ages and distinct counts need them, but no tool returns them. Ages come out
|
|
227
|
+
as bands and dates as months.
|
|
228
|
+
3. Any cell covering fewer than 11 clients is suppressed. Eleven is the CMS
|
|
229
|
+
convention; you can change it, down to 5.
|
|
230
|
+
4. If one suppressed cell on a row or column could be recovered by subtracting
|
|
231
|
+
the others from a total, a second cell is suppressed as well.
|
|
232
|
+
5. The server remembers which client groups it has already answered about. A
|
|
233
|
+
later query whose group differs from an earlier one by fewer than 11 clients,
|
|
234
|
+
with one containing the other, is refused. That blocks the "everyone, then
|
|
235
|
+
everyone except the people who entered on March 3rd" trick.
|
|
236
|
+
6. Unexpected errors return a generic message, so a database error can't carry
|
|
237
|
+
data out.
|
|
238
|
+
7. Over HTTP, every request needs the access secret or a token issued after
|
|
239
|
+
someone typed it into the approval page. Only hashes of issued tokens are
|
|
240
|
+
stored. Ten wrong guesses lock the approval page for ten minutes.
|
|
241
|
+
|
|
242
|
+
Known limits, stated plainly:
|
|
243
|
+
|
|
244
|
+
- The differencing check is pairwise and lives in memory. Restarting the server
|
|
245
|
+
clears it, and an attack that combines three or more overlapping queries can
|
|
246
|
+
get past it.
|
|
247
|
+
- Attribute disclosure is not addressed. If all 14 clients in some cell share a
|
|
248
|
+
sensitive attribute, a breakdown will show that. Anyone who knows a person is
|
|
249
|
+
in the cell learns the attribute.
|
|
250
|
+
- A suppressed cell still shows that between 1 and 10 clients are in it.
|
|
251
|
+
- Small projects will see a lot of suppression on detailed breakdowns. That is
|
|
252
|
+
the rule working. Use coarser dimensions or longer periods.
|
|
253
|
+
|
|
254
|
+
Have your HMIS lead review this before using it on real data. HUD has said
|
|
255
|
+
publicly that general-purpose AI tools are not appropriate for client data, and
|
|
256
|
+
your CoC's privacy policy may have its own rules about AI and about minimum
|
|
257
|
+
cell sizes.
|
|
258
|
+
|
|
259
|
+
## What the numbers mean
|
|
260
|
+
|
|
261
|
+
These are counts from your export, not certified HUD reports. Where they can
|
|
262
|
+
differ from an APR or CAPER:
|
|
263
|
+
|
|
264
|
+
- Age is taken at the later of entry or period start, as HUD reports do.
|
|
265
|
+
- Household type is computed from members' ages at entry.
|
|
266
|
+
- Length of stay runs from entry to exit, or to the period end for people still
|
|
267
|
+
enrolled. It does not use move-in dates.
|
|
268
|
+
- Bed utilization uses entry and exit dates, move-in dates for permanent
|
|
269
|
+
housing, and bed-night records for night-by-night shelters.
|
|
270
|
+
- Chronic homelessness is not implemented.
|
|
271
|
+
|
|
272
|
+
## Adding a live backend
|
|
273
|
+
|
|
274
|
+
`hmis_mcp.source.DataSource` is the seam. A source fills `raw_*` tables using
|
|
275
|
+
HUD CSV column names, and everything after that is shared. WellSky does not
|
|
276
|
+
publish API documentation, so a live backend needs an arrangement with WellSky
|
|
277
|
+
or your HMIS lead before it can be written.
|
|
278
|
+
|
|
279
|
+
## Development
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
git clone https://github.com/dan-blanchard/hmis-mcp
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
cd hmis-mcp && uv run pytest
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The tests build a synthetic export with planted names and SSNs, run every tool
|
|
290
|
+
across every dimension, and fail if any planted value appears in any output.
|
|
291
|
+
They also write the same population in each supported HUD CSV revision and
|
|
292
|
+
require identical answers, check that tool schemas avoid the JSON Schema
|
|
293
|
+
features some model providers reject, and drive the HTTP transport through a
|
|
294
|
+
full OAuth sign-in. CI runs them on Windows, macOS and Linux.
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
|
|
298
|
+
0BSD. Do what you like with it; no attribution needed.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "hmis-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Aggregate-only MCP server for HMIS data: reports and analytics without exporting PII"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "0BSD"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.12"
|
|
9
|
+
keywords = [
|
|
10
|
+
"mcp",
|
|
11
|
+
"hmis",
|
|
12
|
+
"homelessness",
|
|
13
|
+
"hud",
|
|
14
|
+
"privacy",
|
|
15
|
+
"disclosure-control",
|
|
16
|
+
]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 3 - Alpha",
|
|
19
|
+
"Intended Audience :: Information Technology",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"duckdb>=1.1",
|
|
28
|
+
"mcp>=2,<3",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Repository = "https://github.com/dan-blanchard/hmis-mcp"
|
|
33
|
+
Issues = "https://github.com/dan-blanchard/hmis-mcp/issues"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
hmis-mcp = "hmis_mcp.server:main"
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["uv_build>=0.11.32,<0.12.0"]
|
|
40
|
+
build-backend = "uv_build"
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = ["pytest>=9.2.0"]
|