@cliwant/mcp-sam-gov 1.3.0 → 1.4.0

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 (83) hide show
  1. package/README.ja.md +15 -7
  2. package/README.ko.md +15 -7
  3. package/README.md +48 -8
  4. package/dist/bea.d.ts +1 -1
  5. package/dist/bea.js +1 -1
  6. package/dist/census-economic.d.ts +1 -1
  7. package/dist/census-economic.d.ts.map +1 -1
  8. package/dist/census-economic.js +12 -6
  9. package/dist/census-economic.js.map +1 -1
  10. package/dist/cms-facility.d.ts +112 -0
  11. package/dist/cms-facility.d.ts.map +1 -0
  12. package/dist/cms-facility.js +311 -0
  13. package/dist/cms-facility.js.map +1 -0
  14. package/dist/cms-hospital.d.ts +105 -0
  15. package/dist/cms-hospital.d.ts.map +1 -0
  16. package/dist/cms-hospital.js +290 -0
  17. package/dist/cms-hospital.js.map +1 -0
  18. package/dist/cms-supplier.d.ts +133 -0
  19. package/dist/cms-supplier.d.ts.map +1 -0
  20. package/dist/cms-supplier.js +414 -0
  21. package/dist/cms-supplier.js.map +1 -0
  22. package/dist/cms-utilization.d.ts +113 -0
  23. package/dist/cms-utilization.d.ts.map +1 -0
  24. package/dist/cms-utilization.js +328 -0
  25. package/dist/cms-utilization.js.map +1 -0
  26. package/dist/courtlistener.d.ts +115 -0
  27. package/dist/courtlistener.d.ts.map +1 -0
  28. package/dist/courtlistener.js +398 -0
  29. package/dist/courtlistener.js.map +1 -0
  30. package/dist/cpsc.d.ts +81 -0
  31. package/dist/cpsc.d.ts.map +1 -0
  32. package/dist/cpsc.js +283 -0
  33. package/dist/cpsc.js.map +1 -0
  34. package/dist/dol.d.ts +2 -2
  35. package/dist/dol.js +5 -5
  36. package/dist/dol.js.map +1 -1
  37. package/dist/epa-envirofacts.d.ts +97 -0
  38. package/dist/epa-envirofacts.d.ts.map +1 -0
  39. package/dist/epa-envirofacts.js +292 -0
  40. package/dist/epa-envirofacts.js.map +1 -0
  41. package/dist/fred.d.ts +1 -1
  42. package/dist/fred.js +1 -1
  43. package/dist/keys.d.ts +6 -5
  44. package/dist/keys.d.ts.map +1 -1
  45. package/dist/keys.js +25 -6
  46. package/dist/keys.js.map +1 -1
  47. package/dist/nhtsa.d.ts +91 -0
  48. package/dist/nhtsa.d.ts.map +1 -0
  49. package/dist/nhtsa.js +263 -0
  50. package/dist/nhtsa.js.map +1 -0
  51. package/dist/nonprofit.d.ts +116 -0
  52. package/dist/nonprofit.d.ts.map +1 -0
  53. package/dist/nonprofit.js +342 -0
  54. package/dist/nonprofit.js.map +1 -0
  55. package/dist/openfda-device.d.ts +85 -0
  56. package/dist/openfda-device.d.ts.map +1 -0
  57. package/dist/openfda-device.js +277 -0
  58. package/dist/openfda-device.js.map +1 -0
  59. package/dist/openfda.d.ts +133 -0
  60. package/dist/openfda.d.ts.map +1 -0
  61. package/dist/openfda.js +402 -0
  62. package/dist/openfda.js.map +1 -0
  63. package/dist/server.d.ts.map +1 -1
  64. package/dist/server.js +666 -7
  65. package/dist/server.js.map +1 -1
  66. package/package.json +2 -1
  67. package/src/bea.ts +1 -1
  68. package/src/census-economic.ts +12 -6
  69. package/src/cms-facility.ts +379 -0
  70. package/src/cms-hospital.ts +344 -0
  71. package/src/cms-supplier.ts +527 -0
  72. package/src/cms-utilization.ts +389 -0
  73. package/src/courtlistener.ts +465 -0
  74. package/src/cpsc.ts +333 -0
  75. package/src/dol.ts +5 -5
  76. package/src/epa-envirofacts.ts +342 -0
  77. package/src/fred.ts +1 -1
  78. package/src/keys.ts +27 -6
  79. package/src/nhtsa.ts +352 -0
  80. package/src/nonprofit.ts +460 -0
  81. package/src/openfda-device.ts +356 -0
  82. package/src/openfda.ts +495 -0
  83. package/src/server.ts +765 -7
