@cyanheads/fema-mcp-server 0.1.1

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.
Files changed (65) hide show
  1. package/AGENTS.md +360 -0
  2. package/CLAUDE.md +360 -0
  3. package/Dockerfile +100 -0
  4. package/LICENSE +201 -0
  5. package/README.md +340 -0
  6. package/changelog/0.1.x/0.1.1.md +41 -0
  7. package/changelog/template.md +127 -0
  8. package/dist/config/server-config.d.ts +9 -0
  9. package/dist/config/server-config.d.ts.map +1 -0
  10. package/dist/config/server-config.js +22 -0
  11. package/dist/config/server-config.js.map +1 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +45 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/mcp-server/resources/definitions/fema-disaster.resource.d.ts +9 -0
  17. package/dist/mcp-server/resources/definitions/fema-disaster.resource.d.ts.map +1 -0
  18. package/dist/mcp-server/resources/definitions/fema-disaster.resource.js +59 -0
  19. package/dist/mcp-server/resources/definitions/fema-disaster.resource.js.map +1 -0
  20. package/dist/mcp-server/tools/definitions/fema-dataframe-describe.tool.d.ts +27 -0
  21. package/dist/mcp-server/tools/definitions/fema-dataframe-describe.tool.d.ts.map +1 -0
  22. package/dist/mcp-server/tools/definitions/fema-dataframe-describe.tool.js +99 -0
  23. package/dist/mcp-server/tools/definitions/fema-dataframe-describe.tool.js.map +1 -0
  24. package/dist/mcp-server/tools/definitions/fema-dataframe-query.tool.d.ts +25 -0
  25. package/dist/mcp-server/tools/definitions/fema-dataframe-query.tool.d.ts.map +1 -0
  26. package/dist/mcp-server/tools/definitions/fema-dataframe-query.tool.js +87 -0
  27. package/dist/mcp-server/tools/definitions/fema-dataframe-query.tool.js.map +1 -0
  28. package/dist/mcp-server/tools/definitions/fema-get-disaster.tool.d.ts +33 -0
  29. package/dist/mcp-server/tools/definitions/fema-get-disaster.tool.d.ts.map +1 -0
  30. package/dist/mcp-server/tools/definitions/fema-get-disaster.tool.js +142 -0
  31. package/dist/mcp-server/tools/definitions/fema-get-disaster.tool.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/fema-get-housing-assistance.tool.d.ts +53 -0
  33. package/dist/mcp-server/tools/definitions/fema-get-housing-assistance.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/fema-get-housing-assistance.tool.js +246 -0
  35. package/dist/mcp-server/tools/definitions/fema-get-housing-assistance.tool.js.map +1 -0
  36. package/dist/mcp-server/tools/definitions/fema-get-public-assistance.tool.d.ts +45 -0
  37. package/dist/mcp-server/tools/definitions/fema-get-public-assistance.tool.d.ts.map +1 -0
  38. package/dist/mcp-server/tools/definitions/fema-get-public-assistance.tool.js +210 -0
  39. package/dist/mcp-server/tools/definitions/fema-get-public-assistance.tool.js.map +1 -0
  40. package/dist/mcp-server/tools/definitions/fema-query-dataset.tool.d.ts +32 -0
  41. package/dist/mcp-server/tools/definitions/fema-query-dataset.tool.d.ts.map +1 -0
  42. package/dist/mcp-server/tools/definitions/fema-query-dataset.tool.js +128 -0
  43. package/dist/mcp-server/tools/definitions/fema-query-dataset.tool.js.map +1 -0
  44. package/dist/mcp-server/tools/definitions/fema-search-disasters.tool.d.ts +50 -0
  45. package/dist/mcp-server/tools/definitions/fema-search-disasters.tool.d.ts.map +1 -0
  46. package/dist/mcp-server/tools/definitions/fema-search-disasters.tool.js +281 -0
  47. package/dist/mcp-server/tools/definitions/fema-search-disasters.tool.js.map +1 -0
  48. package/dist/mcp-server/tools/definitions/fema-search-nfip.tool.d.ts +38 -0
  49. package/dist/mcp-server/tools/definitions/fema-search-nfip.tool.d.ts.map +1 -0
  50. package/dist/mcp-server/tools/definitions/fema-search-nfip.tool.js +307 -0
  51. package/dist/mcp-server/tools/definitions/fema-search-nfip.tool.js.map +1 -0
  52. package/dist/services/canvas/canvas-accessor.d.ts +9 -0
  53. package/dist/services/canvas/canvas-accessor.d.ts.map +1 -0
  54. package/dist/services/canvas/canvas-accessor.js +11 -0
  55. package/dist/services/canvas/canvas-accessor.js.map +1 -0
  56. package/dist/services/openfema/openfema-service.d.ts +52 -0
  57. package/dist/services/openfema/openfema-service.d.ts.map +1 -0
  58. package/dist/services/openfema/openfema-service.js +157 -0
  59. package/dist/services/openfema/openfema-service.js.map +1 -0
  60. package/dist/services/openfema/types.d.ts +139 -0
  61. package/dist/services/openfema/types.d.ts.map +1 -0
  62. package/dist/services/openfema/types.js +6 -0
  63. package/dist/services/openfema/types.js.map +1 -0
  64. package/package.json +105 -0
  65. package/server.json +99 -0
