@cyanheads/usaspending-mcp-server 0.2.8 → 0.3.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.
- package/CLAUDE.md +1 -1
- package/README.md +35 -9
- package/changelog/0.2.x/0.2.9.md +28 -0
- package/changelog/0.3.x/0.3.0.md +18 -0
- package/dist/mcp-server/tools/definitions/get-award-federal-accounts.tool.d.ts +42 -0
- package/dist/mcp-server/tools/definitions/get-award-federal-accounts.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-award-federal-accounts.tool.js +177 -0
- package/dist/mcp-server/tools/definitions/get-award-federal-accounts.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-federal-account-breakdown.tool.d.ts +45 -0
- package/dist/mcp-server/tools/definitions/get-federal-account-breakdown.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/get-federal-account-breakdown.tool.js +164 -0
- package/dist/mcp-server/tools/definitions/get-federal-account-breakdown.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/get-federal-account.tool.d.ts +8 -1
- package/dist/mcp-server/tools/definitions/get-federal-account.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/get-federal-account.tool.js +57 -4
- package/dist/mcp-server/tools/definitions/get-federal-account.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/index.d.ts +86 -2
- package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/index.js +6 -0
- package/dist/mcp-server/tools/definitions/index.js.map +1 -1
- package/dist/mcp-server/tools/definitions/search-awards.tool.d.ts +6 -0
- package/dist/mcp-server/tools/definitions/search-awards.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/search-awards.tool.js +26 -1
- package/dist/mcp-server/tools/definitions/search-awards.tool.js.map +1 -1
- package/dist/mcp-server/tools/definitions/spending-over-time.tool.d.ts +1 -2
- package/dist/mcp-server/tools/definitions/spending-over-time.tool.d.ts.map +1 -1
- package/dist/mcp-server/tools/definitions/spending-over-time.tool.js +17 -15
- package/dist/mcp-server/tools/definitions/spending-over-time.tool.js.map +1 -1
- package/dist/services/usaspending/types.d.ts +79 -3
- package/dist/services/usaspending/types.d.ts.map +1 -1
- package/dist/services/usaspending/usaspending-service.d.ts +49 -5
- package/dist/services/usaspending/usaspending-service.d.ts.map +1 -1
- package/dist/services/usaspending/usaspending-service.js +82 -12
- package/dist/services/usaspending/usaspending-service.js.map +1 -1
- package/package.json +1 -1
- package/server.json +3 -3
package/CLAUDE.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Developer Protocol
|
|
2
2
|
|
|
3
3
|
**Server:** usaspending-mcp-server
|
|
4
|
-
**Version:** 0.
|
|
4
|
+
**Version:** 0.3.0
|
|
5
5
|
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.10.14`
|
|
6
6
|
**Engines:** Bun ≥1.3.0, Node ≥24.0.0
|
|
7
7
|
**MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>@cyanheads/usaspending-mcp-server</h1>
|
|
3
3
|
<p><b>Access US federal award, recipient, agency, and spending analytics data from USAspending.gov via MCP. STDIO or Streamable HTTP.</b>
|
|
4
|
-
<div>
|
|
4
|
+
<div>18 Tools</div>
|
|
5
5
|
</p>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
<div align="center">
|
|
9
9
|
|
|
10
|
-
[](./CHANGELOG.md) [](./LICENSE) [](https://github.com/users/cyanheads/packages/container/package/usaspending-mcp-server) [](https://modelcontextprotocol.io/) [](https://www.npmjs.com/package/@cyanheads/usaspending-mcp-server) [](https://www.typescriptlang.org/) [](https://bun.sh/)
|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
## Tools
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
18 tools covering the full USAspending.gov API surface — award discovery and detail, recipient and agency profiles, spending analytics (by geography, category, and time), disaster/emergency spending, and federal account data:
|
|
33
33
|
|
|
34
34
|
| Tool | Description |
|
|
35
35
|
|:---|:---|
|
|
@@ -38,14 +38,16 @@
|
|
|
38
38
|
| `usaspending_get_idv_awards` | List child contracts and task/delivery orders placed under an IDV award. Each row includes a `generated_unique_award_id` for chaining into `usaspending_get_award`. |
|
|
39
39
|
| `usaspending_get_award_transactions` | List individual transactions (modifications, amendments) on an award. Reveals spending history and obligation changes over time. |
|
|
40
40
|
| `usaspending_get_award_subawards` | List subaward contracts or grants under a prime award. Reveals the sub-contractor or sub-grantee layer — who actually does the work. |
|
|
41
|
+
| `usaspending_get_award_federal_accounts` | List the Treasury federal accounts that funded an award, with the amount obligated from each. Returns `federal_account` for chaining into `usaspending_get_federal_account`. |
|
|
41
42
|
| `usaspending_search_recipients` | Search for organizations receiving federal funds by name, UEI, or DUNS. Returns recipient hash IDs, UEI/DUNS, total award amounts, and hierarchy level. Paginated — page through with `page`; `page_metadata.total` reports the full match count. |
|
|
42
43
|
| `usaspending_get_recipient` | Fetch a recipient's profile: address, business types, parent organization, alternate names, and total award amounts by type. |
|
|
43
44
|
| `usaspending_get_agency` | Fetch an agency's fiscal year overview: mission, budget authority, obligation totals, sub-agency count, and DEF codes. Accepts a 3-digit `toptier_code` or an `agency_slug` from award search results. |
|
|
44
45
|
| `usaspending_spending_by_geography` | Aggregate federal spending by state, county, or congressional district. Returns per-capita figures when combined with population data. |
|
|
45
46
|
| `usaspending_spending_by_category` | Aggregate spending grouped by NAICS code, PSC code, awarding agency, funding agency, CFDA program, or recipient. Returns top items with amounts for trend and breakdown analysis. |
|
|
46
|
-
| `usaspending_spending_over_time` | Fetch aggregated spending by fiscal year, fiscal quarter, or
|
|
47
|
+
| `usaspending_spending_over_time` | Fetch aggregated spending by fiscal year, fiscal quarter, or fiscal month. Filter by award type, agency, recipient, or keyword to trace trends in a specific area. |
|
|
47
48
|
| `usaspending_disaster_spending` | Fetch disaster and emergency supplemental spending (COVID-19, hurricanes, etc.) broken down by agency, CFDA program, recipient, or geography. Filter by DEF codes to isolate a specific appropriation. |
|
|
48
|
-
| `usaspending_get_federal_account` | Fetch a federal account's budget data: total obligations, outlays,
|
|
49
|
+
| `usaspending_get_federal_account` | Fetch a federal account's budget data: total obligations, outlays, budgetary resources, and the per-Treasury-Account-Symbol component breakdown. Account codes come from `usaspending_search_federal_accounts`. |
|
|
50
|
+
| `usaspending_get_federal_account_breakdown` | Break a federal account's obligations down by program activity (what the money funds) or object class (what it buys). Paginated with a total count. |
|
|
49
51
|
| `usaspending_search_federal_accounts` | List and keyword-search federal accounts by agency identifier or title keyword. Returns account numbers for chaining into `usaspending_get_federal_account`. |
|
|
50
52
|
| `usaspending_list_agencies` | List all top-tier federal agencies with toptier codes, budget authority amounts, and obligation totals. Entry point for agency navigation. |
|
|
51
53
|
| `usaspending_autocomplete` | Look up valid code values for filter fields: NAICS, PSC, CFDA, recipient names, or agency names. Use before filtering to discover the right code from a description. |
|
|
@@ -107,6 +109,18 @@ List subawards under a prime contract or grant.
|
|
|
107
109
|
|
|
108
110
|
---
|
|
109
111
|
|
|
112
|
+
### `usaspending_get_award_federal_accounts`
|
|
113
|
+
|
|
114
|
+
List the Treasury federal accounts that funded an award — the award → appropriation link.
|
|
115
|
+
|
|
116
|
+
- `award_id` must be a `generated_unique_award_id` — from `usaspending_search_awards` (`generated_internal_id` field) or `usaspending_get_award`
|
|
117
|
+
- Each row returns `federal_account` (AGENCY-MAIN format, e.g. `080-0120`) for chaining into `usaspending_get_federal_account`, plus the amount obligated from that account and the funding agency behind it
|
|
118
|
+
- Distinct from `usaspending_get_award` `account_obligations_by_defc`, which breaks funding down by Disaster/Emergency Funding code rather than by account
|
|
119
|
+
- Pagination via `limit` (max 100) and `page`; `count` in `page_metadata` is the total across pages
|
|
120
|
+
- An `award_id` that does not exist returns an empty list rather than an error — the upstream reports no not-found signal for this endpoint
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
110
124
|
### `usaspending_search_recipients`
|
|
111
125
|
|
|
112
126
|
Search for organizations receiving federal funds by name, UEI, or DUNS.
|
|
@@ -183,10 +197,22 @@ Fetch disaster and emergency supplemental spending consolidated from nine+ API e
|
|
|
183
197
|
|
|
184
198
|
Fetch budget data for a federal account identified by its account code.
|
|
185
199
|
|
|
186
|
-
- Returns account title, federal account code,
|
|
187
|
-
- Includes fiscal year snapshot
|
|
188
|
-
-
|
|
189
|
-
- Account codes
|
|
200
|
+
- Returns account title, federal account code, agency identifier, parent agency, and bureau
|
|
201
|
+
- Includes the fiscal year snapshot: total obligations, gross outlays, and budgetary resources
|
|
202
|
+
- `children` breaks the account into its Treasury Account Symbol (TAS) components, each with its own obligated, outlay, and budgetary-resource amounts — one entry per availability period, bounded and returned in full
|
|
203
|
+
- Account codes come from `account_number` in `usaspending_search_federal_accounts` results, or `federal_account` in `usaspending_get_award_federal_accounts` results
|
|
204
|
+
- For obligations broken down by program activity or object class, use `usaspending_get_federal_account_breakdown`
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
### `usaspending_get_federal_account_breakdown`
|
|
209
|
+
|
|
210
|
+
Break a federal account's obligations down by program activity or object class.
|
|
211
|
+
|
|
212
|
+
- `dimension` enum selects the axis: `program_activity` (what the money funds) or `object_class` (what it buys — personnel, supplies, contracts)
|
|
213
|
+
- Each row returns the code, name, and obligated amount; `program_activity` rows also carry `type` — `PAC/PAN` (legacy program activity code/name) or `PARK` (Program Activity Reporting Key), both of which can appear for the same account
|
|
214
|
+
- Pagination via `limit` (max 100) and `page`; `total` in `page_metadata` is the true row count across pages
|
|
215
|
+
- An account code that does not exist returns an empty list rather than an error — unlike `usaspending_get_federal_account`, these routes report no not-found signal
|
|
190
216
|
|
|
191
217
|
---
|
|
192
218
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Declared not-found contracts now fire on upstream misses for usaspending_get_award, usaspending_get_recipient, usaspending_get_agency, and usaspending_get_federal_account; usaspending_search_awards guards the 2007-10-01 date floor client-side; usaspending_spending_over_time relabels month as a fiscal-year ordinal."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.2.9 — 2026-07-17
|
|
8
|
+
|
|
9
|
+
Five fixes across the error surface and the tool descriptions: upstream misses and out-of-range dates now reach callers as declared, actionable errors rather than raw upstream failures, and `usaspending_spending_over_time` and `usaspending_get_federal_account` describe what the API actually returns.
|
|
10
|
+
|
|
11
|
+
## Added
|
|
12
|
+
|
|
13
|
+
- **`usaspending_search_awards` declares `date_before_earliest`** (`ValidationError`, non-retryable) — a `start_date` before the new `EARLIEST_SEARCH_DATE` floor of `2007-10-01` is now rejected client-side with the boundary and a pointer to the Custom Award Download / `bulk_download` endpoints for data back to 2000-10-01. The endpoint answers such a request with a raw HTML 500, so the guard runs before the call. Covers both input paths — the flat `time_period` and the nested `filters.time_period_start` resolve into the same start date. ([#38](https://github.com/cyanheads/usaspending-mcp-server/issues/38))
|
|
14
|
+
|
|
15
|
+
## Changed
|
|
16
|
+
|
|
17
|
+
- **`usaspending_spending_over_time` describes and renders `month` as a fiscal month** — an ordinal within `fiscal_year` where 1 = October, not a calendar month. The tool description, the `group` input, and the output `time_period.month` field all say so; `format()` renders `FM1` instead of the unqualified `M1`, with a legend line emitted only when rows carry a month. Upstream returns one shape per `group` mode — `{fiscal_year}`, `{fiscal_year, quarter}`, or `{fiscal_year, month}` — now documented on `RawSpendingOverTimeResult.time_period`. ([#32](https://github.com/cyanheads/usaspending-mcp-server/issues/32))
|
|
18
|
+
- **`usaspending_get_federal_account` points callers at `usaspending_search_federal_accounts`** for account codes — its tool description, `account_code` input, declared `account_not_found` recovery, and runtime recovery hint previously cited `usaspending_get_award`'s `account_obligations_by_defc`, which carries DEF codes and amounts, not `AGENCY-MAIN` account numbers. ([#20](https://github.com/cyanheads/usaspending-mcp-server/issues/20))
|
|
19
|
+
- **`usaspending_search_awards`'s `upstream_messages` describes the date advisory as boilerplate** — the API returns its "search covers 2007-10-01 onward" note on every successful response regardless of the dates supplied, so it is not a verdict on the requested range. ([#38](https://github.com/cyanheads/usaspending-mcp-server/issues/38))
|
|
20
|
+
|
|
21
|
+
## Removed
|
|
22
|
+
|
|
23
|
+
- **`usaspending_spending_over_time`'s `time_period.calendar_year` output field and the `Cal Year` column** — upstream only populates `calendar_year` under `group: "calendar_year"`, which this tool's `group` enum does not expose, so the field was unreachable and the column always rendered `N/A`. The handler's `tp.month ?? tp.calendar_month` fallback and both fields on `RawSpendingOverTimeResult.time_period` are gone with it; `calendar_month` appears in no live response under any mode. ([#32](https://github.com/cyanheads/usaspending-mcp-server/issues/32))
|
|
24
|
+
- **The unreachable `httpErrorFromResponse` guard in `USASpendingService.post<T>()`** and its now-unused import — `fetchWithTimeout` throws a status-mapped `McpError` on every non-2xx before returning, so `response.ok` was always true at the guard. Behavior-preserving: POST-path failures surfaced then and now as the framework's status-mapped error. ([#40](https://github.com/cyanheads/usaspending-mcp-server/issues/40))
|
|
25
|
+
|
|
26
|
+
## Fixed
|
|
27
|
+
|
|
28
|
+
- **Upstream 4xx misses no longer bypass the declared not-found contracts** on `usaspending_get_award`, `usaspending_get_recipient`, `usaspending_get_agency`, and `usaspending_get_federal_account` — `fetchWithTimeout` threw before each handler's existence check could run, so a miss surfaced as an unclassified fetch error with no `data.reason` and no recovery hint. A private `getEntity<T>()` helper now resolves `undefined` on the statuses that mean "no such entity" at these four endpoints (400 and 404, verified live per endpoint), letting each handler's `ctx.fail()` fire. The shared `get<T>()` primitive is untouched, so `listAgencies`, `getAgencySubAgencies`, `getAgencyBudgetaryResources`, and `getDisasterOverview` still surface their 4xx as real errors instead of empty successes; non-miss statuses — including the 422 the agency endpoint raises for an out-of-range `fiscal_year` — still propagate. ([#27](https://github.com/cyanheads/usaspending-mcp-server/issues/27))
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
summary: "Federal account drill-down: usaspending_get_award_federal_accounts links an award to the accounts that funded it, usaspending_get_federal_account_breakdown adds the program-activity and object-class axes, and usaspending_get_federal_account now maps its per-Treasury-Account-Symbol children."
|
|
3
|
+
breaking: false
|
|
4
|
+
security: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 0.3.0 — 2026-07-17
|
|
8
|
+
|
|
9
|
+
Three federal-account gaps close together: the award → appropriation chain gains its missing link, the program-activity and object-class breakdowns the README advertised now exist behind a tool, and the account response's own component detail is no longer discarded.
|
|
10
|
+
|
|
11
|
+
## Added
|
|
12
|
+
|
|
13
|
+
- **`usaspending_get_award_federal_accounts`** — lists the Treasury federal accounts that funded an award (`POST /awards/accounts/`), with the amount obligated from each and the funding agency behind it. Each row's `federal_account` (`AGENCY-MAIN`, e.g. `080-0120`) chains into `usaspending_get_federal_account` as `account_code` — the award → appropriation link `usaspending_get_award`'s `account_obligations_by_defc` (DEF codes, not accounts) left open. Paginated via `page`/`limit` (max 100), with `page_metadata.count` the total across pages. A nonexistent `award_id` returns an empty list with a notice rather than an error: the endpoint answers a miss with HTTP 200 and zero rows, so no not-found contract can fire. ([#28](https://github.com/cyanheads/usaspending-mcp-server/issues/28))
|
|
14
|
+
- **`usaspending_get_federal_account_breakdown`** — breaks an account's obligations down along a `dimension`: `program_activity` (what the funds support) or `object_class` (what they buy), over `POST /federal_accounts/{code}/program_activities/total` and `.../object_classes/total`. Rows carry `code`, `name`, `obligations`, and — for `program_activity` only — `type`, either `PAC/PAN` (legacy program activity code/name pair) or `PARK` (Program Activity Reporting Key). Paginated via `page`/`limit` (max 100), with an honest `page_metadata.total`. An account code with no rows on the requested axis returns empty with a notice pointing at the other dimension. ([#31](https://github.com/cyanheads/usaspending-mcp-server/issues/31))
|
|
15
|
+
|
|
16
|
+
## Fixed
|
|
17
|
+
|
|
18
|
+
- **`usaspending_get_federal_account` maps `children`** — the per-Treasury-Account-Symbol component breakdown was arriving in the response the tool already fetched and being discarded before it reached callers. Each row carries `name`, `code` (the full TAS, e.g. `080-2020/2021-0120-000` — the availability-period-scoped component, not an `account_code` this tool accepts), `obligated_amount`, `gross_outlay_amount`, and `budgetary_resources_amount`, rendered in `content[]` at parity with `structuredContent` and omitted entirely when upstream returns none. `RawFederalAccount.children` drops its `unknown[]` placeholder for the real `RawFederalAccountChild[]` row type. ([#41](https://github.com/cyanheads/usaspending-mcp-server/issues/41))
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tool to list the Treasury federal accounts that funded an award.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-award-federal-accounts.tool
|
|
4
|
+
*/
|
|
5
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
export declare const getAwardFederalAccountsTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
8
|
+
award_id: z.ZodString;
|
|
9
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
award_id: z.ZodString;
|
|
13
|
+
results: z.ZodArray<z.ZodObject<{
|
|
14
|
+
federal_account: z.ZodOptional<z.ZodString>;
|
|
15
|
+
account_title: z.ZodOptional<z.ZodString>;
|
|
16
|
+
total_transaction_obligated_amount: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
funding_agency_name: z.ZodOptional<z.ZodString>;
|
|
18
|
+
funding_agency_abbreviation: z.ZodOptional<z.ZodString>;
|
|
19
|
+
funding_agency_slug: z.ZodOptional<z.ZodString>;
|
|
20
|
+
funding_agency_id: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
funding_toptier_agency_id: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
page_metadata: z.ZodObject<{
|
|
24
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
page: z.ZodNumber;
|
|
26
|
+
has_next: z.ZodBoolean;
|
|
27
|
+
has_previous: z.ZodBoolean;
|
|
28
|
+
limit: z.ZodNumber;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
}, z.core.$strip>, readonly [{
|
|
31
|
+
readonly reason: "api_unavailable";
|
|
32
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
33
|
+
readonly when: "USAspending.gov API is unreachable or returns an error.";
|
|
34
|
+
readonly retryable: true;
|
|
35
|
+
readonly recovery: "The API may be temporarily down. Retry the request after a few seconds.";
|
|
36
|
+
}], {
|
|
37
|
+
readonly totalCount: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
readonly current_page: z.ZodNumber;
|
|
39
|
+
readonly has_next_page: z.ZodBoolean;
|
|
40
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}>;
|
|
42
|
+
//# sourceMappingURL=get-award-federal-accounts.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-award-federal-accounts.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-award-federal-accounts.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAQ,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAIjE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2MtC,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tool to list the Treasury federal accounts that funded an award.
|
|
3
|
+
* @module mcp-server/tools/definitions/get-award-federal-accounts.tool
|
|
4
|
+
*/
|
|
5
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
6
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
7
|
+
import { getUSASpendingService } from '../../../services/usaspending/usaspending-service.js';
|
|
8
|
+
import { formatPaginationLine } from './pagination.js';
|
|
9
|
+
export const getAwardFederalAccountsTool = tool('usaspending_get_award_federal_accounts', {
|
|
10
|
+
title: 'Get Award Federal Accounts',
|
|
11
|
+
description: 'List the Treasury federal accounts that funded an award, with the amount obligated from each and the funding agency behind it. This is the award → appropriation link: each row returns federal_account (AGENCY-MAIN format, e.g. 080-0120) to chain into usaspending_get_federal_account for the account budget detail. The award_id must be a generated_unique_award_id — from usaspending_search_awards (generated_internal_id field) or usaspending_get_award. Distinct from usaspending_get_award account_obligations_by_defc, which breaks funding down by Disaster/Emergency Funding code rather than by account. An award_id that does not exist returns an empty list rather than an error.',
|
|
12
|
+
annotations: { readOnlyHint: true, openWorldHint: false, idempotentHint: true },
|
|
13
|
+
input: z.object({
|
|
14
|
+
award_id: z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1)
|
|
17
|
+
.describe('Award generated_unique_award_id (e.g., CONT_AWD_GSFC0198106DNAS526555_8000_-NONE-_-NONE-) — use generated_internal_id from usaspending_search_awards or generated_unique_award_id from usaspending_get_award'),
|
|
18
|
+
limit: z
|
|
19
|
+
.number()
|
|
20
|
+
.int()
|
|
21
|
+
.min(1)
|
|
22
|
+
.max(100)
|
|
23
|
+
.default(10)
|
|
24
|
+
.describe('Maximum results per page (1–100)'),
|
|
25
|
+
page: z.number().int().min(1).default(1).describe('Page number (1-based)'),
|
|
26
|
+
}),
|
|
27
|
+
output: z.object({
|
|
28
|
+
award_id: z.string().describe('Award ID queried'),
|
|
29
|
+
results: z
|
|
30
|
+
.array(z
|
|
31
|
+
.object({
|
|
32
|
+
federal_account: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Federal account code in AGENCY-MAIN format (e.g., 080-0120) — pass to usaspending_get_federal_account as account_code for the account budget detail'),
|
|
36
|
+
account_title: z.string().optional().describe('Full federal account title'),
|
|
37
|
+
total_transaction_obligated_amount: z
|
|
38
|
+
.number()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('Amount obligated to this award from this federal account in USD'),
|
|
41
|
+
funding_agency_name: z.string().optional().describe('Name of the funding agency'),
|
|
42
|
+
funding_agency_abbreviation: z
|
|
43
|
+
.string()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Abbreviation of the funding agency (e.g., "NASA")'),
|
|
46
|
+
funding_agency_slug: z
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe('Funding agency slug (e.g., "national-aeronautics-and-space-administration") — pass to usaspending_get_agency as agency_slug'),
|
|
50
|
+
funding_agency_id: z
|
|
51
|
+
.number()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe('Internal USAspending database ID of the funding agency — not the toptier code accepted by usaspending_get_agency'),
|
|
54
|
+
funding_toptier_agency_id: z
|
|
55
|
+
.number()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe('Internal USAspending database ID of the funding toptier agency — not the 3-digit toptier code accepted by usaspending_get_agency'),
|
|
58
|
+
})
|
|
59
|
+
.describe('Federal account that funded this award, with obligation and funding agency'))
|
|
60
|
+
.describe('Federal accounts funding this award'),
|
|
61
|
+
page_metadata: z
|
|
62
|
+
.object({
|
|
63
|
+
count: z.number().optional().describe('Total funding accounts across all pages'),
|
|
64
|
+
page: z.number().describe('Current page number'),
|
|
65
|
+
has_next: z.boolean().describe('Whether there are more pages of results'),
|
|
66
|
+
has_previous: z.boolean().describe('Whether there are previous pages'),
|
|
67
|
+
limit: z.number().describe('Results per page'),
|
|
68
|
+
})
|
|
69
|
+
.describe('Pagination metadata'),
|
|
70
|
+
}),
|
|
71
|
+
// Agent-facing context: the true total across pages, pagination state, and an
|
|
72
|
+
// empty-result notice. The upstream answers a nonexistent award_id with HTTP 200
|
|
73
|
+
// and zero rows — indistinguishable from a real award with no account linkage —
|
|
74
|
+
// so the empty case is a notice, not a declared failure.
|
|
75
|
+
enrichment: {
|
|
76
|
+
totalCount: z
|
|
77
|
+
.number()
|
|
78
|
+
.optional()
|
|
79
|
+
.describe('Total number of funding accounts across all pages (when available)'),
|
|
80
|
+
current_page: z.number().describe('Current page returned'),
|
|
81
|
+
has_next_page: z.boolean().describe('Whether there are more pages of funding accounts'),
|
|
82
|
+
notice: z
|
|
83
|
+
.string()
|
|
84
|
+
.optional()
|
|
85
|
+
.describe('Recovery hint when results are empty — the award_id may not exist or may have no account linkage. Absent when results are present.'),
|
|
86
|
+
},
|
|
87
|
+
errors: [
|
|
88
|
+
{
|
|
89
|
+
reason: 'api_unavailable',
|
|
90
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
91
|
+
when: 'USAspending.gov API is unreachable or returns an error.',
|
|
92
|
+
retryable: true,
|
|
93
|
+
recovery: 'The API may be temporarily down. Retry the request after a few seconds.',
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
async handler(input, ctx) {
|
|
97
|
+
ctx.log.info('usaspending_get_award_federal_accounts', {
|
|
98
|
+
award_id: input.award_id,
|
|
99
|
+
page: input.page,
|
|
100
|
+
});
|
|
101
|
+
const svc = getUSASpendingService();
|
|
102
|
+
const data = await svc.getAwardFederalAccounts({ award_id: input.award_id, limit: input.limit, page: input.page }, ctx);
|
|
103
|
+
const results = (data.results ?? []).map((r) => ({
|
|
104
|
+
...(r.federal_account ? { federal_account: r.federal_account } : {}),
|
|
105
|
+
...(r.account_title ? { account_title: r.account_title } : {}),
|
|
106
|
+
...(typeof r.total_transaction_obligated_amount === 'number'
|
|
107
|
+
? { total_transaction_obligated_amount: r.total_transaction_obligated_amount }
|
|
108
|
+
: {}),
|
|
109
|
+
...(r.funding_agency_name ? { funding_agency_name: r.funding_agency_name } : {}),
|
|
110
|
+
...(r.funding_agency_abbreviation
|
|
111
|
+
? { funding_agency_abbreviation: r.funding_agency_abbreviation }
|
|
112
|
+
: {}),
|
|
113
|
+
...(r.funding_agency_slug ? { funding_agency_slug: r.funding_agency_slug } : {}),
|
|
114
|
+
...(typeof r.funding_agency_id === 'number'
|
|
115
|
+
? { funding_agency_id: r.funding_agency_id }
|
|
116
|
+
: {}),
|
|
117
|
+
...(typeof r.funding_toptier_agency_id === 'number'
|
|
118
|
+
? { funding_toptier_agency_id: r.funding_toptier_agency_id }
|
|
119
|
+
: {}),
|
|
120
|
+
}));
|
|
121
|
+
const pageMeta = data.page_metadata ?? {};
|
|
122
|
+
const total = typeof pageMeta.count === 'number' ? pageMeta.count : undefined;
|
|
123
|
+
const currentPage = typeof pageMeta.page === 'number' ? pageMeta.page : input.page;
|
|
124
|
+
const hasNext = pageMeta.hasNext ?? false;
|
|
125
|
+
const hasPrevious = pageMeta.hasPrevious ?? false;
|
|
126
|
+
if (total !== undefined)
|
|
127
|
+
ctx.enrich.total(total);
|
|
128
|
+
ctx.enrich({
|
|
129
|
+
current_page: currentPage,
|
|
130
|
+
has_next_page: hasNext,
|
|
131
|
+
});
|
|
132
|
+
if (results.length === 0) {
|
|
133
|
+
ctx.enrich.notice(`No federal accounts fund award "${input.award_id}". ` +
|
|
134
|
+
'Verify the award_id is a generated_unique_award_id from usaspending_search_awards ' +
|
|
135
|
+
'(generated_internal_id field) — a nonexistent award_id returns this same empty result.');
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
award_id: input.award_id,
|
|
139
|
+
results,
|
|
140
|
+
page_metadata: {
|
|
141
|
+
...(total !== undefined ? { count: total } : {}),
|
|
142
|
+
page: currentPage,
|
|
143
|
+
has_next: hasNext,
|
|
144
|
+
has_previous: hasPrevious,
|
|
145
|
+
limit: input.limit,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
format: (result) => {
|
|
150
|
+
const lines = [`## Federal Accounts Funding Award: ${result.award_id}`];
|
|
151
|
+
const paginationLine = formatPaginationLine({
|
|
152
|
+
page: result.page_metadata.page,
|
|
153
|
+
limit: result.page_metadata.limit,
|
|
154
|
+
has_next: result.page_metadata.has_next,
|
|
155
|
+
total: result.page_metadata.count,
|
|
156
|
+
});
|
|
157
|
+
lines.push(`**Results:** ${result.results.length} | ${paginationLine} | **Has previous:** ${result.page_metadata.has_previous ? 'Yes' : 'No'}`);
|
|
158
|
+
for (const a of result.results) {
|
|
159
|
+
lines.push('');
|
|
160
|
+
lines.push(`### ${a.account_title ?? a.federal_account ?? 'Unknown'}`);
|
|
161
|
+
if (a.federal_account)
|
|
162
|
+
lines.push(`**Account Code (for get_federal_account):** ${a.federal_account}`);
|
|
163
|
+
if (typeof a.total_transaction_obligated_amount === 'number')
|
|
164
|
+
lines.push(`**Obligated from this account:** $${a.total_transaction_obligated_amount.toLocaleString()}`);
|
|
165
|
+
if (a.funding_agency_name)
|
|
166
|
+
lines.push(`**Funding Agency:** ${a.funding_agency_name}${a.funding_agency_abbreviation ? ` (${a.funding_agency_abbreviation})` : ''}`);
|
|
167
|
+
if (a.funding_agency_slug)
|
|
168
|
+
lines.push(`**Funding Agency Slug:** ${a.funding_agency_slug}`);
|
|
169
|
+
if (typeof a.funding_agency_id === 'number')
|
|
170
|
+
lines.push(`**Funding Agency ID:** ${a.funding_agency_id}`);
|
|
171
|
+
if (typeof a.funding_toptier_agency_id === 'number')
|
|
172
|
+
lines.push(`**Funding Toptier Agency ID:** ${a.funding_toptier_agency_id}`);
|
|
173
|
+
}
|
|
174
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
175
|
+
},
|
|
176
|
+
});
|
|
177
|
+
//# sourceMappingURL=get-award-federal-accounts.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-award-federal-accounts.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-award-federal-accounts.tool.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BA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C,kCAAkC,CAAC,CAAC,yBAAyB,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tool to fetch a federal account's obligations broken down by
|
|
3
|
+
* program activity or object class.
|
|
4
|
+
* @module mcp-server/tools/definitions/get-federal-account-breakdown.tool
|
|
5
|
+
*/
|
|
6
|
+
import { z } from '@cyanheads/mcp-ts-core';
|
|
7
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
8
|
+
export declare const getFederalAccountBreakdownTool: import("@cyanheads/mcp-ts-core").ToolDefinition<z.ZodObject<{
|
|
9
|
+
account_code: z.ZodString;
|
|
10
|
+
dimension: z.ZodEnum<{
|
|
11
|
+
program_activity: "program_activity";
|
|
12
|
+
object_class: "object_class";
|
|
13
|
+
}>;
|
|
14
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
page: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
17
|
+
account_code: z.ZodString;
|
|
18
|
+
dimension: z.ZodString;
|
|
19
|
+
results: z.ZodArray<z.ZodObject<{
|
|
20
|
+
code: z.ZodOptional<z.ZodString>;
|
|
21
|
+
name: z.ZodOptional<z.ZodString>;
|
|
22
|
+
obligations: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
type: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
page_metadata: z.ZodObject<{
|
|
26
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
page: z.ZodNumber;
|
|
28
|
+
has_next: z.ZodBoolean;
|
|
29
|
+
has_previous: z.ZodBoolean;
|
|
30
|
+
limit: z.ZodNumber;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
}, z.core.$strip>, readonly [{
|
|
33
|
+
readonly reason: "api_unavailable";
|
|
34
|
+
readonly code: JsonRpcErrorCode.ServiceUnavailable;
|
|
35
|
+
readonly when: "USAspending.gov API is unreachable or returns an error.";
|
|
36
|
+
readonly retryable: true;
|
|
37
|
+
readonly recovery: "The API may be temporarily down. Retry the request after a few seconds.";
|
|
38
|
+
}], {
|
|
39
|
+
readonly applied_dimension: z.ZodString;
|
|
40
|
+
readonly totalCount: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
readonly current_page: z.ZodNumber;
|
|
42
|
+
readonly has_next_page: z.ZodBoolean;
|
|
43
|
+
readonly notice: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=get-federal-account-breakdown.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-federal-account-breakdown.tool.d.ts","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-federal-account-breakdown.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,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2LzC,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Tool to fetch a federal account's obligations broken down by
|
|
3
|
+
* program activity or object class.
|
|
4
|
+
* @module mcp-server/tools/definitions/get-federal-account-breakdown.tool
|
|
5
|
+
*/
|
|
6
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
7
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
8
|
+
import { getUSASpendingService } from '../../../services/usaspending/usaspending-service.js';
|
|
9
|
+
import { formatPaginationLine } from './pagination.js';
|
|
10
|
+
export const getFederalAccountBreakdownTool = tool('usaspending_get_federal_account_breakdown', {
|
|
11
|
+
title: 'Get Federal Account Breakdown',
|
|
12
|
+
description: "Fetch a federal account's obligations broken down by program activity (what the money funds) or object class (what it buys — personnel, supplies, contracts). Use the dimension parameter to select the axis. Account codes are AGENCY-MAIN format and come from usaspending_search_federal_accounts (its account_number output field), usaspending_get_award_federal_accounts (its federal_account field), or usaspending_get_federal_account. Paginated with an honest total count. For the account's own metadata and top-level totals, use usaspending_get_federal_account.",
|
|
13
|
+
annotations: { readOnlyHint: true, openWorldHint: false, idempotentHint: true },
|
|
14
|
+
input: z.object({
|
|
15
|
+
account_code: z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.describe('Federal account code in AGENCY-MAIN format (e.g., 097-0100). Returned as account_number by usaspending_search_federal_accounts and as federal_account by usaspending_get_award_federal_accounts.'),
|
|
19
|
+
dimension: z
|
|
20
|
+
.enum(['program_activity', 'object_class'])
|
|
21
|
+
.describe('Breakdown axis: program_activity (obligations by the program the funds support) or object_class (obligations by the category of goods/services purchased)'),
|
|
22
|
+
limit: z
|
|
23
|
+
.number()
|
|
24
|
+
.int()
|
|
25
|
+
.min(1)
|
|
26
|
+
.max(100)
|
|
27
|
+
.default(10)
|
|
28
|
+
.describe('Maximum results per page (1–100)'),
|
|
29
|
+
page: z.number().int().min(1).default(1).describe('Page number (1-based)'),
|
|
30
|
+
}),
|
|
31
|
+
output: z.object({
|
|
32
|
+
account_code: z.string().describe('Federal account code queried'),
|
|
33
|
+
dimension: z.string().describe('Breakdown dimension returned'),
|
|
34
|
+
results: z
|
|
35
|
+
.array(z
|
|
36
|
+
.object({
|
|
37
|
+
code: z
|
|
38
|
+
.string()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe('Program activity code or object class code (e.g., "0001", "25.2")'),
|
|
41
|
+
name: z.string().optional().describe('Program activity name or object class name'),
|
|
42
|
+
obligations: z.number().optional().describe('Obligated amount in USD'),
|
|
43
|
+
type: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Program activity code system, returned only for the program_activity dimension: "PAC/PAN" (legacy program activity code/name) or "PARK" (Program Activity Reporting Key). Both can appear for the same account. Absent for object_class rows.'),
|
|
47
|
+
})
|
|
48
|
+
.describe('Breakdown row with code, name, and obligated amount'))
|
|
49
|
+
.describe('Breakdown rows for the requested dimension'),
|
|
50
|
+
page_metadata: z
|
|
51
|
+
.object({
|
|
52
|
+
total: z.number().optional().describe('Total rows across all pages'),
|
|
53
|
+
page: z.number().describe('Current page number'),
|
|
54
|
+
has_next: z.boolean().describe('Whether there are more pages of results'),
|
|
55
|
+
has_previous: z.boolean().describe('Whether there are previous pages'),
|
|
56
|
+
limit: z.number().describe('Results per page'),
|
|
57
|
+
})
|
|
58
|
+
.describe('Pagination metadata'),
|
|
59
|
+
}),
|
|
60
|
+
// Agent-facing context: the true total across pages, pagination state, and an
|
|
61
|
+
// empty-result notice. Both breakdown endpoints answer a nonexistent account
|
|
62
|
+
// code with HTTP 200 and total: 0 — indistinguishable from a real account with
|
|
63
|
+
// no obligations on this axis — so the empty case is a notice, not a declared
|
|
64
|
+
// failure. (usaspending_get_federal_account's GET route does 400 on a miss and
|
|
65
|
+
// can therefore keep a not-found contract; these POST routes cannot.)
|
|
66
|
+
enrichment: {
|
|
67
|
+
applied_dimension: z.string().describe('Breakdown dimension applied'),
|
|
68
|
+
totalCount: z
|
|
69
|
+
.number()
|
|
70
|
+
.optional()
|
|
71
|
+
.describe('Total number of breakdown rows across all pages (when available)'),
|
|
72
|
+
current_page: z.number().describe('Current page returned'),
|
|
73
|
+
has_next_page: z.boolean().describe('Whether there are more pages of breakdown rows'),
|
|
74
|
+
notice: z
|
|
75
|
+
.string()
|
|
76
|
+
.optional()
|
|
77
|
+
.describe('Recovery hint when results are empty — the account code may not exist or may have no obligations on this axis. Absent when results are present.'),
|
|
78
|
+
},
|
|
79
|
+
errors: [
|
|
80
|
+
{
|
|
81
|
+
reason: 'api_unavailable',
|
|
82
|
+
code: JsonRpcErrorCode.ServiceUnavailable,
|
|
83
|
+
when: 'USAspending.gov API is unreachable or returns an error.',
|
|
84
|
+
retryable: true,
|
|
85
|
+
recovery: 'The API may be temporarily down. Retry the request after a few seconds.',
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
async handler(input, ctx) {
|
|
89
|
+
ctx.log.info('usaspending_get_federal_account_breakdown', {
|
|
90
|
+
account_code: input.account_code,
|
|
91
|
+
dimension: input.dimension,
|
|
92
|
+
page: input.page,
|
|
93
|
+
});
|
|
94
|
+
const svc = getUSASpendingService();
|
|
95
|
+
const body = { limit: input.limit, page: input.page };
|
|
96
|
+
const data = input.dimension === 'program_activity'
|
|
97
|
+
? await svc.getFederalAccountProgramActivities(input.account_code, body, ctx)
|
|
98
|
+
: await svc.getFederalAccountObjectClasses(input.account_code, body, ctx);
|
|
99
|
+
const results = (data.results ?? []).map((r) => ({
|
|
100
|
+
...(r.code ? { code: r.code } : {}),
|
|
101
|
+
...(r.name ? { name: r.name } : {}),
|
|
102
|
+
...(typeof r.obligations === 'number' ? { obligations: r.obligations } : {}),
|
|
103
|
+
...(r.type ? { type: r.type } : {}),
|
|
104
|
+
}));
|
|
105
|
+
const pageMeta = data.page_metadata ?? {};
|
|
106
|
+
const total = typeof pageMeta.total === 'number' ? pageMeta.total : undefined;
|
|
107
|
+
const currentPage = typeof pageMeta.page === 'number' ? pageMeta.page : input.page;
|
|
108
|
+
const hasNext = pageMeta.hasNext ?? false;
|
|
109
|
+
const hasPrevious = pageMeta.hasPrevious ?? false;
|
|
110
|
+
if (total !== undefined)
|
|
111
|
+
ctx.enrich.total(total);
|
|
112
|
+
ctx.enrich({
|
|
113
|
+
applied_dimension: input.dimension,
|
|
114
|
+
current_page: currentPage,
|
|
115
|
+
has_next_page: hasNext,
|
|
116
|
+
});
|
|
117
|
+
if (results.length === 0) {
|
|
118
|
+
ctx.enrich.notice(`No ${input.dimension} obligations found for federal account "${input.account_code}". ` +
|
|
119
|
+
'Verify the code with usaspending_search_federal_accounts and pass its account_number value ' +
|
|
120
|
+
'— a nonexistent account code returns this same empty result. ' +
|
|
121
|
+
`Try dimension="${input.dimension === 'program_activity' ? 'object_class' : 'program_activity'}" for the other breakdown axis.`);
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
account_code: input.account_code,
|
|
125
|
+
dimension: input.dimension,
|
|
126
|
+
results,
|
|
127
|
+
page_metadata: {
|
|
128
|
+
...(total !== undefined ? { total } : {}),
|
|
129
|
+
page: currentPage,
|
|
130
|
+
has_next: hasNext,
|
|
131
|
+
has_previous: hasPrevious,
|
|
132
|
+
limit: input.limit,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
format: (result) => {
|
|
137
|
+
const lines = [
|
|
138
|
+
`## Federal Account ${result.account_code} — ${result.dimension} breakdown`,
|
|
139
|
+
];
|
|
140
|
+
const paginationLine = formatPaginationLine({
|
|
141
|
+
page: result.page_metadata.page,
|
|
142
|
+
limit: result.page_metadata.limit,
|
|
143
|
+
has_next: result.page_metadata.has_next,
|
|
144
|
+
total: result.page_metadata.total,
|
|
145
|
+
});
|
|
146
|
+
lines.push(`**Results:** ${result.results.length} | ${paginationLine} | **Has previous:** ${result.page_metadata.has_previous ? 'Yes' : 'No'}`);
|
|
147
|
+
if (result.results.length > 0) {
|
|
148
|
+
// `type` is a program-activity concept — object-class rows never carry one, so the
|
|
149
|
+
// column appears only when a row has a value for it. An always-empty column reads
|
|
150
|
+
// as missing data rather than an inapplicable concept.
|
|
151
|
+
const hasType = result.results.some((r) => r.type);
|
|
152
|
+
lines.push('');
|
|
153
|
+
lines.push(hasType ? '| Code | Name | Obligations | Type |' : '| Code | Name | Obligations |');
|
|
154
|
+
lines.push(hasType ? '|:-----|:-----|:------------|:-----|' : '|:-----|:-----|:------------|');
|
|
155
|
+
for (const r of result.results) {
|
|
156
|
+
const obligations = typeof r.obligations === 'number' ? `$${r.obligations.toLocaleString()}` : 'N/A';
|
|
157
|
+
const row = `| ${r.code ?? 'N/A'} | ${r.name ?? 'N/A'} | ${obligations} |`;
|
|
158
|
+
lines.push(hasType ? `${row} ${r.type ?? 'N/A'} |` : row);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
//# sourceMappingURL=get-federal-account-breakdown.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-federal-account-breakdown.tool.js","sourceRoot":"","sources":["../../../../src/mcp-server/tools/definitions/get-federal-account-breakdown.tool.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAC,2CAA2C,EAAE;IAC9F,KAAK,EAAE,+BAA+B;IACtC,WAAW,EACT,ijBAAijB;IACnjB,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE;IAE/E,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,YAAY,EAAE,CAAC;aACZ,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACP,kMAAkM,CACnM;QACH,SAAS,EAAE,CAAC;aACT,IAAI,CAAC,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;aAC1C,QAAQ,CACP,2JAA2J,CAC5J;QACH,KAAK,EAAE,CAAC;aACL,MAAM,EAAE;aACR,GAAG,EAAE;aACL,G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