@@ -0,0 +1,342 @@
1
+ /**
2
+ * epa-envirofacts.ts — EPA Envirofacts RESTful data service (`data.epa.gov`,
3
+ * `/efservice`), the `tri_facility` table (ADR-0059). KEYLESS.
4
+ *
5
+ * WHAT IT ADDS: `epa_tri_facilities` — a location/compliance lane: look up EPA
6
+ * Toxics Release Inventory (TRI) reporting facilities by state / facility-name /
7
+ * county. This is the demand-side environmental-footprint complement to the
8
+ * market-sizing (Census CBP) and macro (FRED) sources — a place-of-performance
9
+ * environmental screen for a given geography.
10
+ *
11
+ * ★THE TWO-REQUEST PATTERN (the load-bearing P1 honesty): the efservice REST API
12
+ * embeds filters as PATH SEGMENTS and reports NO total in the data slice. So the
13
+ * EXACT total comes from a SEPARATE count sub-query — the identical filter path
14
+ * with a `/count/JSON` tail returns `[{"TOTALQUERYRESULTS": 1247}]`. This tool
15
+ * runs the count FIRST (best-effort) then the data slice: totalAvailable =
16
+ * TOTALQUERYRESULTS (P1, EXACT), NEVER the returned rows' length. If the count
17
+ * sub-query fails or is absent, totalAvailable falls to null + a disclosing note
18
+ * (never a length-faked total) and the data slice still returns.
19
+ *
20
+ * The module writes ZERO fetch/coercion/error/meta code — it REUSES `getJson`
21
+ * (redirect:"error") / `driftError` (datasource.ts), `str`/`num` (coerce.ts,
22
+ * null-never-empty-string / null-never-0), and `withMeta`·`buildMeta` (meta.ts,
23
+ * offset pagination + totalAvailable). It MIRRORS census-economic.ts's
24
+ * fixed-host SSRF idiom (a single host const + a post-construction hostname/
25
+ * protocol assertion + redirect:"error") and datagov-catalog.ts's schema_drift
26
+ * catch-ladder (ToolErrorCarrier rethrow FIRST so a 5xx keeps its taxonomy →
27
+ * SyntaxError→driftError → bare rethrow).
28
+ *
29
+ * GET https://data.epa.gov/efservice/tri_facility/state_abbr/{ST}
30
+ * [/facility_name/CONTAINING/{NAME}] [/county_name/CONTAINING/{COUNTY}]
31
+ * /count/JSON → [{ "TOTALQUERYRESULTS": <int> }] (the total)
32
+ * GET …same filter path… /rows/{offset}:{offset+limit-1}/JSON
33
+ * → [{ tri_facility_id, facility_name, street_address, city_name,
34
+ * county_name, state_abbr, zip_code, region, fac_closed_ind, … }, …]
35
+ *
36
+ * ★ SSRF (the load-bearing guard — values ride as PATH SEGMENTS, not query params):
37
+ * the host is a compile-time literal (`EPA_HOST`); the table + column names + the
38
+ * `CONTAINING` operator + `rows`/`count`/`JSON` are all MODULE literals. Every
39
+ * USER value is BOTH charclass-validated (state `^[A-Za-z]{2}$`; facilityName/
40
+ * county letters/digits/space/&/-/. only, rejecting `/` and `..` path-traversal)
41
+ * AND `encodeURIComponent`-encoded before it joins the path. `offset`/`limit` are
42
+ * coerced to non-negative integers. A post-construction hostname/protocol
43
+ * assertion + `redirect:"error"` fail closed on any off-host 3xx.
44
+ *
45
+ * ★ HONESTY (ADR-0059 P1–P5, live-verified 2026-07-15 on data.epa.gov):
46
+ * [input] require at least `state` OR `facilityName` — an all-empty query is
47
+ * REFUSED with invalid_input (0 fetch) so the whole national table is
48
+ * never scanned.
49
+ * [P1] totalAvailable = the count sub-query's TOTALQUERYRESULTS (EXACT — e.g.
50
+ * VA = 1247), NOT the slice length. hasMore = offset+returned < total.
51
+ * Count fails/absent ⇒ totalAvailable:null + a disclosing note.
52
+ * [P2] an empty array ⇒ honest empty (returned:0, complete:true). getJson maps
53
+ * a 4xx/5xx via errorFromResponse and THROWS (503 ⇒ upstream_unavailable,
54
+ * 400 ⇒ invalid_input, 404 ⇒ not_found); a 200 non-array/non-JSON body ⇒
55
+ * schema_drift (NEVER a fabricated empty).
56
+ * [P3] fac_closed_ind ("0"/"1" live; "N"/"Y" per the schema) ⇒ a normalized
57
+ * boolean `closed` — an UNRECOGNIZED value ⇒ null (never a fabricated
58
+ * false). Addresses/names are strings via `str` (null-never-empty-string).
59
+ * [P4] a data body that is not an array ⇒ driftError; a count body missing
60
+ * TOTALQUERYRESULTS ⇒ totalAvailable:null (handled, not a crash).
61
+ */
62
+
63
+ import { ToolErrorCarrier } from "./errors.js";
64
+ import { getJson, driftError } from "./datasource.js";
65
+ import { str, num } from "./coerce.js";
66
+ import { withMeta, type MetaBundle, type ResponseMeta } from "./meta.js";
67
+
68
+ // Re-export the shared honesty coercions (single audited copy in ./coerce.js) so a
69
+ // regression fails together across sources. NO local num/str.
70
+ export { num, str };
71
+
72
+ // ─── SSRF core: the single fixed host + module-literal path pieces ──
73
+ const EPA_HOST = "data.epa.gov";
74
+ const EPA_TABLE = "tri_facility";
75
+ // HOST+path label — surfaces in ToolError.upstreamEndpoint; keyless, so no token
76
+ // can ever appear here.
77
+ const EPA_LABEL = "epa-envirofacts:/efservice/tri_facility";
78
+
79
+ // ─── Validation charclasses (SSRF + "verify the input" honesty) ───
80
+ // state rides as a PATH SEGMENT → strictly 2 ASCII letters (the efservice filter is
81
+ // case-insensitive; live-verified `va` === `VA`).
82
+ const STATE_RE = /^[A-Za-z]{2}$/;
83
+ // facilityName / county ride as PATH SEGMENTS after `.../CONTAINING/`. Allow only
84
+ // letters / digits / space / & / - / . (a superset of real facility names); this
85
+ // REJECTS `/` (path injection) and any other separator. `..` path-traversal is
86
+ // rejected explicitly below (the charclass permits a lone `.`, so `..` must be
87
+ // caught separately).
88
+ const NAME_RE = /^[A-Za-z0-9 &.\-]+$/;
89
+ const NAME_MAX = 100;
90
+
91
+ const LIMIT_MIN = 1;
92
+ const LIMIT_MAX = 100;
93
+ const LIMIT_DEFAULT = 25;
94
+
95
+ // ─── Honesty notes (ADR-0059 required set) ────────────────────────
96
+ const CLOSED_NOTE =
97
+ "`closed` is the normalized EPA fac_closed_ind ('0'/'N' → false = active, '1'/'Y' → true = closed); an unrecognized value is null (unknown), NEVER a fabricated false. A closed facility no longer actively reports to TRI.";
98
+ const NOMINAL_NOTE =
99
+ "These are EPA TRI (Toxics Release Inventory) REPORTING facilities for the geography — a nominal environmental-footprint screen, NOT a compliance, enforcement, or violation determination. Use ECHO / enforcement sources for compliance status.";
100
+ const COUNT_FALLBACK_NOTE =
101
+ "The count sub-query (…/count/JSON) failed or did not report TOTALQUERYRESULTS, so totalAvailable is null (unknown) — it was NOT faked from the returned row count. hasMore is a heuristic (a full page ⇒ likely more); re-page with offset to confirm.";
102
+
103
+ // ─── Curated facility shape ───────────────────────────────────────
104
+ export type TriFacility = {
105
+ triFacilityId: string | null;
106
+ facilityName: string | null;
107
+ streetAddress: string | null;
108
+ city: string | null;
109
+ county: string | null;
110
+ state: string | null;
111
+ zip: string | null;
112
+ region: string | null;
113
+ closed: boolean | null;
114
+ };
115
+
116
+ /**
117
+ * Normalize EPA's fac_closed_ind to a boolean. Live values are "0" (active) / "1"
118
+ * (closed); the schema also documents "N"/"Y". Anything else ⇒ null (unknown) —
119
+ * NEVER a fabricated false (P3).
120
+ */
121
+ export function normalizeClosed(v: unknown): boolean | null {
122
+ const s = str(v);
123
+ if (s === null) return null;
124
+ const t = s.toUpperCase();
125
+ if (t === "1" || t === "Y" || t === "YES" || t === "TRUE") return true;
126
+ if (t === "0" || t === "N" || t === "NO" || t === "FALSE") return false;
127
+ return null;
128
+ }
129
+
130
+ /** Map ONE efservice row → the curated facility shape (every scalar via `str`). */
131
+ function mapFacility(row: unknown): TriFacility {
132
+ const r = (row ?? {}) as Record<string, unknown>;
133
+ return {
134
+ triFacilityId: str(r.tri_facility_id),
135
+ facilityName: str(r.facility_name),
136
+ streetAddress: str(r.street_address),
137
+ city: str(r.city_name),
138
+ county: str(r.county_name),
139
+ state: str(r.state_abbr),
140
+ zip: str(r.zip_code),
141
+ region: str(r.region),
142
+ closed: normalizeClosed(r.fac_closed_ind),
143
+ };
144
+ }
145
+
146
+ // ─── SSRF-guarded fetch (fixed host + hostname assertion + redirect:"error") ──
147
+ /**
148
+ * GET one efservice JSON resource at a MODULE-BUILT path (all user values already
149
+ * charclass-validated + encodeURIComponent-encoded by the caller). Builds
150
+ * `https://${EPA_HOST}${path}` on the FIXED host, asserts the CONSTRUCTED URL's
151
+ * hostname === the host over https (belt-and-suspenders), and sets
152
+ * `redirect:"error"` (an off-host 3xx must NOT be followed). Keyless — no headers.
153
+ */
154
+ async function getEpa(path: string): Promise<unknown> {
155
+ const url = `https://${EPA_HOST}${path}`;
156
+ const built = new URL(url);
157
+ if (built.hostname !== EPA_HOST || built.protocol !== "https:") {
158
+ throw new ToolErrorCarrier({
159
+ kind: "invalid_input",
160
+ message: `Constructed EPA Envirofacts URL host ${JSON.stringify(built.hostname)} (${built.protocol}) does not match the fixed host ${JSON.stringify(EPA_HOST)} over https — refusing to fetch (SSRF safety).`,
161
+ retryable: false,
162
+ upstreamEndpoint: EPA_LABEL,
163
+ });
164
+ }
165
+ return getJson(built.toString(), { label: EPA_LABEL, redirect: "error" });
166
+ }
167
+
168
+ export type EpaTriFacilitiesArgs = {
169
+ state?: string;
170
+ facilityName?: string;
171
+ county?: string;
172
+ limit?: number;
173
+ offset?: number;
174
+ };
175
+
176
+ /** Validate + encode ONE user path-segment value (facilityName / county). */
177
+ function validateName(value: string, field: string): string {
178
+ if (value.length > NAME_MAX || !NAME_RE.test(value) || value.includes("..")) {
179
+ throw new ToolErrorCarrier({
180
+ kind: "invalid_input",
181
+ retryable: false,
182
+ message: `Invalid ${field} ${JSON.stringify(value)} — allowed: letters, digits, space, & - . (≤${NAME_MAX} chars); '/' and '..' are rejected (it rides in the request PATH as a segment; it is strictly validated to prevent path injection).`,
183
+ upstreamEndpoint: EPA_LABEL,
184
+ });
185
+ }
186
+ return encodeURIComponent(value);
187
+ }
188
+
189
+ /**
190
+ * Look up EPA TRI reporting facilities by state / facilityName / county →
191
+ * normalized facility rows + honest `_meta`. Requires at least `state` OR
192
+ * `facilityName` (an all-empty query is refused). Runs a count sub-query FIRST for
193
+ * the EXACT total (P1), then the data slice; a count failure degrades to
194
+ * totalAvailable:null + a note (never a length-faked total).
195
+ */
196
+ export async function triFacilities(
197
+ args: EpaTriFacilitiesArgs,
198
+ ): Promise<MetaBundle> {
199
+ // ── [input guard] require at least state OR facilityName (never scan the whole
200
+ // national table). ──
201
+ const hasState = args.state !== undefined && args.state !== "";
202
+ const hasName = args.facilityName !== undefined && args.facilityName !== "";
203
+ if (!hasState && !hasName) {
204
+ throw new ToolErrorCarrier({
205
+ kind: "invalid_input",
206
+ retryable: false,
207
+ message:
208
+ "epa_tri_facilities requires at least `state` (2-letter, e.g. 'VA') OR `facilityName` — an all-empty query would scan the entire national TRI table and is refused. Add a filter and retry.",
209
+ upstreamEndpoint: EPA_LABEL,
210
+ });
211
+ }
212
+
213
+ // ── Validate + build the filter path segments (SSRF: charclass + encode each). ──
214
+ const segments: string[] = ["efservice", EPA_TABLE];
215
+ const filtersApplied: string[] = [];
216
+
217
+ if (hasState) {
218
+ const state = args.state as string;
219
+ if (!STATE_RE.test(state)) {
220
+ throw new ToolErrorCarrier({
221
+ kind: "invalid_input",
222
+ retryable: false,
223
+ message: `Invalid state ${JSON.stringify(state)} — expected a 2-letter state code (^[A-Za-z]{2}$), e.g. "VA" (it rides in the request PATH; it is strictly validated).`,
224
+ upstreamEndpoint: EPA_LABEL,
225
+ });
226
+ }
227
+ segments.push("state_abbr", encodeURIComponent(state));
228
+ filtersApplied.push(`state:${state}`);
229
+ }
230
+
231
+ if (hasName) {
232
+ const enc = validateName(args.facilityName as string, "facilityName");
233
+ segments.push("facility_name", "CONTAINING", enc);
234
+ filtersApplied.push(`facilityName~${args.facilityName}`);
235
+ }
236
+
237
+ if (args.county !== undefined && args.county !== "") {
238
+ const enc = validateName(args.county, "county");
239
+ segments.push("county_name", "CONTAINING", enc);
240
+ filtersApplied.push(`county~${args.county}`);
241
+ }
242
+
243
+ // ── Coerce limit / offset to non-negative integers (belt-and-suspenders behind
244
+ // the server Zod; a DIRECT handler call bypasses Zod). ──
245
+ let limit = LIMIT_DEFAULT;
246
+ if (typeof args.limit === "number" && Number.isFinite(args.limit)) {
247
+ limit = Math.trunc(args.limit);
248
+ if (limit < LIMIT_MIN) limit = LIMIT_MIN;
249
+ if (limit > LIMIT_MAX) limit = LIMIT_MAX;
250
+ }
251
+ let offset = 0;
252
+ if (typeof args.offset === "number" && Number.isFinite(args.offset) && args.offset > 0) {
253
+ offset = Math.trunc(args.offset);
254
+ }
255
+
256
+ const filterPath = "/" + segments.join("/");
257
+
258
+ // ── (1) The COUNT sub-query FIRST (best-effort — the EXACT total, P1). Any
259
+ // failure (network/5xx/drift/missing field) degrades to totalAvailable:null +
260
+ // a disclosing note; it NEVER throws and NEVER fakes the total from the slice
261
+ // length. ──
262
+ let totalAvailable: number | null = null;
263
+ let countFailed = false;
264
+ try {
265
+ const countBody = await getEpa(`${filterPath}/count/JSON`);
266
+ if (
267
+ Array.isArray(countBody) &&
268
+ countBody.length > 0 &&
269
+ countBody[0] !== null &&
270
+ typeof countBody[0] === "object"
271
+ ) {
272
+ const t = num((countBody[0] as Record<string, unknown>).TOTALQUERYRESULTS);
273
+ if (t !== null && t >= 0) {
274
+ totalAvailable = t;
275
+ } else {
276
+ countFailed = true; // present body but no usable TOTALQUERYRESULTS (P4)
277
+ }
278
+ } else {
279
+ countFailed = true; // count body not the expected [{...}] shape
280
+ }
281
+ } catch {
282
+ countFailed = true; // any count error ⇒ degrade, never propagate (P1)
283
+ }
284
+
285
+ // ── (2) The DATA slice — the authoritative request. efservice rows are INCLUSIVE
286
+ // on both ends: rows/{offset}:{offset+limit-1}. Its errors follow P2. ──
287
+ const end = offset + limit - 1;
288
+ const dataPath = `${filterPath}/rows/${offset}:${end}/JSON`;
289
+
290
+ // Catch-ladder (datagov-catalog shape, VERBATIM): preserve the 4xx/5xx/timeout
291
+ // ToolErrorCarrier taxonomy FIRST; reclassify a 200 non-JSON SyntaxError to
292
+ // schema_drift SECOND; bare-rethrow LAST.
293
+ let body: unknown;
294
+ try {
295
+ body = await getEpa(dataPath);
296
+ } catch (e) {
297
+ if (e instanceof ToolErrorCarrier) throw e;
298
+ if (e instanceof SyntaxError)
299
+ throw driftError(
300
+ EPA_LABEL,
301
+ "EPA Envirofacts returned a non-JSON body at HTTP 200 — schema drift (never read as an empty result).",
302
+ );
303
+ throw e;
304
+ }
305
+
306
+ // [P4] the data body MUST be an array (a non-array 200 is drift, never a
307
+ // fabricated empty).
308
+ if (!Array.isArray(body)) {
309
+ throw driftError(
310
+ EPA_LABEL,
311
+ "EPA Envirofacts shape drift — the /rows/…/JSON response must be a JSON array of facilities.",
312
+ );
313
+ }
314
+
315
+ const facilities = (body as unknown[]).map(mapFacility);
316
+ const returned = facilities.length;
317
+
318
+ // ── [P1] pagination. total known ⇒ hasMore = offset+returned < total; total
319
+ // unknown (count degraded) ⇒ a full page is the honest heuristic for "more". ──
320
+ const hasMore =
321
+ totalAvailable !== null
322
+ ? offset + returned < totalAvailable
323
+ : returned === limit;
324
+ const nextOffset = hasMore ? offset + returned : null;
325
+
326
+ const notes: string[] = [CLOSED_NOTE, NOMINAL_NOTE];
327
+ if (countFailed) notes.push(COUNT_FALLBACK_NOTE);
328
+
329
+ const meta: Partial<ResponseMeta> = {
330
+ source: `${EPA_HOST} EPA Envirofacts /efservice/${EPA_TABLE} (TRI facilities; keyless)`,
331
+ keylessMode: true,
332
+ returned,
333
+ totalAvailable,
334
+ filtersApplied,
335
+ filtersDropped: [],
336
+ fieldsUnavailable: [],
337
+ pagination: { offset, limit, hasMore, nextOffset },
338
+ notes,
339
+ };
340
+
341
+ return withMeta({ facilities }, meta);
342
+ }
package/src/fred.ts CHANGED
@@ -8,7 +8,7 @@
8
8
  * FRED has NO keyless tier: every request needs `&api_key=`, and a missing/bad
