@cyanheads/usaspending-mcp-server 0.4.4 → 0.5.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 (71) hide show
  1. package/AGENTS.md +12 -11
  2. package/CLAUDE.md +12 -11
  3. package/Dockerfile +91 -44
  4. package/README.md +34 -30
  5. package/changelog/0.4.x/0.4.5.md +31 -0
  6. package/changelog/0.5.x/0.5.0.md +50 -0
  7. package/dist/config/server-config.d.ts.map +1 -1
  8. package/dist/config/server-config.js +3 -3
  9. package/dist/config/server-config.js.map +1 -1
  10. package/dist/index.js +1 -0
  11. package/dist/index.js.map +1 -1
  12. package/dist/mcp-server/tools/definitions/autocomplete-filters.tool.d.ts +8 -1
  13. package/dist/mcp-server/tools/definitions/autocomplete-filters.tool.d.ts.map +1 -1
  14. package/dist/mcp-server/tools/definitions/autocomplete-filters.tool.js +94 -35
  15. package/dist/mcp-server/tools/definitions/autocomplete-filters.tool.js.map +1 -1
  16. package/dist/mcp-server/tools/definitions/disaster-spending.tool.d.ts +2 -1
  17. package/dist/mcp-server/tools/definitions/disaster-spending.tool.d.ts.map +1 -1
  18. package/dist/mcp-server/tools/definitions/disaster-spending.tool.js +60 -26
  19. package/dist/mcp-server/tools/definitions/disaster-spending.tool.js.map +1 -1
  20. package/dist/mcp-server/tools/definitions/filters.d.ts +73 -4
  21. package/dist/mcp-server/tools/definitions/filters.d.ts.map +1 -1
  22. package/dist/mcp-server/tools/definitions/filters.js +138 -4
  23. package/dist/mcp-server/tools/definitions/filters.js.map +1 -1
  24. package/dist/mcp-server/tools/definitions/get-agency.tool.d.ts +22 -3
  25. package/dist/mcp-server/tools/definitions/get-agency.tool.d.ts.map +1 -1
  26. package/dist/mcp-server/tools/definitions/get-agency.tool.js +170 -33
  27. package/dist/mcp-server/tools/definitions/get-agency.tool.js.map +1 -1
  28. package/dist/mcp-server/tools/definitions/get-award.tool.d.ts +8 -3
  29. package/dist/mcp-server/tools/definitions/get-award.tool.d.ts.map +1 -1
  30. package/dist/mcp-server/tools/definitions/get-award.tool.js +149 -140
  31. package/dist/mcp-server/tools/definitions/get-award.tool.js.map +1 -1
  32. package/dist/mcp-server/tools/definitions/get-federal-account.tool.d.ts.map +1 -1
  33. package/dist/mcp-server/tools/definitions/get-federal-account.tool.js +1 -1
  34. package/dist/mcp-server/tools/definitions/get-federal-account.tool.js.map +1 -1
  35. package/dist/mcp-server/tools/definitions/get-idv-awards.tool.d.ts.map +1 -1
  36. package/dist/mcp-server/tools/definitions/get-idv-awards.tool.js +14 -12
  37. package/dist/mcp-server/tools/definitions/get-idv-awards.tool.js.map +1 -1
  38. package/dist/mcp-server/tools/definitions/get-recipient.tool.d.ts +2 -8
  39. package/dist/mcp-server/tools/definitions/get-recipient.tool.d.ts.map +1 -1
  40. package/dist/mcp-server/tools/definitions/get-recipient.tool.js +29 -29
  41. package/dist/mcp-server/tools/definitions/get-recipient.tool.js.map +1 -1
  42. package/dist/mcp-server/tools/definitions/index.d.ts +130 -28
  43. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
  44. package/dist/mcp-server/tools/definitions/locations.d.ts +45 -0
  45. package/dist/mcp-server/tools/definitions/locations.d.ts.map +1 -0
  46. package/dist/mcp-server/tools/definitions/locations.js +206 -0
  47. package/dist/mcp-server/tools/definitions/locations.js.map +1 -0
  48. package/dist/mcp-server/tools/definitions/search-awards.tool.d.ts +28 -8
  49. package/dist/mcp-server/tools/definitions/search-awards.tool.d.ts.map +1 -1
  50. package/dist/mcp-server/tools/definitions/search-awards.tool.js +112 -84
  51. package/dist/mcp-server/tools/definitions/search-awards.tool.js.map +1 -1
  52. package/dist/mcp-server/tools/definitions/spending-by-category.tool.d.ts +21 -2
  53. package/dist/mcp-server/tools/definitions/spending-by-category.tool.d.ts.map +1 -1
  54. package/dist/mcp-server/tools/definitions/spending-by-category.tool.js +79 -14
  55. package/dist/mcp-server/tools/definitions/spending-by-category.tool.js.map +1 -1
  56. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.d.ts +21 -2
  57. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.d.ts.map +1 -1
  58. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.js +95 -22
  59. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.js.map +1 -1
  60. package/dist/mcp-server/tools/definitions/spending-over-time.tool.d.ts +19 -1
  61. package/dist/mcp-server/tools/definitions/spending-over-time.tool.d.ts.map +1 -1
  62. package/dist/mcp-server/tools/definitions/spending-over-time.tool.js +62 -14
  63. package/dist/mcp-server/tools/definitions/spending-over-time.tool.js.map +1 -1
  64. package/dist/services/usaspending/types.d.ts +24 -16
  65. package/dist/services/usaspending/types.d.ts.map +1 -1
  66. package/dist/services/usaspending/usaspending-service.d.ts +45 -27
  67. package/dist/services/usaspending/usaspending-service.d.ts.map +1 -1
  68. package/dist/services/usaspending/usaspending-service.js +103 -64
  69. package/dist/services/usaspending/usaspending-service.js.map +1 -1
  70. package/package.json +15 -13
  71. package/server.json +10 -24