package/README.md ADDED
@@ -0,0 +1,340 @@
1
+ <div align="center">
2
+ <h1>@cyanheads/fema-mcp-server</h1>
3
+ <p><b>Query FEMA disaster declarations, public assistance grants, housing aid, and NFIP flood insurance claims via MCP. STDIO or Streamable HTTP.</b>
4
+ <div>8 Tools • 1 Resource</div>
5
+ </p>
6
+ </div>
7
+
8
+ <div align="center">
9
+
10
+ [![Version](https://img.shields.io/badge/Version-0.1.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/fema-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/fema-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@cyanheads/fema-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.11-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
+
12
+ </div>
13
+
14
+ <div align="center">
15
+
16
+ [![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/fema-mcp-server/releases/latest/download/fema-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=fema-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvZmVtYS1tY3Atc2VydmVyIl19) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22fema-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Ffema-mcp-server%22%5D%7D)
17
+
18
+ [![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
19
+
20
+ </div>
21
+
22
+ ---
23
+
24
+ ## Tools
25
+
26
+ Eight tools covering the OpenFEMA data surface — convenience tools for the headline datasets, SQL analytics over large NFIP result sets via DuckDB canvas, and a generic escape hatch for datasets the convenience tools don't cover:
27
+
28
+ | Tool | Description |
29
+ |:---|:---|
30
+ | `fema_search_disasters` | Search federal disaster declarations by state, incident type, declaration type, date range, and county |
31
+ | `fema_get_disaster` | Fetch all designated-area records for a specific disaster by disaster number |
32
+ | `fema_get_public_assistance` | Public assistance funded projects for a disaster or state — where federal recovery money went |
33
+ | `fema_get_housing_assistance` | Individual assistance housing data for a disaster — owner and renter breakdowns by county/ZIP |
34
+ | `fema_search_nfip` | NFIP flood insurance claims for a state, county, or ZIP, with optional DataCanvas spillover for SQL analytics |
35
+ | `fema_dataframe_describe` | List columns and row counts for DataCanvas tables staged by `fema_search_nfip` |
36
+ | `fema_dataframe_query` | Run a SELECT query against a DataCanvas table staged by `fema_search_nfip` |
37
+ | `fema_query_dataset` | Generic OData query against any OpenFEMA v2 dataset — escape hatch for datasets the convenience tools don't cover |
38
+
39
+ ### `fema_search_disasters`
40
+
41
+ The primary entry point — "what disasters were declared in Texas in 2025?"
42
+
43
+ - Filter by state (2-letter code), incident type (Hurricane, Flood, Wildfire, etc.), declaration type (`DR`/`EM`/`FM`), date range, and county
44
+ - Returns deduplicated declaration-level summaries — one row per declaration, not per designated area
45
+ - Includes disaster number (the join key for PA and housing tools), title, state, incident type, declaration/incident dates, programs declared (IA/PA/HM), and `designatedAreaCount`
46
+ - Paginated via `limit` / `offset`
47
+
48
+ ---
49
+
50
+ ### `fema_get_disaster`
51
+
52
+ Fetch all designated-area records for a specific FEMA disaster number.
53
+
54
+ - Returns every county/municipality row for the declaration with programs activated, incident period, and FIPS codes
55
+ - Use after `fema_search_disasters` to drill into a specific event; the disaster number chains to PA and housing tools
56
+ - `DisasterDeclarationsSummaries` returns one row per designated area — a single declaration can span dozens of counties
57
+
58
+ ---
59
+
60
+ ### `fema_get_public_assistance`
61
+
62
+ Retrieve PA funded project details — where federal recovery money went after a disaster.
63
+
64
+ - Filter by `disaster_number`, `state`, or `county`; at least one of `disaster_number` or `state` is required
65
+ - Returns applicant, damage category, project size/status, federal share obligated, and total obligated
66
+ - Useful for journalists, researchers, and oversight analysts tracking federal grant flows
67
+
68
+ ---
69
+
70
+ ### `fema_get_housing_assistance`
71
+
72
+ Individual assistance housing data for a disaster, broken down by county and ZIP.
73
+
74
+ - Returns owner and renter breakdowns via `type` param (`owners`/`renters`/`both`)
75
+ - Fields include valid registrations, total inspected, total damage, approved IHP amounts, repair/rental/other-needs amounts, and max grants
76
+ - Covers `HousingAssistanceOwners` and `HousingAssistanceRenters` datasets in a single call
77
+
78
+ ---
79
+
80
+ ### `fema_search_nfip`
81
+
82
+ NFIP flood insurance claims with optional DuckDB-backed SQL analytics for large result sets.
83
+
84
+ - Requires at minimum a `state` filter — unfiltered NFIP Claims is 2.7M rows
85
+ - Additional filters: `county_code`, `zip_code`, `year_from`, `year_to`; pagination via `limit`
86
+ - When `CANVAS_PROVIDER_TYPE=duckdb` is set and results exceed the inline cap, the full result set spills to a DataCanvas table and returns a `canvas_id` handle
87
+ - Use `fema_dataframe_describe` to inspect the schema, then `fema_dataframe_query` for aggregation, grouping, and time-series analysis without re-fetching
88
+
89
+ ---
90
+
91
+ ### `fema_dataframe_describe` / `fema_dataframe_query`
92
+
93
+ In-conversation SQL analytics over NFIP Claims data staged by `fema_search_nfip` on a DuckDB-backed DataCanvas.
94
+
95
+ - `fema_dataframe_describe`: lists columns, types, and row count for a canvas table — use before writing a query
96
+ - `fema_dataframe_query`: runs a single SELECT statement against the staged table; standard DuckDB SQL (GROUP BY, SUM, window functions, time-series)
97
+ - Workflow: `fema_search_nfip` (with canvas enabled) → `fema_dataframe_describe` → `fema_dataframe_query`
98
+ - Read-only — writes, DDL, and DROP are rejected by the framework SQL gate
99
+
100
+ ---
101
+
102
+ ### `fema_query_dataset`
103
+
104
+ Generic OData query against any OpenFEMA v2 dataset — the escape hatch for datasets the convenience tools don't cover.
105
+
106
+ - Accepts raw `$filter`, `$select`, `$orderby`, `limit`, and `offset` params
107
+ - Dataset name must match an actual OpenFEMA endpoint (e.g. `FimaNfipPolicies`, `IndividualAssistanceHousingRegistrantsLargeDisasters`)
108
+ - Validates that the API returns JSON (Content-Type check) and surfaces structured error codes on 400 responses
109
+
110
+ ## Resources and prompts
111
+
112
+ | Type | Name | Description |
113
+ |:---|:---|:---|
114
+ | Resource | `fema://disaster/{disasterNumber}` | Summary for a specific FEMA disaster declaration — title, state, incident type, programs, incident period |
115
+
116
+ All resource data is also reachable via tools. Use `fema_get_disaster` for the same data with pagination and full designated-area detail.
117
+
118
+ ## Features
119
+
120
+ Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):
121
+
122
+ - Declarative tool, resource, and prompt definitions — single file per primitive, framework handles registration and validation
123
+ - Unified error handling — handlers throw, framework catches, classifies, and formats
124
+ - Pluggable auth: `none`, `jwt`, `oauth`
125
+ - Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
126
+ - Structured logging with optional OpenTelemetry tracing
127
+ - STDIO and Streamable HTTP transports
128
+
129
+ FEMA/OpenFEMA-specific:
130
+
131
+ - Typed OpenFEMA REST client with OData parameter building (`%24`-encoded to satisfy Akamai's Drupal layer), response parsing, and structured error classification (JSON 400 vs HTML 404)
132
+ - Automatic deduplication of `DisasterDeclarationsSummaries` — one row per designated area collapsed to declaration-level summaries with `designatedAreaCount`
133
+ - NFIP Claims guard: `state` filter is required to prevent unbounded 2.7M-row fetches
134
+ - DataCanvas spillover for NFIP analytics — large NFIP result sets materialize as DuckDB tables queryable via SQL without re-fetching
135
+ - No API keys required — OpenFEMA is a free, public API
136
+
137
+ Agent-friendly output:
138
+
139
+ - Disaster number is the explicit join key across all datasets — every tool that touches a disaster surfaces it prominently so agents can chain calls without re-searching
140
+ - Typed error contracts on every tool — `invalid_state`, `no_results`, `missing_filter`, `state_required`, `unknown_dataset`, `invalid_filter` — with recovery hints telling agents the concrete next step
141
+ - `designatedAreaCount` on search results so agents know whether to drill in with `fema_get_disaster` without having to fetch the full record first
142
+
143
+ ## Getting started
144
+
145
+ Add the following to your MCP client configuration file.
146
+
147
+ ```json
148
+ {
149
+ "mcpServers": {
150
+ "fema-mcp-server": {
151
+ "type": "stdio",
152
+ "command": "bunx",
153
+ "args": ["@cyanheads/fema-mcp-server@latest"],
154
+ "env": {
155
+ "MCP_TRANSPORT_TYPE": "stdio",
156
+ "MCP_LOG_LEVEL": "info"
157
+ }
158
+ }
159
+ }
160
+ }
161
+ ```
162
+
163
+ Or with npx (no Bun required):
164
+
165
+ ```json
166
+ {
167
+ "mcpServers": {
168
+ "fema-mcp-server": {
169
+ "type": "stdio",
170
+ "command": "npx",
171
+ "args": ["-y", "@cyanheads/fema-mcp-server@latest"],
172
+ "env": {
173
+ "MCP_TRANSPORT_TYPE": "stdio",
174
+ "MCP_LOG_LEVEL": "info"
175
+ }
176
+ }
177
+ }
178
+ }
179
+ ```
180
+
181
+ Or with Docker:
182
+
183
+ ```json
184
+ {
185
+ "mcpServers": {
186
+ "fema-mcp-server": {
187
+ "type": "stdio",
188
+ "command": "docker",
189
+ "args": [
190
+ "run", "-i", "--rm",
191
+ "-e", "MCP_TRANSPORT_TYPE=stdio",
192
+ "ghcr.io/cyanheads/fema-mcp-server:latest"
193
+ ]
194
+ }
195
+ }
196
+ }
197
+ ```
198
+
199
+ For Streamable HTTP, set the transport and start the server:
200
+
201
+ ```sh
202
+ MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
203
+ # Server listens at http://localhost:3010/mcp
204
+ ```
205
+
206
+ To enable DuckDB-backed SQL analytics for NFIP Claims:
207
+
208
+ ```json
209
+ {
210
+ "mcpServers": {
211
+ "fema-mcp-server": {
212
+ "type": "stdio",
213
+ "command": "bunx",
214
+ "args": ["@cyanheads/fema-mcp-server@latest"],
215
+ "env": {
216
+ "MCP_TRANSPORT_TYPE": "stdio",
217
+ "CANVAS_PROVIDER_TYPE": "duckdb"
218
+ }
219
+ }
220
+ }
221
+ }
222
+ ```
223
+
224
+ ### Prerequisites
225
+
226
+ - [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+).
227
+ - No API keys required — OpenFEMA is a free, public API.
228
+ - Optional: set `CANVAS_PROVIDER_TYPE=duckdb` to enable SQL analytics over large NFIP Claims result sets.
229
+
230
+ ### Installation
231
+
232
+ 1. **Clone the repository:**
233
+
234
+ ```sh
235
+ git clone https://github.com/cyanheads/fema-mcp-server.git
236
+ ```
237
+
238
+ 2. **Navigate into the directory:**
239
+
240
+ ```sh
241
+ cd fema-mcp-server
242
+ ```
243
+
244
+ 3. **Install dependencies:**
245
+
246
+ ```sh
247
+ bun install
248
+ ```
249
+
250
+ 4. **Configure environment:**
251
+
252
+ ```sh
253
+ cp .env.example .env
254
+ # edit .env — no required vars, but CANVAS_PROVIDER_TYPE=duckdb enables SQL analytics
255
+ ```
256
+
257
+ ## Configuration
258
+
259
+ All configuration is validated at startup via Zod schemas in `src/config/server-config.ts`. Key environment variables:
260
+
261
+ | Variable | Description | Default |
262
+ |:---------|:------------|:--------|
263
+ | `FEMA_BASE_URL` | Override the OpenFEMA API base URL. | `https://www.fema.gov/api/open/v2` |
264
+ | `FEMA_REQUEST_TIMEOUT_MS` | Per-request HTTP timeout in milliseconds. NFIP county queries can be slow. | `30000` |
265
+ | `CANVAS_PROVIDER_TYPE` | Set to `duckdb` to enable DataCanvas for NFIP Claims analytics. Without it, `fema_search_nfip` inlines results up to the cap. | — |
266
+ | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
267
+ | `MCP_HTTP_PORT` | HTTP server port. | `3010` |
268
+ | `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
269
+ | `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `warning`, `error`, etc.). | `info` |
270
+ | `LOGS_DIR` | Directory for log files (Node.js only). | `<project-root>/logs` |
271
+ | `OTEL_ENABLED` | Enable [OpenTelemetry instrumentation](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry). | `false` |
272
+
273
+ See [`.env.example`](./.env.example) for the full list of optional overrides.
274
+
275
+ ## Running the server
276
+
277
+ ### Local development
278
+
279
+ - **Build and run:**
280
+
281
+ ```sh
282
+ # One-time build
283
+ bun run rebuild
284
+
285
+ # Run the built server
286
+ bun run start:stdio
287
+ # or
288
+ bun run start:http
289
+ ```
290
+
291
+ - **Run checks and tests:**
292
+
293
+ ```sh
294
+ bun run devcheck # Lint, format, typecheck, security
295
+ bun run test # Vitest test suite
296
+ bun run lint:mcp # Validate MCP definitions against spec
297
+ ```
298
+
299
+ ### Docker
300
+
301
+ ```sh
302
+ docker build -t fema-mcp-server .
303
+ docker run --rm -e MCP_TRANSPORT_TYPE=stdio fema-mcp-server
304
+ ```
305
+
306
+ The Dockerfile defaults to HTTP transport, stateless session mode, and logs to `/var/log/fema-mcp-server`. OpenTelemetry peer dependencies are installed by default — build with `--build-arg OTEL_ENABLED=false` to omit them. The `@duckdb/node-api` native binary is copied from the build stage, so the production image doesn't need build tools.
307
+
308
+ ## Project structure
309
+
310
+ | Directory | Purpose |
311
+ |:----------|:--------|
312
+ | `src/index.ts` | `createApp()` entry point — registers tools/resources and inits services. |
313
+ | `src/config` | Server-specific environment variable parsing and validation with Zod. |
314
+ | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`) — one file per tool. |
315
+ | `src/mcp-server/resources` | Resource definitions (`*.resource.ts`). |
316
+ | `src/services/openfema` | OpenFEMA REST API client — OData param builder, response parser, error classifier, retry wrapper. |
317
+ | `src/services/canvas` | DataCanvas integration — DuckDB spillover for large NFIP result sets. |
318
+ | `tests/` | Unit and integration tests mirroring `src/`. |
319
+
320
+ ## Development guide
321
+
322
+ See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
323
+
324
+ - Handlers throw, framework catches — no `try/catch` in tool logic
325
+ - Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage
326
+ - Register new tools and resources via the barrels in `src/mcp-server/*/definitions/index.ts`
327
+ - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
328
+
329
+ ## Contributing
330
+
331
+ Issues and pull requests are welcome. Run checks and tests before submitting:
332
+
333
+ ```sh
334
+ bun run devcheck
335
+ bun run test
336
+ ```
337
+
338
+ ## License
339
+
340
+ Apache-2.0 — see [LICENSE](./LICENSE) for details.
@@ -0,0 +1,41 @@
1
+ ---
2
+ summary: "Initial public release — 8 tools, 1 resource over the OpenFEMA API (disaster declarations, public assistance, housing aid, NFIP claims) with DataCanvas SQL and OData injection hardening"
3
+ breaking: false
4
+ security: true
5
+ ---
6
+
7
+ # 0.1.1 — 2026-06-05
8
+
9
+ Initial public release of `@cyanheads/fema-mcp-server`. Provides 8 MCP tools and 1 resource over the [OpenFEMA API v2](https://www.fema.gov/about/openfema/api):
10
+
11
+ - **`fema_search_disasters`** — search federal disaster declarations by state, incident type, declaration type, date range, and county
12
+ - **`fema_get_disaster`** — fetch all designated-area records for a specific disaster by number
13
+ - **`fema_get_public_assistance`** — public assistance funded projects for a disaster or state
14
+ - **`fema_get_housing_assistance`** — individual assistance housing data by disaster — owner and renter breakdowns by county/ZIP
15
+ - **`fema_search_nfip`** — NFIP flood insurance claims for a state, county, or ZIP, with optional DataCanvas spillover for SQL analytics
16
+ - **`fema_dataframe_describe`** — list columns and row counts for DataCanvas tables staged by `fema_search_nfip`
17
+ - **`fema_dataframe_query`** — run a SELECT query against a DataCanvas table staged by `fema_search_nfip`
18
+ - **`fema_query_dataset`** — generic OData query against any OpenFEMA v2 dataset (escape hatch for datasets the convenience tools don't cover)
19
+ - **`fema://disaster/{disasterNumber}`** resource — summary for a specific FEMA disaster declaration
20
+
21
+ ## Added
22
+
23
+ - **`fema_search_disasters`** — search disaster declarations; deduplicated to one row per declaration with disaster number, title, state, incident type, declaration/incident dates, programs declared (IA/PA/HM), and `designatedAreaCount`
24
+ - **`fema_get_disaster`** — returns all designated-area records for a disaster number with full program eligibility breakdown
25
+ - **`fema_get_public_assistance`** — funded project records with applicant, project amount, category codes, and status; filterable by state, disaster number, county, and incident type
26
+ - **`fema_get_housing_assistance`** — owner and renter household registrant and assistance totals by county and ZIP for a disaster
27
+ - **`fema_search_nfip`** — NFIP claims with state/county/ZIP filters; spills to a named DuckDB DataCanvas table when result sets exceed the inline preview budget (`CANVAS_PROVIDER_TYPE=duckdb`)
28
+ - **`fema_dataframe_describe`** — enumerates registered DataCanvas tables with column names, types, row count, and TTL; supports follow-up SQL analytics on NFIP data
29
+ - **`fema_dataframe_query`** — single-statement SELECT SQL executed against DataCanvas tables via DuckDB; read-only, enforced by the framework SQL gate
30
+ - **`fema_query_dataset`** — generic OData v4 escape hatch for any `/api/open/v2/` endpoint not covered by the convenience tools; accepts `$filter`, `$select`, `$orderby`, `$top`, `$skip`
31
+ - **`fema://disaster/{disasterNumber}`** resource — disaster declaration summary keyed by disaster number
32
+ - **`escapeODataString`** helper in `openfema-service.ts` — sanitizes user-supplied string values injected into OData `$filter` expressions across all tools
33
+ - **DataCanvas support** (`CANVAS_PROVIDER_TYPE=duckdb`) — `fema_search_nfip` spills large result sets to named DuckDB tables for SQL follow-up; inline preview bounded at 100 KB
34
+
35
+ ## Changed
36
+
37
+ - **`Dockerfile`** — copies `node_modules` from the build stage so `@duckdb/node-api`'s pre-compiled native binary is preserved in the production image without reinstalling build tools at runtime
38
+
39
+ ## Security
40
+
41
+ - **OData injection hardening** — `escapeODataString` sanitizes single-quote characters (`'` → `''`) in all user-supplied string values before interpolation into OData `$filter` expressions in `fema_search_disasters`, `fema_get_public_assistance`, and `fema_search_nfip`; prevents filter injection via crafted string inputs
@@ -0,0 +1,127 @@
1
+ ---
2
+ # FORMAT REFERENCE — do not edit. Copy this file to
3
+ # `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.8.x/0.8.6.md`)
4
+ # to author a new release. Set that file's H1 to `# <version> — YYYY-MM-DD`
5
+ # with a concrete date.
6
+
7
+ # Required. One-line GitHub Release-style headline. 350 character cap.
8
+ # Default short and scannable. Don't pad, don't stitch unrelated changes with
9
+ # semicolons — pick the headline. Quotes required: unquoted YAML treats `: `
10
+ # inside the value as a key separator and fails GitHub's strict parser.
11
+ summary: ""
12
+
13
+ # Set `true` when consumers must change code to upgrade: API removals,
14
+ # signature changes, config renames, behavior changes that break existing
15
+ # usage. Flagged as `Breaking` in the rollup.
16
+ breaking: false
17
+
18
+ # Set `true` if this release contains any security fix. Pairs with the
19
+ # `## Security` section below. Flagged as `Security` in the rollup so
20
+ # users can triage upgrade urgency at a glance.
21
+ security: false
22
+
23
+ # Optional free-form notes for maintenance agents processing this release.
24
+ # Not rendered in CHANGELOG — consumed by agents running `maintenance` on
25
+ # downstream servers. Use for adoption instructions that don't fit the
26
+ # human-facing sections: new files to create, fields to populate, one-time
27
+ # migration steps. Omit the field entirely when there's nothing to say.
28
+ # agent-notes: |
29
+ # <instructions for downstream maintenance agents>
30
+ ---
31
+
32
+ # <version> — YYYY-MM-DD
33
+
34
+ <!--
35
+ AUTHORING GUIDE — applies to the new per-version file you create from this
36
+ template.
37
+
38
+ Audience: someone scanning release notes to decide what affects them. Lead
39
+ each bullet with the symbol or concept name in **bold** so they can skip
40
+ what's irrelevant and zoom in on what's not.
41
+
42
+ Tone: terse, fact-dense, not verbose. Default to one sentence per bullet —
43
+ name the symbol, state what changed, stop. Use a second sentence only when
44
+ it carries weight. If a bullet feels long, it is.
45
+
46
+ Cut: mechanism walkthroughs (those belong in JSDoc, CLAUDE.md/AGENTS.md, or the
47
+ relevant skill), ceremonial framings ("This release introduces…",
48
+ backwards-compat paragraphs), file-by-file test enumerations, internal
49
+ implementation notes. Prefer code/symbol names over English re-explanations.
50
+
51
+ Narrative intro: skip by default. Add one short sentence only when the
52
+ release theme genuinely needs framing the bullets can't carry.
53
+
54
+ Sections: Keep a Changelog order — Added, Changed, Deprecated, Removed,
55
+ Fixed, Security. Include only sections with entries; delete the rest
56
+ (including the commented-out scaffolding below). Don't ship empty headers.
57
+
58
+ Include: every distinct fact a reader needs to adopt or audit the release —
59
+ new exports, signatures, lint rule IDs, env vars, breaking changes, version
60
+ bumps on shipped skills. Nothing more.
61
+
62
+ Links: link issues, PRs, docs, or skills where they help a reader jump to
63
+ context. Once per item per entry — don't re-link the same issue in summary,
64
+ narrative, and bullet. Skip links for inline symbol names; code spans speak
65
+ for themselves.
66
+
67
+ Issue/PR URLs: use full URLs. GitHub's bare `#NN` auto-link only resolves
68
+ inside its own UI, not in npm reads or local editors.
69
+
70
+ [#38](https://github.com/cyanheads/mcp-ts-core/issues/38) ← issue
71
+ [#42](https://github.com/cyanheads/mcp-ts-core/pull/42) ← PR
72
+
73
+ Verify numbers exist before linking (`gh issue view NN`, `gh pr view NN`).
74
+ Never speculate on a future number — `#42` for an upcoming PR silently
75
+ resolves to whatever real item already owns 42, and timeline previews pull
76
+ in that unrelated item's metadata.
77
+
78
+ TAG ANNOTATIONS — the annotated tag body renders as the GitHub Release body
79
+ via `gh release create --notes-from-tag`. The tag is a derivative of this
80
+ changelog entry — a condensed, scannable version, not a copy. Format:
81
+
82
+ <theme — omit version number, GitHub prepends it>
83
+ ← blank line
84
+ <1-2 sentence context: what this release does>
85
+ ← blank line
86
+ Dependency bumps: ← section header
87
+ ← blank line
88
+ - `@cyanheads/mcp-ts-core` ^0.9.1 → ^0.9.6 ← bullet
89
+ ← blank line
90
+ Changed: ← only sections with entries
91
+ ← blank line
92
+ - `format()` output includes `query` in text mode
93
+ ← blank line
94
+ Added:
95
+ ← blank line
96
+ - `manifest.json` scaffolded for MCPB bundle support
97
+ - Install badges (Claude Desktop, Cursor, VS Code)
98
+ ← blank line
99
+ <N> tests pass; `bun run devcheck` clean. ← footer
100
+
101
+ Never a flat comma-separated string. Always structured markdown with
102
+ sections. The tag must scan well as a rendered GitHub Release page.
103
+ -->
104
+
105
+ ## Added
106
+
107
+ -
108
+
109
+ ## Changed
110
+
111
+ -
112
+
113
+ <!-- ## Deprecated
114
+
115
+ - -->
116
+
117
+ <!-- ## Removed
118
+
119
+ - -->
120
+
121
+ ## Fixed
122
+
123
+ -
124
+
125
+ <!-- ## Security
126
+
127
+ - -->
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @fileoverview Server-specific environment variable configuration for fema-mcp-server.
3
+ * @module config/server-config
4
+ */
5
+ export declare function getServerConfig(): {
6
+ baseUrl: string;
7
+ requestTimeoutMs: number;
8
+ };
9
+ //# sourceMappingURL=server-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,wBAAgB,eAAe;;;EAM9B"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @fileoverview Server-specific environment variable configuration for fema-mcp-server.
3
+ * @module config/server-config
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
7
+ const ServerConfigSchema = z.object({
8
+ baseUrl: z.string().default('https://www.fema.gov/api/open/v2').describe('OpenFEMA API base URL'),
9
+ requestTimeoutMs: z.coerce
10
+ .number()
11
+ .default(30000)
12
+ .describe('HTTP request timeout in milliseconds'),
13
+ });
14
+ let _config;
15
+ export function getServerConfig() {
16
+ _config ??= parseEnvConfig(ServerConfigSchema, {
17
+ baseUrl: 'FEMA_BASE_URL',
18
+ requestTimeoutMs: 'FEMA_REQUEST_TIMEOUT_MS',
19
+ });
20
+ return _config;
21
+ }
22
+ //# sourceMappingURL=server-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,kCAAkC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACjG,gBAAgB,EAAE,CAAC,CAAC,MAAM;SACvB,MAAM,EAAE;SACR,OAAO,CAAC,KAAK,CAAC;SACd,QAAQ,CAAC,sCAAsC,CAAC;CACpD,CAAC,CAAC;AAEH,IAAI,OAAuD,CAAC;AAE5D,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,OAAO,EAAE,eAAe;QACxB,gBAAgB,EAAE,yBAAyB;KAC5C,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview fema-mcp-server MCP server entry point.
4
+ * @module index
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG"}
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview fema-mcp-server MCP server entry point.
4
+ * @module index
5
+ */
6
+ import { createApp } from '@cyanheads/mcp-ts-core';
7
+ import { femaDisasterResource } from './mcp-server/resources/definitions/fema-disaster.resource.js';
8
+ import { femaDataframeDescribe } from './mcp-server/tools/definitions/fema-dataframe-describe.tool.js';
9
+ import { femaDataframeQuery } from './mcp-server/tools/definitions/fema-dataframe-query.tool.js';
10
+ import { femaGetDisaster } from './mcp-server/tools/definitions/fema-get-disaster.tool.js';
11
+ import { femaGetHousingAssistance } from './mcp-server/tools/definitions/fema-get-housing-assistance.tool.js';
12
+ import { femaGetPublicAssistance } from './mcp-server/tools/definitions/fema-get-public-assistance.tool.js';
13
+ import { femaQueryDataset } from './mcp-server/tools/definitions/fema-query-dataset.tool.js';
14
+ import { femaSearchDisasters } from './mcp-server/tools/definitions/fema-search-disasters.tool.js';
15
+ import { femaSearchNfip } from './mcp-server/tools/definitions/fema-search-nfip.tool.js';
16
+ import { setCanvas } from './services/canvas/canvas-accessor.js';
17
+ import { initOpenFemaService } from './services/openfema/openfema-service.js';
18
+ await createApp({
19
+ tools: [
20
+ femaSearchDisasters,
21
+ femaGetDisaster,
22
+ femaGetPublicAssistance,
23
+ femaGetHousingAssistance,
24
+ femaSearchNfip,
25
+ femaDataframeQuery,
26
+ femaDataframeDescribe,
27
+ femaQueryDataset,
28
+ ],
29
+ resources: [femaDisasterResource],
30
+ prompts: [],
31
+ setup(core) {
32
+ initOpenFemaService(core.config, core.storage);
33
+ setCanvas(core.canvas);
34
+ },
35
+ instructions: 'FEMA disaster and flood data server. Primary entry points:\n' +
36
+ '- fema_search_disasters: find federal disaster declarations by state/type/date\n' +
37
+ '- fema_get_disaster: all designated areas for a specific disaster number\n' +
38
+ '- fema_get_public_assistance: PA funded projects (where recovery money went)\n' +
39
+ '- fema_get_housing_assistance: IA housing grants by county/ZIP\n' +
40
+ '- fema_search_nfip: NFIP flood insurance claims (requires state filter; stages to canvas for SQL)\n' +
41
+ '- fema_query_dataset: generic OData access to any OpenFEMA v2 dataset\n' +
42
+ '- fema://disaster/{number}: read-once disaster summary resource\n' +
43
+ 'Disaster number is the join key across all PA and IA tools.',
44
+ });
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8DAA8D,CAAC;AACpG,OAAO,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AACvG,OAAO,EAAE,kBAAkB,EAAE,MAAM,6DAA6D,CAAC;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,0DAA0D,CAAC;AAC3F,OAAO,EAAE,wBAAwB,EAAE,MAAM,oEAAoE,CAAC;AAC9G,OAAO,EAAE,uBAAuB,EAAE,MAAM,mEAAmE,CAAC;AAC5G,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,8DAA8D,CAAC;AACnG,OAAO,EAAE,cAAc,EAAE,MAAM,yDAAyD,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,MAAM,SAAS,CAAC;IACd,KAAK,EAAE;QACL,mBAAmB;QACnB,eAAe;QACf,uBAAuB;QACvB,wBAAwB;QACxB,cAAc;QACd,kBAAkB;QAClB,qBAAqB;QACrB,gBAAgB;KACjB;IACD,SAAS,EAAE,CAAC,oBAAoB,CAAC;IACjC,OAAO,EAAE,EAAE;IACX,KAAK,CAAC,IAAI;QACR,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,YAAY,EACV,8DAA8D;QAC9D,kFAAkF;QAClF,4EAA4E;QAC5E,gFAAgF;QAChF,kEAAkE;QAClE,qGAAqG;QACrG,yEAAyE;QACzE,mEAAmE;QACnE,6DAA6D;CAChE,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @fileoverview Resource: fema://disaster/{disasterNumber} — disaster declaration summary.
3
+ * @module mcp-server/resources/definitions/fema-disaster
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ export declare const femaDisasterResource: import("@cyanheads/mcp-ts-core").ResourceDefinition<z.ZodObject<{
7
+ disasterNumber: z.ZodString;
8
+ }, z.core.$strip>, undefined, undefined>;
9
+ //# sourceMappingURL=fema-disaster.resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fema-disaster.resource.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/resources/definitions/fema-disaster.resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAY,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAIrD,eAAO,MAAM,oBAAoB;;wCAgE/B,CAAC"}