9
9
  * key returns HTTP 400 `{error_code, error_message}`. So, honestly: with NO
10
10
  * `FRED_API_KEY` these two tools THROW an `invalid_input` config error BEFORE any
11
- * fetch (never a fake-empty, never a keyless-pretend). The other 112 tools stay
11
+ * fetch (never a fake-empty, never a keyless-pretend). The other tools stay
12
12
  * keyless — this key is scoped to this one source. (Contrast the OPTIONAL keys of
13
13
  * datagov/bls/nvd, which lift a tier but are not required.)
14
14
  *
package/src/keys.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Why this exists
5
5
  * ----------------
6
- * The server rides 31 federal sources. MOST are fully keyless. But the set of
6
+ * The server rides dozens of federal data sources. MOST are fully keyless. But the set of
7
7
  * *optional* keys (raise a rate limit, unlock one filter) plus the four *required*
8
8
  * keys (Census business-patterns, FRED, BEA Regional, DOL data) has grown to the point where a user — or
9
9
  * the AI driving the server — cannot tell, without reading source code:
@@ -20,8 +20,9 @@
20
20
  * `process.env.<NAME>` — DATA_GOV_API_KEY (datagovKey.ts), SAM_GOV_API_KEY
21
21
  * (server.ts), BLS_API_KEY (bls.ts), NVD_API_KEY (nvd.ts), SOCRATA_APP_TOKEN