@@ -0,0 +1,50 @@
1
+ ---
2
+ summary: "Autocomplete agency rows drop id and name the matched agency; get_agency rejects both identifiers; nested filter keys are strict. Fixes location_filter normalization, analytics code filters, geography shape_codes, award-detail fields, recipient fiscal-year totals, agency budget years, truncation labels, and request timeouts."
3
+ breaking: true
4
+ security: false
5
+ ---
6
+
7
+ # 0.5.0 — 2026-10-12
8
+
9
+ ## Added
10
+
11
+ - **`psc_codes`, `def_codes`, and `assistance_listings`** filter the `filters` of `usaspending_spending_by_geography`, `usaspending_spending_by_category`, and `usaspending_spending_over_time`, and `usaspending_search_awards` takes all three both flat and inside its `filters` (it took only a flat `assistance_listings` before), each echoed as `applied_*` ([#77](https://github.com/cyanheads/usaspending-mcp-server/issues/77)). PSC and DEF codes are sent uppercased; `assistance_listings` with only contract or IDV award types fails as `assistance_listings_type_mismatch`, `psc_codes` with only assistance types as `psc_codes_type_mismatch`.
12
+ - **`usaspending_spending_by_geography` `shape_codes`** (1–500, beside `limit`) returns only the listed areas, reaching counties ranked past `limit`; the codes echo as `applied_shape_codes` and an unmatched code is named in the `notice` ([#72](https://github.com/cyanheads/usaspending-mcp-server/issues/72)).
13
+ - **`usaspending_get_award` `assistance_listings[]`** (`number`, `title`, `obligation`), `recipient.parent_uei`, `recipient.parent_recipient_id`, `recipient.business_categories`, and `total_loan_value` / `total_subsidy_cost` on loans; `recipient.uei` and the three-letter `country_code` on `recipient.location` and `place_of_performance` are now populated ([#68](https://github.com/cyanheads/usaspending-mcp-server/issues/68)).
14
+ - **`usaspending_get_recipient` `period`** names the totals window, `FY<year>` or `trailing 12 months` ([#67](https://github.com/cyanheads/usaspending-mcp-server/issues/67)).
15
+ - **`usaspending_get_agency` `sub_agency_fiscal_year`** and an optional **`unavailable_sections`** listing each failed section with its `reason` ([#86](https://github.com/cyanheads/usaspending-mcp-server/issues/86), [#69](https://github.com/cyanheads/usaspending-mcp-server/issues/69)).
16
+ - **`usaspending_spending_by_category`** `recipient_duns` rows carry `recipient_id` and `uei` when upstream has them ([#83](https://github.com/cyanheads/usaspending-mcp-server/issues/83)).
17
+ - **`invalid_location`** (`usaspending_search_awards`), **`psc_codes_type_mismatch`** (`usaspending_search_awards` and the three spending analytics tools), and **`conflicting_input`** (`usaspending_get_agency`) typed failures; `assistance_listings_type_mismatch`, until now on `usaspending_search_awards` alone, is added to the three spending analytics tools.
18
+
19
+ ## Changed
20
+
21
+ - **BREAKING: unknown keys inside the nested `filters`, `time_period`, and `location_filter` objects are rejected** with the key path named (for example `time_period.fiscal_year`); they were dropped and the call ran without them ([#74](https://github.com/cyanheads/usaspending-mcp-server/issues/74)). `usaspending_search_awards` rejects `filters.recipient_id`.
22
+ - **BREAKING: `usaspending_autocomplete_filters` agency rows drop `id`** and carry the matched agency's own `name` (the top-tier parent was returned for a sub-agency), with `abbreviation`, `tier`, and the parent in `toptier_name` / `toptier_code`; `code` is no longer advertised for agencies ([#71](https://github.com/cyanheads/usaspending-mcp-server/issues/71)).
23
+ - **BREAKING: `usaspending_get_agency` rejects any call with both `toptier_code` and `agency_slug`** as `conflicting_input`, a matching pair included ([#75](https://github.com/cyanheads/usaspending-mcp-server/issues/75)).
24
+ - **`usaspending_search_awards` `location_filter` is normalized** (`country` defaults to `USA`, a territory code becomes `USA` plus its state, a 2-digit FIPS `state` becomes its postal code, a 5-digit county FIPS stands alone) and echoed as `applied_location`. A malformed `country`, `state`, or `county` fails as `-32602`; an unknown US state, a county without a state or with an armed-forces state (`AA`/`AE`/`AP`), a county or FIPS-number state under a non-USA country, and parts that name different states fail as `invalid_location` ([#70](https://github.com/cyanheads/usaspending-mcp-server/issues/70)).
25
+ - **`usaspending_get_recipient` totals** cover the requested `fiscal_year` instead of always the trailing 12 months ([#67](https://github.com/cyanheads/usaspending-mcp-server/issues/67)).
26
+ - **`usaspending_get_agency`** reports the most recent fiscal year with budget data, and `sub_agencies` cover that same year ([#81](https://github.com/cyanheads/usaspending-mcp-server/issues/81), [#86](https://github.com/cyanheads/usaspending-mcp-server/issues/86)). A failed budget or sub-agency request omits those fields, and `sub_agency_page` / `has_more_sub_agencies` become optional ([#69](https://github.com/cyanheads/usaspending-mcp-server/issues/69)).
27
+ - **`truncated` / `shown` / `cap` are set only on evidence** (an upstream `hasNext`, or a row received past `limit`) in `usaspending_autocomplete_filters`, `usaspending_search_awards`, and `usaspending_get_idv_awards`, where any full page set them before; a page that exactly fills `limit` is no longer labeled truncated, and the two paged tools still report `has_next`. Autocomplete at `limit: 500`, the upstream maximum, says in its new `notice` that more matches may exist ([#76](https://github.com/cyanheads/usaspending-mcp-server/issues/76)).
28
+ - **`usaspending_disaster_spending` geography** returns a page of `limit` areas (default 10) with `total` counting every area and `has_next` set from the page position ([#73](https://github.com/cyanheads/usaspending-mcp-server/issues/73)).
29
+ - **Request timeouts:** `USASPENDING_TIMEOUT_MS` defaults to 45000 (was 30000) and `USASPENDING_RETRY_BUDGET_MS` to 45000, or the timeout when higher (was 1.5 × the timeout). A timed-out attempt is not retried; 5xx and network failures still retry inside the budget ([#79](https://github.com/cyanheads/usaspending-mcp-server/issues/79)).
30
+ - **Framework (mcp-ts-core 0.13.15):** unknown nested keys are rejected with the key path named (the mechanism behind #74); `{"keyword": null}` and a lone string for an array filter such as `filters.keywords: "water"`, rejected with `-32602` before, are repaired and accepted.
31
+ - **Docker, `.mcpbignore`, docs:** the base image is Bun 1.4.3; the `.mcpb` bundle excludes `tests/`, `src/`, `scripts/`, `docs/`, `coverage/`, `.github/`, and `.vscode/` ([#88](https://github.com/cyanheads/usaspending-mcp-server/issues/88)); `framework-skills/` is synced to 0.13.15.
32
+
33
+ ## Removed
34
+
35
+ - **BREAKING: `usaspending_spending_by_category` `category: "recipient_parent_duns"`**; it always answered 404 upstream ([#80](https://github.com/cyanheads/usaspending-mcp-server/issues/80)).
36
+ - **BREAKING: `usaspending_get_recipient` `award_type`**; the endpoint has no award-type selector, so the value was ignored. Use `usaspending_spending_over_time` with `filters.recipient_id` and `award_type_codes` for totals by type ([#67](https://github.com/cyanheads/usaspending-mcp-server/issues/67)).
37
+ - **`usaspending_get_award` `cfda` and `recipient.business_types`**, never populated; replaced by `assistance_listings[]` and `recipient.business_categories`. An empty `place_of_performance` or `recipient.location` is omitted instead of returned as `{}` ([#68](https://github.com/cyanheads/usaspending-mcp-server/issues/68)).
38
+ - **`usaspending_spending_by_geography` `award_count`** (result field and "Awards" column), never populated ([#82](https://github.com/cyanheads/usaspending-mcp-server/issues/82)).
39
+
40
+ ## Fixed
41
+
42
+ - **An Assistance Listing or PSC filter the award types cannot match** — `filters.psc_codes` or `filters.assistance_listings` on `usaspending_search_awards` or on the three spending analytics tools — was dropped and the call answered without it; it now fails as `assistance_listings_type_mismatch` or `psc_codes_type_mismatch` ([#74](https://github.com/cyanheads/usaspending-mcp-server/issues/74), [#77](https://github.com/cyanheads/usaspending-mcp-server/issues/77)).
43
+
44
+ ## Dependencies
45
+
46
+ - `@cyanheads/mcp-ts-core` `^0.13.13` → `^0.13.15`
47
+ - `pino-pretty` `^13.1.3` → `^13.2.0`
48
+ - `@types/node` `^26.6.4` → `^26.6.5` (dev)
49
+ - `@modelcontextprotocol/server` `2.2.0` → `2.3.1` (lockfile, via the framework)
50
+ - Bun `1.4.2` → `1.4.3` (`packageManager`, Dockerfile base image, README badge)
@@ -1 +1 @@
1
- {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;;;iBAsBtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,wBAAgB,eAAe,IAAI,YAAY,CAO9C"}
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;;;iBAwBtB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,wBAAgB,eAAe,IAAI,YAAY,CAO9C"}
@@ -15,15 +15,15 @@ const ServerConfigSchema = z.object({
15
15
  .int()
16
16
  .min(1000)
17
17
  .max(120_000)
18
- .default(30_000)
19
- .describe('HTTP request timeout in milliseconds, per attempt'),
18
+ .default(45_000)
19
+ .describe('Per-attempt HTTP timeout in milliseconds. Each attempt is cut at this or at the time left in the request budget, whichever is smaller, and an attempt that times out is not retried.'),
20
20
  retryBudgetMs: z.coerce
21
21
  .number()
22
22
  .int()
23
23
  .min(1000)
24
24
  .max(300_000)
25
25
  .optional()
26
- .describe('Wall-clock budget covering every retry attempt of one request. Defaults to 1.5x the per-attempt timeout, which leaves room for one retry rather than four full timeouts plus backoff.'),
26
+ .describe('Wall-clock budget in milliseconds for one request, every attempt and retry backoff included. Fast transient failures (5xx, network errors) retry inside it. Defaults to 45000, or to the per-attempt timeout when that is higher, so one attempt can always run its full timeout.'),
27
27
  });
28
28
  let _config;
29
29
  export function getServerConfig() {
@@ -1 +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;SACP,MAAM,EAAE;SACR,GAAG,EAAE;SACL,OAAO,CAAC,qCAAqC,CAAC;SAC9C,QAAQ,CAAC,iCAAiC,CAAC;IAC9C,SAAS,EAAE,CAAC,CAAC,MAAM;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,IAAI,CAAC;SACT,GAAG,CAAC,OAAO,CAAC;SACZ,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CAAC,mDAAmD,CAAC;IAChE,aAAa,EAAE,CAAC,CAAC,MAAM;SACpB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,IAAI,CAAC;SACT,GAAG,CAAC,OAAO,CAAC;SACZ,QAAQ,EAAE;SACV,QAAQ,CACP,uLAAuL,CACxL;CACJ,CAAC,CAAC;AAIH,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,OAAO,EAAE,sBAAsB;QAC/B,SAAS,EAAE,wBAAwB;QACnC,aAAa,EAAE,6BAA6B;KAC7C,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
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;SACP,MAAM,EAAE;SACR,GAAG,EAAE;SACL,OAAO,CAAC,qCAAqC,CAAC;SAC9C,QAAQ,CAAC,iCAAiC,CAAC;IAC9C,SAAS,EAAE,CAAC,CAAC,MAAM;SAChB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,IAAI,CAAC;SACT,GAAG,CAAC,OAAO,CAAC;SACZ,OAAO,CAAC,MAAM,CAAC;SACf,QAAQ,CACP,sLAAsL,CACvL;IACH,aAAa,EAAE,CAAC,CAAC,MAAM;SACpB,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,IAAI,CAAC;SACT,GAAG,CAAC,OAAO,CAAC;SACZ,QAAQ,EAAE;SACV,QAAQ,CACP,mRAAmR,CACpR;CACJ,CAAC,CAAC;AAIH,IAAI,OAAiC,CAAC;AAEtC,MAAM,UAAU,eAAe;IAC7B,OAAO,KAAK,cAAc,CAAC,kBAAkB,EAAE;QAC7C,OAAO,EAAE,sBAAsB;QAC/B,SAAS,EAAE,wBAAwB;QACnC,aAAa,EAAE,6BAA6B;KAC7C,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/index.js CHANGED
@@ -36,6 +36,7 @@ await createApp({
36
36
  instructions: 'USAspending.gov MCP server — federal award, recipient, agency, and spending data from the US Treasury DATA Act platform.\n' +
37
37
  '- Start with usaspending_list_agencies or usaspending_autocomplete_filters to discover agency codes, NAICS/PSC codes, and Assistance Listing numbers\n' +
38
38
  '- Use usaspending_search_awards to find awards, then usaspending_get_award for full details\n' +
39
+ '- Reuse NAICS, PSC, Assistance Listing, and DEF codes as filters on usaspending_search_awards and the usaspending_spending_* tools to see where and when that money went\n' +
39
40
  '- Chain recipient_id from usaspending_get_award into usaspending_get_recipient for entity profiles\n' +
40
41
  '- Search window: 2007-10-01 onward. DoD contracts have a 90-day publication lag.',
41
42
  setup(core) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,wBAAwB;IAC/B,KAAK,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9B,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;IAC/B;;;;;;OAMG;IACH,UAAU,EAAE;QACV,YAAY,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE;KACzD;IACD;;;;;;OAMG;IACH,WAAW,EAAE,WAAW;IACxB,YAAY,EACV,4HAA4H;QAC5H,wJAAwJ;QACxJ,+FAA+F;QAC/F,sGAAsG;QACtG,kFAAkF;IACpF,KAAK,CAAC,IAAI;QACR,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,sBAAsB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAClE,CAAC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF,MAAM,SAAS,CAAC;IACd,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE,wBAAwB;IAC/B,KAAK,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9B,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;IAC/B;;;;;;OAMG;IACH,UAAU,EAAE;QACV,YAAY,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE;KACzD;IACD;;;;;;OAMG;IACH,WAAW,EAAE,WAAW;IACxB,YAAY,EACV,4HAA4H;QAC5H,wJAAwJ;QACxJ,+FAA+F;QAC/F,4KAA4K;QAC5K,sGAAsG;QACtG,kFAAkF;IACpF,KAAK,CAAC,IAAI;QACR,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,sBAAsB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAClE,CAAC;CACF,CAAC,CAAC"}
@@ -21,7 +21,13 @@ export declare const autocompleteFiltersTool: import("@cyanheads/mcp-ts-core").T
21
21
  results: z.ZodArray<z.ZodObject<{
22
22
  code: z.ZodOptional<z.ZodString>;
23
23
  name: z.ZodOptional<z.ZodString>;
24
- id: z.ZodOptional<z.ZodString>;
24
+ abbreviation: z.ZodOptional<z.ZodString>;
25
+ tier: z.ZodOptional<z.ZodEnum<{
26
+ subtier: "subtier";
27
+ toptier: "toptier";
28
+ }>>;
29
+ toptier_name: z.ZodOptional<z.ZodString>;
30
+ toptier_code: z.ZodOptional<z.ZodString>;
25
31
  uei: z.ZodOptional<z.ZodString>;
26
32
  duns: z.ZodOptional<z.ZodString>;
27
33
  }, z.core.$strip>>;
@@ -52,5 +58,6 @@ export declare const autocompleteFiltersTool: import("@cyanheads/mcp-ts-core").T
52
58
  readonly truncated: z.ZodOptional<z.ZodBoolean>;
53
59
  readonly shown: z.ZodOptional<z.ZodNumber>;
54
60
  readonly cap: z.ZodOptional<z.ZodNumber>;
61
+ readonly notice: z.ZodOptional<z.ZodString>;
55
62
  }>;
56
63
  //# sourceMappingURL=autocomplete-filters.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-filters.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/autocomplete-filters.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAIjE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+MlC,CAAC"}
1
+ {"version":3,"file":"autocomplete-filters.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/autocomplete-filters.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAOjE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmSlC,CAAC"}
@@ -6,14 +6,16 @@
6
6
  import { tool, z } from '@cyanheads/mcp-ts-core';
7
7
  import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
8
8
  import { getUSASpendingService } from '../../../services/usaspending/usaspending-service.js';
9
+ /** Largest `limit` every autocomplete route accepts; 501 is rejected with HTTP 400. */
10
+ const UPSTREAM_LIMIT_MAX = 500;
9
11
  export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters', {
10
12
  title: 'Autocomplete Codes and Names',
11
- description: 'Look up valid code values for filter fields by searching free-text descriptions. Use the type parameter to select the lookup table: naics (NAICS industry codes), psc (product/service codes), cfda (CFDA/Assistance Listing program numbers), awarding_agency (agency names and IDs), or recipient (recipient names with UEI/DUNS). Call this before filtering awards when you know a description but not the exact code. Returns matching codes and names for use in other tool filters.',
13
+ description: 'Look up valid code values for filter fields by searching free-text descriptions. Use the type parameter to select the lookup table: naics (NAICS industry codes), psc (product/service codes), cfda (CFDA/Assistance Listing program numbers), awarding_agency (agency and sub-agency names, each with its tier and top-tier parent — the agency_name filters take the top-tier name), or recipient (recipient names with UEI/DUNS). Call this before filtering awards when you know a description but not the exact code. Returns matching codes and names for use in other tool filters.',
12
14
  annotations: { readOnlyHint: true, openWorldHint: true, idempotentHint: true },
13
15
  input: z.object({
14
16
  type: z
15
17
  .enum(['naics', 'psc', 'cfda', 'awarding_agency', 'recipient'])
16
- .describe('Lookup table to search: naics (industry codes), psc (product/service codes), cfda (Assistance Listing program numbers, for usaspending_search_awards assistance_listings), awarding_agency (agency names), recipient (recipient names)'),
18
+ .describe('Lookup table to search: naics (industry codes), psc (product/service codes, for the psc_codes filter), cfda (Assistance Listing program numbers, for the assistance_listings filter), awarding_agency (agency and sub-agency names), recipient (recipient names). Both filters are taken by usaspending_search_awards and by the filters object of usaspending_spending_by_category, usaspending_spending_by_geography, and usaspending_spending_over_time.'),
17
19
  search_text: z
18
20
  .string()
19
21
  .min(1)
@@ -22,7 +24,7 @@ export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters',
22
24
  .number()
23
25
  .int()
24
26
  .min(1)
25
- .max(500)
27
+ .max(UPSTREAM_LIMIT_MAX)
26
28
  .default(10)
27
29
  .describe('Maximum number of results to return (1–500), enforced client-side. The recipient lookup unions three upstream match buckets (name, UEI, DUNS) and can return up to 3x this value, so its results are capped to this limit before returning — the cap keeps them in bucket order, so name matches fill the page first and identifier matches appear only in whatever room is left. To resolve a specific UEI or DUNS, pass the identifier itself as search_text. naics/psc/cfda/awarding_agency honor this limit exactly.'),
28
30
  }),
@@ -35,12 +37,27 @@ export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters',
35
37
  code: z
36
38
  .string()
37
39
  .optional()
38
- .describe('Code value (NAICS code, PSC code, Assistance Listing/CFDA number, or agency code); use this in filter parameters — an Assistance Listing number goes in usaspending_search_awards assistance_listings'),
39
- name: z.string().optional().describe('Human-readable name or description'),
40
- id: z
40
+ .describe('Code value (NAICS code, PSC code, or Assistance Listing/CFDA number); use this in filter parameters — an Assistance Listing number goes in usaspending_search_awards assistance_listings. Agency rows carry toptier_code instead.'),
41
+ name: z
41
42
  .string()
42
43
  .optional()
43
- .describe('Numeric or string ID (for the awarding_agency type)'),
44
+ .describe("Human-readable name or description; for awarding_agency, the matched agency's own name, which for a sub-agency differs from toptier_name"),
45
+ abbreviation: z
46
+ .string()
47
+ .optional()
48
+ .describe("awarding_agency only: the matched agency's own abbreviation, when it has one"),
49
+ tier: z
50
+ .enum(['toptier', 'subtier'])
51
+ .optional()
52
+ .describe('awarding_agency only: toptier for a department-level agency, subtier for a component under one'),
53
+ toptier_name: z
54
+ .string()
55
+ .optional()
56
+ .describe('awarding_agency only: the top-tier agency name — the value the agency_name filters on usaspending_search_awards, usaspending_spending_by_category, usaspending_spending_by_geography, and usaspending_spending_over_time take. Those filters are top-tier only, so a sub-agency filters at its parent and the results cover the whole department.'),
57
+ toptier_code: z
58
+ .string()
59
+ .optional()
60
+ .describe('awarding_agency only: the 3-digit top-tier agency code, accepted by usaspending_get_agency'),
44
61
  uei: z
45
62
  .string()
46
63
  .optional()
@@ -50,19 +67,27 @@ export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters',
50
67
  .optional()
51
68
  .describe('DUNS number (legacy) — recipient type only; populated when the search text matches a DUNS'),
52
69
  })
53
- .describe('Matched entry — code/name for code lookups, name plus optional UEI/DUNS for recipients'))
70
+ .describe('Matched entry — code/name for code lookups, name with tier and top-tier parent for agencies, name plus optional UEI/DUNS for recipients'))
54
71
  .describe('Matching codes and names'),
55
72
  total: z.number().describe('Number of results returned'),
56
73
  }),
57
74
  // Agent-facing context: echoed query parameters and result count. The autocomplete
58
- // endpoint returns no total, so a hit-the-cap signal discloses truncation.
75
+ // endpoints return no total, so the handler asks for one row past the limit and
76
+ // discloses truncation only when that row (or a recipient bucket overflow) came back.
59
77
  enrichment: {
60
78
  lookup_type: z.string().describe('Lookup table that was searched'),
61
79
  query: z.string().describe('Search text sent to the autocomplete API'),
62
80
  result_count: z.number().describe('Number of matching results returned'),
63
- truncated: z.boolean().optional().describe('True when results were capped at the limit.'),
64
- shown: z.number().optional().describe('Number of results returned.'),
65
- cap: z.number().optional().describe('The limit that was applied.'),
81
+ truncated: z
82
+ .boolean()
83
+ .optional()
84
+ .describe('True when more matches exist beyond the limit and were left out. Absent when every match was returned.'),
85
+ shown: z.number().optional().describe('Number of results returned, when truncated.'),
86
+ cap: z.number().optional().describe('The limit that was applied, when truncated.'),
87
+ notice: z
88
+ .string()
89
+ .optional()
90
+ .describe('How to reach the matches left out when truncated, or — when limit is 500 and all 500 slots filled — that the upstream maximum was reached and more matches may exist. Absent otherwise.'),
66
91
  },
67
92
  errors: [
68
93
  {
@@ -95,22 +120,28 @@ export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters',
95
120
  });
96
121
  const svc = getUSASpendingService();
97
122
  let rawResults = [];
123
+ /**
124
+ * One row past `limit` tells a capped list from one that exactly fills the page. Every
125
+ * autocomplete route rejects `limit` above 500 with HTTP 400, so at 500 there is no
126
+ * room for the extra row and a full page can only say the ceiling was reached.
127
+ */
128
+ const requested = Math.min(input.limit + 1, UPSTREAM_LIMIT_MAX);
98
129
  if (input.type === 'naics') {
99
- const resp = await svc.autocompleteNaics(input.search_text, input.limit, ctx);
130
+ const resp = await svc.autocompleteNaics(input.search_text, requested, ctx);
100
131
  rawResults = (resp.results ?? []).map((r) => ({
101
132
  ...(r.naics ? { code: r.naics } : {}),
102
133
  ...(r.naics_description ? { name: r.naics_description } : {}),
103
134
  }));
104
135
  }
105
136
  else if (input.type === 'psc') {
106
- const resp = await svc.autocompletePsc(input.search_text, input.limit, ctx);
137
+ const resp = await svc.autocompletePsc(input.search_text, requested, ctx);
107
138
  rawResults = (resp.results ?? []).map((r) => ({
108
139
  ...(r.product_or_service_code ? { code: r.product_or_service_code } : {}),
109
140
  ...(r.psc_description ? { name: r.psc_description } : {}),
110
141
  }));
111
142
  }
112
143
  else if (input.type === 'cfda') {
113
- const resp = await svc.autocompleteCfda(input.search_text, input.limit, ctx);
144
+ const resp = await svc.autocompleteCfda(input.search_text, requested, ctx);
114
145
  rawResults = (resp.results ?? []).map((r) => ({
115
146
  ...(r.program_number ? { code: r.program_number } : {}),
116
147
  ...(r.program_title
@@ -121,24 +152,42 @@ export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters',
121
152
  }));
122
153
  }
123
154
  else if (input.type === 'awarding_agency') {
124
- const resp = await svc.autocompleteAwardingAgency(input.search_text, input.limit, ctx);
125
- rawResults = (resp.results ?? []).map((r) => ({
126
- ...(r.id != null ? { id: String(r.id) } : {}),
127
- ...(r.toptier_agency?.name ? { name: r.toptier_agency.name } : {}),
128
- }));
155
+ const resp = await svc.autocompleteAwardingAgency(input.search_text, requested, ctx);
156
+ rawResults = (resp.results ?? []).map((r) => {
157
+ /**
158
+ * A top-tier row repeats the department under subtier_agency; a sub-agency row
159
+ * names itself there, with its parent under toptier_agency.
160
+ */
161
+ const own = r.toptier_flag ? r.toptier_agency : r.subtier_agency;
162
+ return {
163
+ ...(own?.name ? { name: own.name } : {}),
164
+ ...(own?.abbreviation ? { abbreviation: own.abbreviation } : {}),
165
+ ...(typeof r.toptier_flag === 'boolean'
166
+ ? { tier: r.toptier_flag ? 'toptier' : 'subtier' }
167
+ : {}),
168
+ ...(r.toptier_agency?.name ? { toptier_name: r.toptier_agency.name } : {}),
169
+ ...(r.toptier_agency?.toptier_code
170
+ ? { toptier_code: r.toptier_agency.toptier_code }
171
+ : {}),
172
+ };
173
+ });
129
174
  }
130
175
  else {
131
176
  // recipient
132
- const resp = await svc.autocompleteRecipient(input.search_text, input.limit, ctx);
177
+ const resp = await svc.autocompleteRecipient(input.search_text, requested, ctx);
133
178
  rawResults = (resp.results ?? []).map((r) => ({
134
179
  ...(r.recipient_name ? { name: r.recipient_name } : {}),
135
180
  ...(r.uei ? { uei: r.uei } : {}),
136
181
  ...(r.duns ? { duns: r.duns } : {}),
137
182
  }));
138
183
  }
139
- // `autocomplete/recipient/` applies `limit` per match bucket (name, UEI, DUNS) and
140
- // unions them, so it can hand back up to 3x what was asked for. The other four
141
- // lookups already honor `limit`, so capping here is a no-op for them.
184
+ /**
185
+ * `autocomplete/recipient/` applies `limit` per match bucket (name, UEI, DUNS) and
186
+ * unions them, so it can hand back up to 3x what was asked for; the other four
187
+ * lookups return at most `requested`. Truncation is judged on everything received —
188
+ * for recipients, the bucket union — before the slice to `limit`.
189
+ */
190
+ const received = rawResults.length;
142
191
  rawResults = rawResults.slice(0, input.limit);
143
192
  if (rawResults.length === 0) {
144
193
  throw ctx.fail('no_match', `No ${input.type} results matched "${input.search_text}"`, {
@@ -152,20 +201,28 @@ export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters',
152
201
  query: input.search_text,
153
202
  result_count: rawResults.length,
154
203
  });
155
- if (rawResults.length >= input.limit) {
204
+ const narrow = input.limit < UPSTREAM_LIMIT_MAX
205
+ ? `Raise limit (max ${UPSTREAM_LIMIT_MAX}) or use a more specific search term.`
206
+ : 'Use a more specific search term.';
207
+ if (received > input.limit) {
156
208
  ctx.enrich.truncated({
157
209
  shown: rawResults.length,
158
210
  cap: input.limit,
159
- // The recipient cap is a head-slice over name-then-UEI-then-DUNS, and upstream
160
- // fills the name bucket to `limit` on its own whenever the corpus allows. So a
161
- // saturated recipient page holds name matches only, and raising `limit` raises
162
- // the name bucket with it — it never reaches the identifier buckets behind it.
163
- // Pointing that caller at `limit` would send them somewhere the rows are not.
211
+ /**
212
+ * The recipient cap is a head-slice over name-then-UEI-then-DUNS, and upstream
213
+ * fills the name bucket to the requested size on its own whenever the corpus
214
+ * allows. So a saturated recipient page holds name matches only, and raising
215
+ * `limit` raises the name bucket with it — it never reaches the identifier buckets
216
+ * behind it. Pointing that caller at `limit` alone would misdirect them.
217
+ */
164
218
  guidance: input.type === 'recipient'
165
- ? 'More name matches may exist — raise limit (max 500) or use a more specific search term. Matches on a UEI or DUNS are not reachable this way once name matches fill the page; to resolve one, pass the identifier itself as search_text.'
166
- : 'More matches may exist. Raise limit (max 500) or use a more specific search term.',
219
+ ? `More matches exist beyond limit. ${narrow} Matches on a UEI or DUNS are not reachable this way once name matches fill the page; to resolve one, pass the identifier itself as search_text.`
220
+ : `More matches exist beyond limit. ${narrow}`,
167
221
  });
168
222
  }
223
+ else if (requested === input.limit && received === input.limit) {
224
+ ctx.enrich.notice(`Returned the upstream maximum of ${UPSTREAM_LIMIT_MAX} matches, so more may exist. ${narrow}`);
225
+ }
169
226
  return {
170
227
  type: input.type,
171
228
  search_text: input.search_text,
@@ -179,10 +236,12 @@ export const autocompleteFiltersTool = tool('usaspending_autocomplete_filters',
179
236
  const parts = [];
180
237
  if (r.code)
181
238
  parts.push(`**Code:** ${r.code}`);
182
- if (r.id)
183
- parts.push(`**ID:** ${r.id}`);
184
239
  if (r.name)
185
- parts.push(`**Name:** ${r.name}`);
240
+ parts.push(`**Name:** ${r.name}${r.abbreviation ? ` (${r.abbreviation})` : ''}`);
241
+ if (r.tier)
242
+ parts.push(`**Tier:** ${r.tier}`);
243
+ if (r.toptier_name)
244
+ parts.push(`**Top-tier agency:** ${r.toptier_name}${r.toptier_code ? ` (toptier_code ${r.toptier_code})` : ''}`);
186
245
  if (r.uei)
187
246
  parts.push(`**UEI:** ${r.uei}`);
188
247
  if (r.duns)
@@ -1 +1 @@
1
- {"version":3,"file":"autocomplete-filters.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/autocomplete-filters.tool.ts"],"names":[],"mappings":"AAAA;;;;GAI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C3C,IAAI,CAAC,CAAC,IAAI;gBAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9C,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvC,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,gBAAgB,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAC3C,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
@@ -24,7 +24,7 @@ export declare const disasterSpendingTool: import("@cyanheads/mcp-ts-core").Tool
24
24
  county: "county";
25
25
  state: "state";
26
26
  }>>;
27
- }, z.core.$strip>>;
27
+ }, z.core.$strict>>;
28
28
  limit: z.ZodDefault<z.ZodNumber>;
29
29
  page: z.ZodDefault<z.ZodNumber>;
30
30
  }, z.core.$strip>, z.ZodObject<{
@@ -94,6 +94,7 @@ export declare const disasterSpendingTool: import("@cyanheads/mcp-ts-core").Tool
94
94
  readonly truncated: z.ZodOptional<z.ZodBoolean>;
95
95
  readonly shown: z.ZodOptional<z.ZodNumber>;
96
96
  readonly cap: z.ZodOptional<z.ZodNumber>;
97
+ readonly truncationCeiling: z.ZodOptional<z.ZodNumber>;
97
98
  readonly notice: z.ZodOptional<z.ZodString>;
98
99
  }>;
99
100
  //# sourceMappingURL=disaster-spending.tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"disaster-spending.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/disaster-spending.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,+BAA+B,CAAC;AAoDlF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6d/B,CAAC"}
1
+ {"version":3,"file":"disaster-spending.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/disaster-spending.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAmB,MAAM,+BAA+B,CAAC;AAoDlF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAghB/B,CAAC"}
@@ -72,6 +72,7 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
72
72
  .optional()
73
73
  .describe('Geographic layer for geography dimension (state or county)'),
74
74
  })
75
+ .strict()
75
76
  .optional()
76
77
  .describe('Filters — def_codes is required for all non-overview dimensions (agency, cfda, recipient, geography)'),
77
78
  limit: z
@@ -80,7 +81,7 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
80
81
  .min(1)
81
82
  .max(100)
82
83
  .default(10)
83
- .describe('Maximum results per page (1–100). Applies to the agency, cfda, and recipient dimensions; ignored for overview and geography, which are not paginated.'),
84
+ .describe('Maximum results per page (1–100). Applies to the agency, cfda, recipient, and geography dimensions; geography pages through its areas ranked by aggregated_amount, highest first. Ignored for overview.'),
84
85
  page: z.number().int().min(1).default(1).describe('Page number (1-based)'),
85
86
  }),
86
87
  // Agent-facing context: the dimension applied and pagination for non-overview dimensions.
@@ -95,13 +96,20 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
95
96
  truncated: z
96
97
  .boolean()
97
98
  .optional()
98
- .describe('True when the upstream capped the reachable result set rather than counting it.'),
99
+ .describe('recipient: true when the upstream capped the reachable result set rather than counting it. geography: true when more areas rank below this page.'),
99
100
  shown: z.number().optional().describe('Number of results returned on this page.'),
100
- cap: z.number().optional().describe('The result-set ceiling the upstream applied.'),
101
+ cap: z
102
+ .number()
103
+ .optional()
104
+ .describe('recipient: the result-set ceiling the upstream applied. geography: the page size (limit).'),
105
+ truncationCeiling: z
106
+ .number()
107
+ .optional()
108
+ .describe('geography: the lowest aggregated_amount on this page — no area on a later page has a higher one.'),
101
109
  notice: z
102
110
  .string()
103
111
  .optional()
104
- .describe('Caveat explaining a capped total and how to bring the set under the cap.'),
112
+ .describe('recipient: why the total is a cap and how to bring the set under it. geography: how many areas rank below this page and how to reach them.'),
105
113
  },
106
114
  output: z.object({
107
115
  dimension: z.string().describe('Breakdown dimension returned'),
@@ -175,11 +183,14 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
175
183
  .number()
176
184
  .optional()
177
185
  .describe('Face value of loan guarantees in USD (loans spending_type)'),
178
- shape_code: z.string().optional().describe('Geographic code (geography dimension)'),
186
+ shape_code: z
187
+ .string()
188
+ .optional()
189
+ .describe('Geographic code (geography dimension). Absent on the unattributed row: spending with no recorded place of performance, which still ranks and counts as an area.'),
179
190
  display_name: z
180
191
  .string()
181
192
  .optional()
182
- .describe('Geographic display name (geography dimension)'),
193
+ .describe('Geographic display name (geography dimension); absent on the unattributed row'),
183
194
  aggregated_amount: z
184
195
  .number()
185
196
  .optional()
@@ -297,11 +308,12 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
297
308
  rawResults = await svc.getDisasterByRecipient(input.spending_type, paginationBody, ctx);
298
309
  }
299
310
  else {
300
- // geography — this endpoint requires a spending_type from a vocabulary distinct from
301
- // the breakdown dimensions (obligation | outlay | face_value_of_loan); omitting it
302
- // returns HTTP 422. It reports totals across the whole result set in a single page
303
- // (no pagination). Default to obligation — total obligated dollars, the comparable
304
- // default measure — and report that as the effective spending_type.
311
+ /**
312
+ * geography — this endpoint requires a spending_type from a vocabulary distinct from
313
+ * the breakdown dimensions (obligation | outlay | face_value_of_loan); omitting it
314
+ * returns HTTP 422. Default to obligation — total obligated dollars, the comparable
315
+ * default measure — and report that as the effective spending_type.
316
+ */
305
317
  const geoSpendingType = 'obligation';
306
318
  const geoBody = {
307
319
  ...baseBody,
@@ -310,7 +322,7 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
310
322
  spending_type: geoSpendingType,
311
323
  };
312
324
  const data = await svc.getDisasterByGeography(geoBody, ctx);
313
- const geoResults = (data.results ?? []).map((r) => ({
325
+ const areas = (data.results ?? []).map((r) => ({
314
326
  ...(r.shape_code ? { shape_code: r.shape_code } : {}),
315
327
  ...(r.display_name ? { display_name: r.display_name } : {}),
316
328
  ...(typeof r.amount === 'number' ? { aggregated_amount: r.amount } : {}),
@@ -318,22 +330,38 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
318
330
  ...(typeof r.population === 'number' ? { population: r.population } : {}),
319
331
  ...(typeof r.per_capita === 'number' ? { per_capita: r.per_capita } : {}),
320
332
  }));
321
- ctx.enrich.total(geoResults.length);
333
+ /**
334
+ * The endpoint is not paginated: it returns every area whatever paging the request
335
+ * carries, so the page is ranked and sliced here. The unattributed row (no
336
+ * shape_code) stays in the ranking and the count; a code sorts before it on a tie.
337
+ */
338
+ areas.sort((a, b) => (b.aggregated_amount ?? 0) - (a.aggregated_amount ?? 0) ||
339
+ (a.shape_code === undefined ? 1 : 0) - (b.shape_code === undefined ? 1 : 0) ||
340
+ (a.shape_code ?? '').localeCompare(b.shape_code ?? ''));
341
+ const total = areas.length;
342
+ const start = (input.page - 1) * input.limit;
343
+ const pageAreas = areas.slice(start, start + input.limit);
344
+ const hasNext = input.page * input.limit < total;
345
+ ctx.enrich.total(total);
322
346
  ctx.enrich({
323
347
  applied_dimension: 'geography',
324
- current_page: 1,
325
- has_next_page: false,
348
+ current_page: input.page,
349
+ has_next_page: hasNext,
326
350
  });
351
+ if (hasNext) {
352
+ const ceiling = pageAreas.at(-1)?.aggregated_amount;
353
+ ctx.enrich.truncated({
354
+ shown: pageAreas.length,
355
+ cap: input.limit,
356
+ ...(ceiling !== undefined ? { ceiling } : {}),
357
+ guidance: `${(total - input.page * input.limit).toLocaleString()} more of ${total.toLocaleString()} areas rank below this page${ceiling !== undefined ? `, none above ${formatCurrency(ceiling)}` : ''}. Request page ${input.page + 1} to continue${input.limit < 100 ? ', or raise limit (max 100)' : ''}.`,
358
+ });
359
+ }
327
360
  return {
328
361
  dimension: 'geography',
329
362
  spending_type: geoSpendingType,
330
- results: geoResults,
331
- page_metadata: {
332
- has_next: false,
333
- page: 1,
334
- total: geoResults.length,
335
- limit: geoResults.length,
336
- },
363
+ results: pageAreas,
364
+ page_metadata: { has_next: hasNext, page: input.page, total, limit: input.limit },
337
365
  };
338
366
  }
339
367
  const results = (rawResults.results ?? []).map((r) => ({
@@ -433,7 +461,11 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
433
461
  lines.push(formatPaginationLine(result.page_metadata));
434
462
  }
435
463
  if (result.results.length === 0) {
436
- if (!result.overview) {
464
+ const total = result.page_metadata?.total ?? 0;
465
+ if (total > 0) {
466
+ lines.push(`\n> Page ${result.page_metadata?.page} is past the end of the ${total.toLocaleString()} matching rows. Request an earlier page.`);
467
+ }
468
+ else if (!result.overview) {
437
469
  lines.push('\n> No data found for the specified DEF codes and dimension. Try different DEF codes or another breakdown dimension — def_codes is required for all non-overview dimensions and cannot be removed.');
438
470
  }
439
471
  }
@@ -445,9 +477,11 @@ export const disasterSpendingTool = tool('usaspending_disaster_spending', {
445
477
  lines.push(`| Name/Display | ID | Code | Shape | Obligation | Outlay |${showBudgetary ? ' Budgetary Resources |' : ''} Aggregated | Population | Per Capita | Loans | Awards |`);
446
478
  lines.push(`|:-------------|:---|:-----|:------|:-----------|:-------|${showBudgetary ? ':--------------------|' : ''}:-----------|:-----------|:-----------|:------|:-------|`);
447
479
  for (const r of result.results) {
448
- const label = r.display_name && r.name && r.display_name !== r.name
449
- ? `${r.display_name} (${r.name})`
450
- : (r.display_name ?? r.name ?? 'N/A');
480
+ const label = result.dimension === 'geography' && r.shape_code === undefined
481
+ ? 'Unattributed (no place of performance recorded)'
482
+ : r.display_name && r.name && r.display_name !== r.name
483
+ ? `${r.display_name} (${r.name})`
484
+ : (r.display_name ?? r.name ?? 'N/A');
451
485
  const id = r.id ?? 'N/A';
452
486
  const code = r.code ?? 'N/A';
453
487
  const shape = r.shape_code ?? 'N/A';