@cliwant/mcp-sam-gov 1.13.2 → 1.15.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.
@@ -0,0 +1,329 @@
1
+ /**
2
+ * State & local data map — single source of truth.
3
+ *
4
+ * These entries are exported for:
5
+ * (a) the MCP resource samgov://data-map/state-local (resources/read)
6
+ * (b) consistency tests (SKILL.md table must agree on domain/id/rows)
7
+ *
8
+ * Keep verified row counts and notes current here only; SKILL.md table and
9
+ * the resource content are generated from this array.
10
+ */
11
+
12
+ export type DataMapTool =
13
+ | "socrata_query"
14
+ | "ckan_query"
15
+ | "tableau_view_csv"
16
+ | "open_checkbook_search";
17
+
18
+ export interface DataMapEntry {
19
+ /** Two-letter state abbreviation for grouping */
20
+ state: string;
21
+ /** Human-readable jurisdiction name */
22
+ jurisdiction: string;
23
+ /** Short description of what the dataset contains */
24
+ dataLabel: string;
25
+ /** Tool to call */
26
+ tool: DataMapTool;
27
+ /** Key args to pass — human-readable form for doc */
28
+ keyArgs: string;
29
+ /** Verified approximate row count (null = not precisely known) */
30
+ rows: number | null;
31
+ /** Approximate flag — when true prefix rows with '~' */
32
+ approximate: boolean;
33
+ /** What this dataset is NOT (common agent error) */
34
+ notNote: string;
35
+ /** Extra notes (optional) */
36
+ extra?: string;
37
+ }
38
+
39
+ /**
40
+ * Verified 2026-09-21 — all keyless.
41
+ */
42
+ export const DATA_MAP_ENTRIES: DataMapEntry[] = [
43
+ // ── State-level ──────────────────────────────────────────────────────────
44
+ {
45
+ state: "VA",
46
+ jurisdiction: "Virginia",
47
+ dataLabel: "eVA PO line items 2023",
48
+ tool: "ckan_query",
49
+ keyArgs: "host=data.virginia.gov, resourceId=3c7f1bde-35b0-4fbf-b89c-978a19124d53",
50
+ rows: 1693227,
51
+ approximate: false,
52
+ notNote: "the live eVA portal (login-gated)",
53
+ extra:
54
+ "Years 2016–2026 have separate resourceIds; ckan_discover_datasets host=data.virginia.gov q=eVA procurement lists them (2024=25a59527, 2025=b8dc22a8, 2026=76f6831d)",
55
+ },
56
+ {
57
+ state: "MA",
58
+ jurisdiction: "Massachusetts",
59
+ dataLabel: "Comptroller vendor payments (CTHRU)",
60
+ tool: "socrata_query",
61
+ keyArgs: "domain=cthru.data.socrata.com, datasetId=pegc-naaa",
62
+ rows: 49000000,
63
+ approximate: true,
64
+ notNote: "an award or bid register; these are payment transactions",
65
+ },
66
+ {
67
+ state: "NJ",
68
+ jurisdiction: "New Jersey",
69
+ dataLabel: "YourMoney agency purchasing by vendor",
70
+ tool: "socrata_query",
71
+ keyArgs: "domain=data.nj.gov, datasetId=ubnu-tqu7",
72
+ rows: 660425,
73
+ approximate: false,
74
+ notNote: "a solicitation or bid register; agency expenditure rows",
75
+ },
76
+ {
77
+ state: "NY",
78
+ jurisdiction: "New York",
79
+ dataLabel: "State authority procurement contracts",
80
+ tool: "socrata_query",
81
+ keyArgs: "domain=data.ny.gov, datasetId=ehig-g5x3",
82
+ rows: 275763,
83
+ approximate: false,
84
+ notNote: "all NYS agencies (authorities only) and NOT active solicitations",
85
+ },
86
+ {
87
+ state: "NY",
88
+ jurisdiction: "New York",
89
+ dataLabel: "MTA procurement contracts",
90
+ tool: "socrata_query",
91
+ keyArgs: "domain=data.ny.gov, datasetId=twsw-2mqa",
92
+ rows: 107503,
93
+ approximate: false,
94
+ notNote: "a live MTA bid portal; MTA historical contract records",
95
+ },
96
+ {
97
+ state: "WA",
98
+ jurisdiction: "Washington",
99
+ dataLabel: "Agency contract register",
100
+ tool: "socrata_query",
101
+ keyArgs: "domain=data.wa.gov, datasetId=s8d5-pj78",
102
+ rows: 79329,
103
+ approximate: false,
104
+ notNote: "a solicitation or bid feed; awarded contract records",
105
+ },
106
+ {
107
+ state: "WA",
108
+ jurisdiction: "Washington",
109
+ dataLabel: "Master-contract sales by vendor/customer",
110
+ tool: "socrata_query",
111
+ keyArgs: "domain=data.wa.gov, datasetId=n8q6-4twj",
112
+ rows: 245831,
113
+ approximate: false,
114
+ notNote: "open bids; sales reported off statewide master contracts",
115
+ },
116
+ {
117
+ state: "MT",
118
+ jurisdiction: "Montana",
119
+ dataLabel: "DOA contracts awarded",
120
+ tool: "tableau_view_csv",
121
+ keyArgs: "view=mt_contracts_awarded",
122
+ rows: 4554,
123
+ approximate: true,
124
+ notNote: "a bid portal; awarded records only, freshness set by publisher",
125
+ },
126
+ {
127
+ state: "SD",
128
+ jurisdiction: "South Dakota",
129
+ dataLabel: "Open Checkbook vendor payments",
130
+ tool: "open_checkbook_search",
131
+ keyArgs: "portal=sd",
132
+ rows: 741000,
133
+ approximate: true,
134
+ notNote: "an award register; only ~3 most-recent FYs, exact-match filters",
135
+ },
136
+ {
137
+ state: "IL",
138
+ jurisdiction: "Illinois",
139
+ dataLabel: "CDB capital project future bids",
140
+ tool: "socrata_query",
141
+ keyArgs: "domain=data.illinois.gov, datasetId=6rb8-ntpm",
142
+ rows: 48,
143
+ approximate: false,
144
+ notNote: "a comprehensive solicitation feed; only ~48 upcoming CDB capital bids",
145
+ },
146
+ {
147
+ state: "IL",
148
+ jurisdiction: "Illinois",
149
+ dataLabel: "IDHR certified eligible bidders",
150
+ tool: "socrata_query",
151
+ keyArgs: "domain=data.illinois.gov, datasetId=w8h2-q8hu",
152
+ rows: 7848,
153
+ approximate: false,
154
+ notNote: "a bid or award register; vendor-eligibility directory only",
155
+ },
156
+ // ── Texas — verified 2026-09-21 ──────────────────────────────────────────
157
+ {
158
+ state: "TX",
159
+ jurisdiction: "Texas",
160
+ dataLabel: "TxDOT current lettings (★live bid-line items)",
161
+ tool: "socrata_query",
162
+ keyArgs: "domain=data.texas.gov, datasetId=qh8x-rm8r",
163
+ rows: 8861,
164
+ approximate: false,
165
+ notNote:
166
+ "rows are bid LINE ITEMS not projects (8,861 rows = 412 distinct project_ids — report project count not row count); TxDOT highway lettings ONLY, not all Texas procurement; rolling window only (past lettings dropped, cannot answer historical questions); ESBD/TxSmartBuy non-TxDOT solicitations are absent",
167
+ extra:
168
+ "★First live state solicitation feed in this map. Use $select=count(distinct project_id) for open-bid count.",
169
+ },
170
+ {
171
+ state: "TX",
172
+ jurisdiction: "Texas",
173
+ dataLabel: "DIR Cooperative Contract Sales FY2010–FY2025 (archive)",
174
+ tool: "socrata_query",
175
+ keyArgs: "domain=data.texas.gov, datasetId=w64c-ndf7",
176
+ rows: 10749743,
177
+ approximate: false,
178
+ notNote: "bids or awards; purchase line items off DIR cooperative contracts (historical)",
179
+ },
180
+ {
181
+ state: "TX",
182
+ jurisdiction: "Texas",
183
+ dataLabel: "DIR Cooperative & Tele Contract Sales FY2026",
184
+ tool: "socrata_query",
185
+ keyArgs: "domain=data.texas.gov, datasetId=a743-wj72",
186
+ rows: 2077855,
187
+ approximate: false,
188
+ notNote: "historical FY2026 purchase lines (same shape as w64c-ndf7); not bids",
189
+ },
190
+ {
191
+ state: "TX",
192
+ jurisdiction: "Texas",
193
+ dataLabel: "DIR Current Active Cooperative Contracts",
194
+ tool: "socrata_query",
195
+ keyArgs: "domain=data.texas.gov, datasetId=vipt-h4ye",
196
+ rows: 5167,
197
+ approximate: false,
198
+ notNote: "a solicitation feed; active cooperative contract register (not TxDOT lettings)",
199
+ },
200
+ {
201
+ state: "TX",
202
+ jurisdiction: "Texas",
203
+ dataLabel: "TCEQ Current Contracts & Purchase Orders",
204
+ tool: "socrata_query",
205
+ keyArgs: "domain=data.texas.gov, datasetId=svjm-sdfz",
206
+ rows: 2067,
207
+ approximate: false,
208
+ notNote: "statewide; one agency (TCEQ) only",
209
+ },
210
+ // ── Maryland — verified 2026-09-21 ───────────────────────────────────────
211
+ {
212
+ state: "MD",
213
+ jurisdiction: "Maryland",
214
+ dataLabel: "eMaryland Marketplace (eMMA) bids — FY2018 exemplar",
215
+ tool: "socrata_query",
216
+ keyArgs: "domain=opendata.maryland.gov, datasetId=pgna-cxjh",
217
+ rows: 107303,
218
+ approximate: false,
219
+ notNote:
220
+ "rows are bid LINE ITEMS not bids — FY2018 is 107,303 rows for only 3,067 bids (35× overcount); always use $select=count(distinct bid_number) for actual bid count. Coverage stops at FY2019 — eMMA migrated to Periscope mid-FY2019; there is no FY2020+ mirror and this dataset cannot answer questions about current Maryland bids",
221
+ extra:
222
+ "All six FY datasetIds: FY2018=pgna-cxjh (107,303 rows/3,067 bids), FY2017=qkjf-rv4t (64,331/4,943), FY2016=7ang-84wj (45,204/4,818), FY2015=3hzs-sazv (46,895/4,898), FY2014=itax-4ccz (45,551/4,884), FY2019=ttg5-zfzj (4,623/388 — small because eMMA migrated to Periscope mid-year; first row is a sparse placeholder, subsequent rows are complete).",
223
+ },
224
+ // ── Oregon — verified 2026-09-21 ─────────────────────────────────────────
225
+ {
226
+ state: "OR",
227
+ jurisdiction: "Oregon",
228
+ dataLabel: "OregonBuys Purchases and Contracts FY2022–FY2025",
229
+ tool: "socrata_query",
230
+ keyArgs: "domain=data.oregon.gov, datasetId=qyug-f2km",
231
+ rows: 109119,
232
+ approximate: false,
233
+ notNote:
234
+ "open solicitations — these are issued purchase orders and contracts (not bids). ORPIN was the retired system; OregonBuys is its replacement. qyug-f2km covers sent_date 2021-07-01 → 2025-07-01 (FY2022–FY2025); 92,224 distinct po_nbr",
235
+ extra:
236
+ "Historical ORPIN datasets (retired system, same domain): Contracts Issued=6e9e-sfc4 (93,846 rows), Contracts Expired=8izy-bwhd (92,755 rows), Statewide Price Agreement Spend=gart-52me (5,224 rows). All keyless.",
237
+ },
238
+ // ── Vermont — verified 2026-09-21 ────────────────────────────────────────
239
+ {
240
+ state: "VT",
241
+ jurisdiction: "Vermont",
242
+ dataLabel: "Purchase Orders with Vendor Information (current FY, live-ish)",
243
+ tool: "socrata_query",
244
+ keyArgs: "domain=data.vermont.gov, datasetId=8ewu-igdm",
245
+ rows: 111271,
246
+ approximate: false,
247
+ notNote:
248
+ "a bid or award register — issued purchase orders. 39,882 distinct po_id (~2.8 line items per PO). po_date 2025-07-02 → 2026-06-19 (current fiscal year, so this is live-ish state spend, not an archive)",
249
+ },
250
+ // ── Colorado (City of Denver on state portal) — verified 2026-09-21 ──────
251
+ {
252
+ state: "CO",
253
+ jurisdiction: "City of Denver",
254
+ dataLabel: "City of Denver Procurement Transactions (on CO state portal)",
255
+ tool: "socrata_query",
256
+ keyArgs: "domain=data.colorado.gov, datasetId=66zf-qjdd",
257
+ rows: 76357,
258
+ approximate: false,
259
+ notNote:
260
+ "Colorado STATE procurement — this is City of Denver spend hosted on the Colorado state portal (data.colorado.gov). An agent that reads the domain as the jurisdiction gets this wrong. Updated 2026-09-20.",
261
+ },
262
+ {
263
+ state: "CO",
264
+ jurisdiction: "City of Denver",
265
+ dataLabel: "City of Denver Checkbook (on CO state portal)",
266
+ tool: "socrata_query",
267
+ keyArgs: "domain=data.colorado.gov, datasetId=wnau-xrqi",
268
+ rows: 154595,
269
+ approximate: false,
270
+ notNote:
271
+ "Colorado STATE procurement — this is City of Denver checkbook data hosted on the Colorado state portal (data.colorado.gov). An agent that reads the domain as the jurisdiction gets this wrong. Updated 2026-09-20.",
272
+ },
273
+ ];
274
+
275
+ /**
276
+ * Format a row count for display.
277
+ *
278
+ * HONESTY: an EXACT count (approximate:false) is printed in full with thousands
279
+ * separators — never rounded. The table header promises a "verified row count",
280
+ * so rounding a measured 1,693,227 to "2M" would overstate it by 18% while still
281
+ * reading as exact. Only an entry explicitly marked `approximate` is rounded, and
282
+ * that form always carries a leading `~` so the reader can tell the two apart.
283
+ */
284
+ function fmtRows(e: DataMapEntry): string {
285
+ if (e.rows === null) return "?";
286
+ if (!e.approximate) return e.rows.toLocaleString("en-US");
287
+ // Keep 2 significant figures below 10 units so "~5k" never stands in for a
288
+ // measured 4,554 (a 10% overstatement); 49,000,000 still renders "~49M".
289
+ const scale = (v: number, suffix: string) =>
290
+ `${v < 10 ? v.toFixed(1).replace(/\.0$/, "") : String(Math.round(v))}${suffix}`;
291
+ const n = e.rows >= 1000000 ? scale(e.rows / 1000000, "M") :
292
+ e.rows >= 1000 ? scale(e.rows / 1000, "k") :
293
+ String(e.rows);
294
+ return `~${n}`;
295
+ }
296
+
297
+ /**
298
+ * Render the state-level entries as a Markdown table.
299
+ * Matches the format in SKILL.md §State & local data map.
300
+ */
301
+ export function renderStateTableMarkdown(): string {
302
+ const header =
303
+ "| Jurisdiction | Data | Tool · key args | Rows | NOT |\n" +
304
+ "|---|---|---|---|---|\n";
305
+ const rows = DATA_MAP_ENTRIES.map((e) => {
306
+ const extra = e.extra ? ` ${e.extra}` : "";
307
+ return `| **${e.jurisdiction}** | ${e.dataLabel} | \`${e.tool}\` ${e.keyArgs} | ${fmtRows(e)} | ${e.notNote}${extra} |`;
308
+ });
309
+ return header + rows.join("\n");
310
+ }
311
+
312
+ /** Full resource content: header + state table */
313
+ export function renderDataMapMarkdown(): string {
314
+ return `# State & local data map
315
+
316
+ Agent-readable lookup: jurisdiction → data type → exact tool call → verified row count → what it is NOT (the most common source of agent error).
317
+
318
+ **State-level open-data sources (verified 2026-09-21, all keyless):**
319
+
320
+ ${renderStateTableMarkdown()}
321
+
322
+ **County & city** — use \`socrata_discover_datasets\` to find dataset IDs for: NYC (data.cityofnewyork.us), Chicago (data.cityofchicago.org), Austin TX (data.austintexas.gov), Dallas TX (www.dallasopendata.com), LA (controllerdata.lacity.org), King County WA (data.kingcounty.gov), Cook County IL (datacatalog.cookcountyil.gov), Montgomery County MD (data.montgomerycountymd.gov). For Hennepin County MN and Charlotte-Mecklenburg NC capital project pipelines, use \`arcgis_feature_query\` (hennepin_transportation_cip / charlotte_mecklenburg_cip) — these are CIP pipelines, NOT solicitation or award registers.
323
+
324
+ **State portals with no keyless procurement content (measured absence, not unexplored):**
325
+ - Login-gated or WAF-blocked live-bid portals: CA (Cal eProcure), TX ESBD/TxSmartBuy non-TxDOT (TxDOT lettings ARE available via qh8x-rm8r above), OH, NC, MI, and Periscope-based portals for IL/MA/NJ live bids.
326
+ - Portal exists but carries no procurement datasets: PA (data.pa.gov is live; scoped catalog has 0 bid/vendor/procurement datasets matching). Michigan (data.michigan.gov) was checked 2026-09-21 and carries only NIGP commodity code reference tables (w3u3-uptp 9,333 rows; jv5q-yp8x 235 rows) — not procurement transactions.
327
+ - No state-level open-data portal: FL (data.fl.gov NXDOMAIN), GA (data.georgia.gov NXDOMAIN). These states have no keyless state procurement data source — this is a measured absence, not a connectivity block.
328
+ `;
329
+ }
package/src/errors.ts CHANGED
@@ -32,7 +32,12 @@ export type ErrorKind =
32
32
  /** API returned 200 but we couldn't parse / shape doesn't match. */
33
33
  | "schema_drift"
34
34
  /** Anything else. Don't retry. */
35
- | "unknown";
35
+ | "unknown"
36
+ /**
37
+ * The tool exists in the registry but is not loaded in the current toolset
38
+ * profile. Set MCP_SAM_GOV_TOOLSETS to enable the required toolset.
39
+ */
40
+ | "tool_not_loaded";
36
41
 
37
42
  export type ToolError = {
38
43
  kind: ErrorKind;