22
22
  * (socrata.ts), CENSUS_API_KEY (census-economic.ts), FRED_API_KEY (fred.ts),
23
- * BEA_API_KEY (bea.ts), DOL_API_KEY (dol.ts), LDA_API_KEY (lda.ts). No invented
24
- * keys, sources, or signup URLs.
23
+ * BEA_API_KEY (bea.ts), DOL_API_KEY (dol.ts), LDA_API_KEY (lda.ts),
24
+ * OPENFDA_API_KEY (openfda.ts), COURTLISTENER_API_TOKEN (courtlistener.ts).
25
+ * No invented keys, sources, or signup URLs.
25
26
  */
26
27
 
27
28
  import { readFileSync } from "node:fs";
@@ -44,11 +45,11 @@ export type KeyRegistryEntry = {
44
45
  };
45
46
 
46
47
  /**
47
- * The 10 keys the server reads — code-grounded, no inventions.
48
+ * The 12 keys the server reads — code-grounded, no inventions.
48
49
  *
49
50
  * REQUIRED (4): CENSUS_API_KEY, FRED_API_KEY, BEA_API_KEY, DOL_API_KEY — those sources
50
51
  * have no keyless tier, so the tool throws without them (DOL_API_KEY gates ONLY
51
- * dol_get_dataset; the DOL catalog, dol_list_datasets, is keyless). OPTIONAL (6):
52
+ * dol_get_dataset; the DOL catalog, dol_list_datasets, is keyless). OPTIONAL (8):
52
53
  * everything else works keyless; a key only raises a rate limit or unlocks a single filter.
53
54
  */
54
55
  export const KEY_REGISTRY: readonly KeyRegistryEntry[] = [
@@ -131,7 +132,7 @@ export const KEY_REGISTRY: readonly KeyRegistryEntry[] = [
131
132
  "US DOL enforcement data (dol_get_dataset; dol_list_datasets is keyless)",
132
133
  ],
133
134
  required: true,
134
- signupUrl: "https://dol.gov/developer",
135
+ signupUrl: "https://dataportal.dol.gov/registration",
135
136
  unlocks:
136
137
  "the dol_get_dataset tool (dataset records need a free key; dol_list_datasets works keyless)",
137
138
  note: "The DOL data endpoint needs a free key; the dataset CATALOG (dol_list_datasets) and agency list are keyless.",
@@ -145,6 +146,26 @@ export const KEY_REGISTRY: readonly KeyRegistryEntry[] = [
145
146
  "higher LDA API rate limits (anonymous access already works without it)",
146
147
  note: "Keyless by default (anonymous 200); a free token only raises the rate limit.",
147
148
  },
149
+ {
150
+ envVar: "OPENFDA_API_KEY",
151
+ sources: ["openFDA enforcement (openfda_enforcement)"],
152
+ required: false,
153
+ signupUrl: "https://open.fda.gov/apis/authentication/",
154
+ unlocks:
155
+ "higher openFDA rate limits (keyless works without it — ~1000/day)",
156
+ note: "Keyless by default; a free key raises the rate limit.",
157
+ },
158
+ {
159
+ envVar: "COURTLISTENER_API_TOKEN",
160
+ sources: [
161
+ "CourtListener federal court opinions (courtlistener_search_opinions)",
162
+ ],
163
+ required: false,
164
+ signupUrl: "https://www.courtlistener.com/help/api/rest/",
165
+ unlocks:
166
+ "higher CourtListener rate limits (anonymous search works without it)",
167
+ note: "Keyless by default (anonymous 200); a free token only raises the rate limit. Data = US federal court public records via CourtListener/Free Law Project.",
168
+ },
148
169
  ] as const;
149
170
 
150
171
  /** true iff the env var is set to a non-empty (after-trim) string. */