@cyanheads/usaspending-mcp-server 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CLAUDE.md +405 -0
  2. package/Dockerfile +98 -0
  3. package/README.md +391 -0
  4. package/changelog/0.1.x/0.1.0.md +26 -0
  5. package/changelog/0.1.x/0.1.1.md +16 -0
  6. package/changelog/template.md +119 -0
  7. package/dist/config/server-config.d.ts +13 -0
  8. package/dist/config/server-config.d.ts.map +1 -0
  9. package/dist/config/server-config.js +29 -0
  10. package/dist/config/server-config.js.map +1 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +25 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/mcp-server/tools/definitions/autocomplete.tool.d.ts +39 -0
  16. package/dist/mcp-server/tools/definitions/autocomplete.tool.d.ts.map +1 -0
  17. package/dist/mcp-server/tools/definitions/autocomplete.tool.js +138 -0
  18. package/dist/mcp-server/tools/definitions/autocomplete.tool.js.map +1 -0
  19. package/dist/mcp-server/tools/definitions/disaster-spending.tool.d.ts +78 -0
  20. package/dist/mcp-server/tools/definitions/disaster-spending.tool.d.ts.map +1 -0
  21. package/dist/mcp-server/tools/definitions/disaster-spending.tool.js +300 -0
  22. package/dist/mcp-server/tools/definitions/disaster-spending.tool.js.map +1 -0
  23. package/dist/mcp-server/tools/definitions/filters.d.ts +15 -0
  24. package/dist/mcp-server/tools/definitions/filters.d.ts.map +1 -0
  25. package/dist/mcp-server/tools/definitions/filters.js +26 -0
  26. package/dist/mcp-server/tools/definitions/filters.js.map +1 -0
  27. package/dist/mcp-server/tools/definitions/get-agency.tool.d.ts +50 -0
  28. package/dist/mcp-server/tools/definitions/get-agency.tool.d.ts.map +1 -0
  29. package/dist/mcp-server/tools/definitions/get-agency.tool.js +217 -0
  30. package/dist/mcp-server/tools/definitions/get-agency.tool.js.map +1 -0
  31. package/dist/mcp-server/tools/definitions/get-award-subawards.tool.d.ts +56 -0
  32. package/dist/mcp-server/tools/definitions/get-award-subawards.tool.d.ts.map +1 -0
  33. package/dist/mcp-server/tools/definitions/get-award-subawards.tool.js +154 -0
  34. package/dist/mcp-server/tools/definitions/get-award-subawards.tool.js.map +1 -0
  35. package/dist/mcp-server/tools/definitions/get-award-transactions.tool.d.ts +53 -0
  36. package/dist/mcp-server/tools/definitions/get-award-transactions.tool.d.ts.map +1 -0
  37. package/dist/mcp-server/tools/definitions/get-award-transactions.tool.js +147 -0
  38. package/dist/mcp-server/tools/definitions/get-award-transactions.tool.js.map +1 -0
  39. package/dist/mcp-server/tools/definitions/get-award.tool.d.ts +91 -0
  40. package/dist/mcp-server/tools/definitions/get-award.tool.d.ts.map +1 -0
  41. package/dist/mcp-server/tools/definitions/get-award.tool.js +433 -0
  42. package/dist/mcp-server/tools/definitions/get-award.tool.js.map +1 -0
  43. package/dist/mcp-server/tools/definitions/get-federal-account.tool.d.ts +32 -0
  44. package/dist/mcp-server/tools/definitions/get-federal-account.tool.d.ts.map +1 -0
  45. package/dist/mcp-server/tools/definitions/get-federal-account.tool.js +107 -0
  46. package/dist/mcp-server/tools/definitions/get-federal-account.tool.js.map +1 -0
  47. package/dist/mcp-server/tools/definitions/get-recipient.tool.d.ts +55 -0
  48. package/dist/mcp-server/tools/definitions/get-recipient.tool.d.ts.map +1 -0
  49. package/dist/mcp-server/tools/definitions/get-recipient.tool.js +194 -0
  50. package/dist/mcp-server/tools/definitions/get-recipient.tool.js.map +1 -0
  51. package/dist/mcp-server/tools/definitions/index.d.ts +678 -0
  52. package/dist/mcp-server/tools/definitions/index.d.ts.map +1 -0
  53. package/dist/mcp-server/tools/definitions/index.js +49 -0
  54. package/dist/mcp-server/tools/definitions/index.js.map +1 -0
  55. package/dist/mcp-server/tools/definitions/list-agencies.tool.d.ts +36 -0
  56. package/dist/mcp-server/tools/definitions/list-agencies.tool.d.ts.map +1 -0
  57. package/dist/mcp-server/tools/definitions/list-agencies.tool.js +93 -0
  58. package/dist/mcp-server/tools/definitions/list-agencies.tool.js.map +1 -0
  59. package/dist/mcp-server/tools/definitions/search-awards.tool.d.ts +77 -0
  60. package/dist/mcp-server/tools/definitions/search-awards.tool.d.ts.map +1 -0
  61. package/dist/mcp-server/tools/definitions/search-awards.tool.js +300 -0
  62. package/dist/mcp-server/tools/definitions/search-awards.tool.js.map +1 -0
  63. package/dist/mcp-server/tools/definitions/search-recipients.tool.d.ts +46 -0
  64. package/dist/mcp-server/tools/definitions/search-recipients.tool.d.ts.map +1 -0
  65. package/dist/mcp-server/tools/definitions/search-recipients.tool.js +143 -0
  66. package/dist/mcp-server/tools/definitions/search-recipients.tool.js.map +1 -0
  67. package/dist/mcp-server/tools/definitions/spending-by-category.tool.d.ts +57 -0
  68. package/dist/mcp-server/tools/definitions/spending-by-category.tool.d.ts.map +1 -0
  69. package/dist/mcp-server/tools/definitions/spending-by-category.tool.js +136 -0
  70. package/dist/mcp-server/tools/definitions/spending-by-category.tool.js.map +1 -0
  71. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.d.ts +51 -0
  72. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.d.ts.map +1 -0
  73. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.js +153 -0
  74. package/dist/mcp-server/tools/definitions/spending-by-geography.tool.js.map +1 -0
  75. package/dist/mcp-server/tools/definitions/spending-over-time.tool.d.ts +53 -0
  76. package/dist/mcp-server/tools/definitions/spending-over-time.tool.d.ts.map +1 -0
  77. package/dist/mcp-server/tools/definitions/spending-over-time.tool.js +163 -0
  78. package/dist/mcp-server/tools/definitions/spending-over-time.tool.js.map +1 -0
  79. package/dist/services/usaspending/types.d.ts +489 -0
  80. package/dist/services/usaspending/types.d.ts.map +1 -0
  81. package/dist/services/usaspending/types.js +6 -0
  82. package/dist/services/usaspending/types.js.map +1 -0
  83. package/dist/services/usaspending/usaspending-service.d.ts +137 -0
  84. package/dist/services/usaspending/usaspending-service.d.ts.map +1 -0
  85. package/dist/services/usaspending/usaspending-service.js +201 -0
  86. package/dist/services/usaspending/usaspending-service.js.map +1 -0
  87. package/package.json +80 -0
  88. package/server.json +99 -0
package/README.md ADDED
@@ -0,0 +1,391 @@
1
+ <div align="center">
2
+ <h1>@cyanheads/usaspending-mcp-server</h1>
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>14 Tools</div>
5
+ </p>
6
+ </div>
7
+
8
+ <div align="center">
9
+
10
+ [![Version](https://img.shields.io/badge/Version-0.1.1-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)
11
+
12
+ </div>
13
+
14
+ <div align="center">
15
+
16
+ [![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ ## Tools
23
+
24
+ 14 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:
25
+
26
+ | Tool | Description |
27
+ |:---|:---|
28
+ | `usaspending_search_awards` | Search federal awards by keyword, recipient, agency, award type, NAICS code, location, or date range. Returns ranked award summaries with recipient names, amounts, agencies, and award IDs for chaining. |
29
+ | `usaspending_get_award` | Fetch full details of a federal award by its generated ID. Returns contract or assistance data, parent IDV info, subaward count, and funding account linkages. |
30
+ | `usaspending_get_award_transactions` | List individual transactions (modifications, amendments) on an award. Reveals spending history and obligation changes over time. |
31
+ | `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. |
32
+ | `usaspending_search_recipients` | Search for organizations receiving federal funds by name or UEI. Returns recipient IDs, total award amounts, and business type classifications. |
33
+ | `usaspending_get_recipient` | Fetch a recipient's profile: address, business types, parent organization, alternate names, and total award amounts by type. |
34
+ | `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. |
35
+ | `usaspending_spending_by_geography` | Aggregate federal spending by state, county, or congressional district. Returns per-capita figures when combined with population data. |
36
+ | `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. |
37
+ | `usaspending_spending_over_time` | Fetch aggregated spending by fiscal year, fiscal quarter, or calendar month. Filter by award type, agency, recipient, or keyword to trace trends in a specific area. |
38
+ | `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. |
39
+ | `usaspending_get_federal_account` | Fetch a federal account's budget data: total obligations, outlays, program activities, and object class breakdown. Account codes appear in award funding details. |
40
+ | `usaspending_list_agencies` | List all top-tier federal agencies with toptier codes, budget authority amounts, and obligation totals. Entry point for agency navigation. |
41
+ | `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. |
42
+
43
+ ### `usaspending_search_awards`
44
+
45
+ Search for federal awards across contracts, grants, loans, direct payments, and IDVs.
46
+
47
+ - Full-text keyword search across award descriptions, recipient names, and locations
48
+ - Filter by award type codes (`A/B/C/D` = contracts, `02/03/04/05` = grants, `06/10` = direct payments, `07/08` = loans, `IDV_*` = IDVs)
49
+ - Filter by awarding or funding agency (toptier or subtier), recipient name or ID, NAICS code, PSC code, and place of performance
50
+ - Date range filtering — earliest 2007-10-01 via search API
51
+ - Pagination via `limit` (max 100) and `page`; `page_metadata.hasNext` signals more results
52
+ - Returns `generated_internal_id` for chaining to `usaspending_get_award` and `agency_slug` for chaining to `usaspending_get_agency`
53
+
54
+ ---
55
+
56
+ ### `usaspending_get_award`
57
+
58
+ Fetch complete details for a single federal award by its generated ID.
59
+
60
+ - Returns type, description, total obligation, date signed, and subaward count
61
+ - Exposes `recipient.recipient_hash` for chaining to `usaspending_get_recipient`
62
+ - Exposes `parent_award.generated_unique_award_id` for traversing IDV parent chains
63
+ - Includes NAICS code and product/service code from the latest transaction
64
+ - Returns `account_obligations_by_defc` linking the award to specific disaster/emergency appropriations
65
+ - Award IDs use the `generated_unique_award_id` format (e.g., `CONT_AWD_FA862118F6251_9700_...`)
66
+
67
+ ---
68
+
69
+ ### `usaspending_get_award_transactions`
70
+
71
+ List obligation history and modifications for an award.
72
+
73
+ - Each row is one transaction: `action_date`, `federal_action_obligation`, `modification_number`, and description
74
+ - Pagination via `limit` and `page`; configurable sort and order
75
+
76
+ ---
77
+
78
+ ### `usaspending_get_award_subawards`
79
+
80
+ List subawards under a prime contract or grant.
81
+
82
+ - Each row covers: subaward number, description, action date, amount, and recipient name
83
+ - Reveals the supply chain below the prime — who actually performs the work
84
+ - Pagination via `limit` and `page`; configurable sort and order
85
+
86
+ ---
87
+
88
+ ### `usaspending_search_recipients`
89
+
90
+ Search for organizations receiving federal funds by name or UEI.
91
+
92
+ - Returns recipient IDs (UUID hashes with level suffix: `-P` parent, `-C` child, `-R` root), UEI, DUNS, name, recipient level, and total award amount
93
+ - `results[].id` chains to `usaspending_get_recipient`; `uei` and `duns` chain to SAM.gov or SEC EDGAR
94
+
95
+ ---
96
+
97
+ ### `usaspending_get_recipient`
98
+
99
+ Fetch a recipient's full profile.
100
+
101
+ - Returns address, business type classifications, parent organization, alternate names
102
+ - Optionally scope to a specific fiscal year and award type
103
+ - Requires the UUID-based recipient ID from `usaspending_search_recipients`
104
+
105
+ ---
106
+
107
+ ### `usaspending_get_agency`
108
+
109
+ Fetch an agency's current fiscal year overview.
110
+
111
+ - Returns mission, budget authority amount, obligation amount, sub-agency count, and DEF codes
112
+ - Accepts either a 3-digit `toptier_code` (e.g., `097` for DoD) or an `agency_slug` (e.g., `department-of-defense`) — slugs appear in award search results, eliminating an intermediate lookup
113
+ - Includes sub-agency breakdown with transaction counts
114
+
115
+ ---
116
+
117
+ ### `usaspending_spending_by_geography`
118
+
119
+ Aggregate federal spending by geographic unit.
120
+
121
+ - `scope`: `place_of_performance` or `recipient_location`
122
+ - `geo_layer`: `state`, `county`, or `district`
123
+ - Returns `shape_code`, `display_name`, `aggregated_amount`, and `per_capita` (when `population` is available)
124
+ - Geographic filters require FIPS codes or 2-letter state abbreviations — use a geocoding server (e.g., Census or OpenStreetMap) to resolve place names first
125
+
126
+ ---
127
+
128
+ ### `usaspending_spending_by_category`
129
+
130
+ Aggregate spending broken down by a single dimension.
131
+
132
+ - `category` enum maps to the right sub-route: `naics`, `psc`, `awarding_agency`, `funding_agency`, `cfda`, or `recipient`
133
+ - Returns top items with amounts and codes for trend analysis
134
+ - Accepts the standard award filter object for scoping to a specific agency, time period, or keyword
135
+
136
+ ---
137
+
138
+ ### `usaspending_spending_over_time`
139
+
140
+ Fetch aggregated spending grouped by time period.
141
+
142
+ - `group`: `fiscal_year`, `quarter`, or `month`
143
+ - Filter by award type, agency, recipient, or keyword to trace trends in a specific area
144
+ - `subawards: true` shifts aggregation to the subaward layer
145
+
146
+ ---
147
+
148
+ ### `usaspending_disaster_spending`
149
+
150
+ Fetch disaster and emergency supplemental spending consolidated from nine+ API endpoints.
151
+
152
+ - `dimension` enum selects the breakdown axis: `overview`, `agency`, `cfda`, `recipient`, or `geography`
153
+ - `spending_type` selects between grant/contract obligations (`spending`) and loan face values (`loans`)
154
+ - Filter by `def_codes` to isolate a specific emergency appropriation (e.g., COVID-19 = `L`, `M`, `N`, `O`, `P`, `U`)
155
+ - Returns obligation, outlay, and award count per row
156
+
157
+ ---
158
+
159
+ ### `usaspending_get_federal_account`
160
+
161
+ Fetch budget data for a federal account identified by its account code.
162
+
163
+ - Returns account title, federal account code, budget function, and managing agency
164
+ - Includes fiscal year snapshot with total obligations and outlays
165
+ - Program activity and object class breakdown shows how funds are categorized
166
+ - Account codes appear in `account_obligations_by_defc` from `usaspending_get_award`
167
+
168
+ ---
169
+
170
+ ### `usaspending_list_agencies`
171
+
172
+ List all top-tier federal agencies.
173
+
174
+ - Returns agency name, abbreviation, `toptier_code`, `agency_slug`, obligated amount, and budget authority amount for the current fiscal year
175
+ - Entry point for agency navigation — `toptier_code` is required by `usaspending_get_agency` and agency filters
176
+ - Configurable sort and order
177
+
178
+ ---
179
+
180
+ ### `usaspending_autocomplete`
181
+
182
+ Discover valid code values for award filter fields.
183
+
184
+ - `type` enum selects the lookup: `naics`, `psc`, `cfda`, `awarding_agency`, or `recipient`
185
+ - Returns matching codes and names — use before filtering to find the right code when you only know a description (e.g., "cybersecurity" → NAICS code)
186
+ - Consolidates five autocomplete endpoints into one tool
187
+
188
+ ## Features
189
+
190
+ Built on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):
191
+
192
+ - Declarative tool definitions — single file per tool, framework handles registration and validation
193
+ - Unified error handling — handlers throw, framework catches, classifies, and formats
194
+ - Pluggable auth: `none`, `jwt`, `oauth`
195
+ - Swappable storage backends: `in-memory`, `filesystem`, `Supabase`, `Cloudflare KV/R2/D1`
196
+ - Structured logging with optional OpenTelemetry tracing
197
+ - STDIO and Streamable HTTP transports
198
+
199
+ USAspending-specific:
200
+
201
+ - Full USAspending.gov API v2 coverage — award search, award detail, recipient and agency profiles, spending analytics, disaster spending, and federal accounts
202
+ - No authentication required — all data is public domain under the DATA Act
203
+ - `usaspending_spending_by_category` consolidates 14 category sub-routes behind a single `category` enum; `usaspending_disaster_spending` consolidates 9+ disaster endpoints behind `dimension` + `spending_type` enums
204
+ - `usaspending_get_agency` accepts both `toptier_code` and `agency_slug`, eliminating the intermediate agency-list lookup that award search results would otherwise require
205
+ - `usaspending_autocomplete` serves as the code-discovery step before filtering — maps human-readable terms to NAICS, PSC, CFDA, and agency codes
206
+
207
+ Agent-friendly output:
208
+
209
+ - Chaining fields on every response — `generated_internal_id`, `agency_slug`, `recipient_hash`, and `account_code` fields are surfaced explicitly so agents can follow the money without parsing identifiers out of display strings
210
+ - Pagination metadata on all list responses — `page_metadata.hasNext`, `page_metadata.page`, and `page_metadata.total` let agents iterate large result sets without guessing
211
+ - Structured geographic outputs — `shape_code`, `display_name`, `aggregated_amount`, and `per_capita` are typed consistently across state, county, and district views for composable analysis
212
+
213
+ ## Getting started
214
+
215
+ Add the following to your MCP client configuration file. No API key is required — USAspending.gov data is public domain.
216
+
217
+ ```json
218
+ {
219
+ "mcpServers": {
220
+ "usaspending": {
221
+ "type": "stdio",
222
+ "command": "bunx",
223
+ "args": ["@cyanheads/usaspending-mcp-server@latest"],
224
+ "env": {
225
+ "MCP_TRANSPORT_TYPE": "stdio",
226
+ "MCP_LOG_LEVEL": "info"
227
+ }
228
+ }
229
+ }
230
+ }
231
+ ```
232
+
233
+ Or with npx (no Bun required):
234
+
235
+ ```json
236
+ {
237
+ "mcpServers": {
238
+ "usaspending": {
239
+ "type": "stdio",
240
+ "command": "npx",
241
+ "args": ["-y", "@cyanheads/usaspending-mcp-server@latest"],
242
+ "env": {
243
+ "MCP_TRANSPORT_TYPE": "stdio",
244
+ "MCP_LOG_LEVEL": "info"
245
+ }
246
+ }
247
+ }
248
+ }
249
+ ```
250
+
251
+ Or with Docker:
252
+
253
+ ```json
254
+ {
255
+ "mcpServers": {
256
+ "usaspending": {
257
+ "type": "stdio",
258
+ "command": "docker",
259
+ "args": [
260
+ "run", "-i", "--rm",
261
+ "-e", "MCP_TRANSPORT_TYPE=stdio",
262
+ "ghcr.io/cyanheads/usaspending-mcp-server:latest"
263
+ ]
264
+ }
265
+ }
266
+ }
267
+ ```
268
+
269
+ For Streamable HTTP, set the transport and start the server:
270
+
271
+ ```sh
272
+ MCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 bun run start:http
273
+ # Server listens at http://localhost:3010/mcp
274
+ ```
275
+
276
+ ### Prerequisites
277
+
278
+ - [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+).
279
+ - No API key required — USAspending.gov is a public data platform with no authentication requirement.
280
+
281
+ ### Installation
282
+
283
+ 1. **Clone the repository:**
284
+
285
+ ```sh
286
+ git clone https://github.com/cyanheads/usaspending-mcp-server.git
287
+ ```
288
+
289
+ 2. **Navigate into the directory:**
290
+
291
+ ```sh
292
+ cd usaspending-mcp-server
293
+ ```
294
+
295
+ 3. **Install dependencies:**
296
+
297
+ ```sh
298
+ bun install
299
+ ```
300
+
301
+ 4. **Configure environment (optional):**
302
+
303
+ ```sh
304
+ cp .env.example .env
305
+ # edit .env if you need to override defaults
306
+ ```
307
+
308
+ ## Configuration
309
+
310
+ All configuration is validated at startup via Zod schemas in `src/config/server-config.ts`. No environment variables are required — the defaults work out of the box.
311
+
312
+ | Variable | Description | Default |
313
+ |:---------|:------------|:--------|
314
+ | `USASPENDING_BASE_URL` | Base URL for the USAspending.gov API. | `https://api.usaspending.gov/api/v2/` |
315
+ | `USASPENDING_TIMEOUT_MS` | Per-request HTTP timeout in milliseconds. | `30000` |
316
+ | `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |
317
+ | `MCP_HTTP_PORT` | Port for the HTTP server. | `3010` |
318
+ | `MCP_HTTP_ENDPOINT_PATH` | HTTP endpoint path. | `/mcp` |
319
+ | `MCP_PUBLIC_URL` | Public origin override for TLS-terminating reverse-proxy deployments. | — |
320
+ | `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |
321
+ | `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `warning`, `error`, etc.). | `info` |
322
+ | `LOGS_DIR` | Directory for log files (Node.js only). | `<project-root>/logs` |
323
+ | `STORAGE_PROVIDER_TYPE` | Storage backend: `in-memory`, `filesystem`, `supabase`, `cloudflare-kv/r2/d1`. | `in-memory` |
324
+ | `OTEL_ENABLED` | Enable [OpenTelemetry instrumentation](https://github.com/cyanheads/mcp-ts-core/tree/main/docs/telemetry). | `false` |
325
+
326
+ See [`.env.example`](./.env.example) for the full list of optional overrides.
327
+
328
+ ## Running the server
329
+
330
+ ### Local development
331
+
332
+ - **Build and run:**
333
+
334
+ ```sh
335
+ # One-time build
336
+ bun run rebuild
337
+
338
+ # Run the built server
339
+ bun run start:stdio
340
+ # or
341
+ bun run start:http
342
+ ```
343
+
344
+ - **Run checks and tests:**
345
+
346
+ ```sh
347
+ bun run devcheck # Lint, format, typecheck, security
348
+ bun run test # Vitest test suite
349
+ bun run lint:mcp # Validate MCP definitions against spec
350
+ ```
351
+
352
+ ### Docker
353
+
354
+ ```sh
355
+ docker build -t usaspending-mcp-server .
356
+ docker run --rm -p 3010:3010 usaspending-mcp-server
357
+ ```
358
+
359
+ The Dockerfile defaults to HTTP transport, stateless session mode, and logs to `/var/log/usaspending-mcp-server`. OpenTelemetry peer dependencies are installed by default — build with `--build-arg OTEL_ENABLED=false` to omit them.
360
+
361
+ ## Project structure
362
+
363
+ | Directory | Purpose |
364
+ |:----------|:--------|
365
+ | `src/index.ts` | `createApp()` entry point — registers tools and inits services. |
366
+ | `src/config` | Server-specific environment variable parsing and validation with Zod. |
367
+ | `src/mcp-server/tools` | Tool definitions (`*.tool.ts`). |
368
+ | `src/services` | USAspending API client and service layer. |
369
+ | `tests/` | Unit and integration tests mirroring `src/`. |
370
+
371
+ ## Development guide
372
+
373
+ See [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:
374
+
375
+ - Handlers throw, framework catches — no `try/catch` in tool logic
376
+ - Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage
377
+ - Register new tools via the barrels in `src/mcp-server/tools/definitions/index.ts`
378
+ - Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields
379
+
380
+ ## Contributing
381
+
382
+ Issues and pull requests are welcome. Run checks and tests before submitting:
383
+
384
+ ```sh
385
+ bun run devcheck
386
+ bun run test
387
+ ```
388
+
389
+ ## License
390
+
391
+ Apache-2.0 — see [LICENSE](LICENSE) for details.
@@ -0,0 +1,26 @@
1
+ ---
2
+ summary: "Initial release — 14 tools covering USAspending.gov award search, analytics, and federal account data"
3
+ breaking: false
4
+ security: false
5
+ ---
6
+
7
+ # 0.1.0 — 2026-05-25
8
+
9
+ ## Added
10
+
11
+ - **`usaspending_search_awards`** — search federal awards by keyword, recipient, agency, award type, NAICS, PSC, location, and date range
12
+ - **`usaspending_get_award`** — fetch full award details by generated ID, including recipient hash, parent IDV, subaward count, and funding account linkages
13
+ - **`usaspending_get_award_transactions`** — list obligation history and modifications on an award
14
+ - **`usaspending_get_award_subawards`** — list subaward contracts and grants under a prime award
15
+ - **`usaspending_search_recipients`** — search organizations receiving federal funds by name or UEI
16
+ - **`usaspending_get_recipient`** — fetch recipient profile with address, business types, parent org, and award totals
17
+ - **`usaspending_get_agency`** — fetch agency overview; accepts both `toptier_code` and `agency_slug` to avoid intermediate lookups
18
+ - **`usaspending_spending_by_geography`** — aggregate spending by state, county, or congressional district with per-capita output
19
+ - **`usaspending_spending_by_category`** — aggregate spending by NAICS, PSC, agency, CFDA, or recipient using a `category` enum (consolidates 14 sub-routes)
20
+ - **`usaspending_spending_over_time`** — aggregate spending by fiscal year, quarter, or month
21
+ - **`usaspending_disaster_spending`** — disaster and emergency supplemental spending via `dimension` + `spending_type` enums (consolidates 9+ endpoints)
22
+ - **`usaspending_get_federal_account`** — fetch federal account budget data: obligations, outlays, program activities, object class breakdown
23
+ - **`usaspending_list_agencies`** — list all top-tier agencies with toptier codes, slugs, and fiscal year totals
24
+ - **`usaspending_autocomplete`** — discover valid NAICS, PSC, CFDA, agency, and recipient codes by description
25
+ - **`USASpendingService`** — single HTTP client wrapping `api.usaspending.gov/api/v2/` with retry, timeout, and parse-failure classification
26
+ - **Server config** — `USASPENDING_BASE_URL` and `USASPENDING_TIMEOUT_MS` env vars validated via Zod at startup
@@ -0,0 +1,16 @@
1
+ ---
2
+ summary: "Patch: autocomplete schema, federal account output, disaster spending flexibility, spending-over-time month normalization"
3
+ breaking: false
4
+ security: false
5
+ ---
6
+
7
+ # 0.1.1 — 2026-05-25
8
+
9
+ ## Fixed
10
+
11
+ - **`usaspending_autocomplete`** — narrowed `type` enum to valid values (`naics`, `psc`, `cfda`, `recipient`, `awarding_agency`, `funding_agency`); removed overly broad union that accepted arbitrary strings
12
+ - **`usaspending_get_federal_account`** — flattened and reduced output schema; removed deeply nested optional fields that upstream rarely populates, fixing sparse-payload failures in field tests
13
+ - **`usaspending_disaster_spending`** — relaxed `def_codes` validation to accept any string array; official DEF code list expands with new appropriations and hard-coded enums were rejecting valid newer codes
14
+ - **`usaspending_spending_over_time`** — normalized `month` / `calendar_month` fields from upstream response into a single `month` output key; previously missing under certain `group` values
15
+ - **`usaspending_search_awards`** — added `award_type_codes` passthrough to support IDV subtypes (`IDV_A`, `IDV_B`, etc.) that the previous union missed
16
+ - **`USASpendingService`** — tightened `parseJson` error classification; upstream HTML error pages now surface as `ServiceUnavailable` instead of `SerializationError`
@@ -0,0 +1,119 @@
1
+ ---
2
+ # FORMAT REFERENCE — do not edit. Copy this file to
3
+ # `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.8.x/0.8.6.md`)
4
+ # to author a new release. Set that file's H1 to `# <version> — YYYY-MM-DD`
5
+ # with a concrete date.
6
+
7
+ # Required. One-line GitHub Release-style headline. 350 character cap.
8
+ # Default short and scannable. Don't pad, don't stitch unrelated changes with
9
+ # semicolons — pick the headline. Quotes required: unquoted YAML treats `: `
10
+ # inside the value as a key separator and fails GitHub's strict parser.
11
+ summary: ""
12
+
13
+ # Set `true` when consumers must change code to upgrade: API removals,
14
+ # signature changes, config renames, behavior changes that break existing
15
+ # usage. Flagged as `Breaking` in the rollup.
16
+ breaking: false
17
+
18
+ # Set `true` if this release contains any security fix. Pairs with the
19
+ # `## Security` section below. Flagged as `Security` in the rollup so
20
+ # users can triage upgrade urgency at a glance.
21
+ security: false
22
+ ---
23
+
24
+ # <version> — YYYY-MM-DD
25
+
26
+ <!--
27
+ AUTHORING GUIDE — applies to the new per-version file you create from this
28
+ template.
29
+
30
+ Audience: someone scanning release notes to decide what affects them. Lead
31
+ each bullet with the symbol or concept name in **bold** so they can skip
32
+ what's irrelevant and zoom in on what's not.
33
+
34
+ Tone: terse, fact-dense, not verbose. Default to one sentence per bullet —
35
+ name the symbol, state what changed, stop. Use a second sentence only when
36
+ it carries weight. If a bullet feels long, it is.
37
+
38
+ Cut: mechanism walkthroughs (those belong in JSDoc, AGENTS.md, or the
39
+ relevant skill), ceremonial framings ("This release introduces…",
40
+ backwards-compat paragraphs), file-by-file test enumerations, internal
41
+ implementation notes. Prefer code/symbol names over English re-explanations.
42
+
43
+ Narrative intro: skip by default. Add one short sentence only when the
44
+ release theme genuinely needs framing the bullets can't carry.
45
+
46
+ Sections: Keep a Changelog order — Added, Changed, Deprecated, Removed,
47
+ Fixed, Security. Include only sections with entries; delete the rest
48
+ (including the commented-out scaffolding below). Don't ship empty headers.
49
+
50
+ Include: every distinct fact a reader needs to adopt or audit the release —
51
+ new exports, signatures, lint rule IDs, env vars, breaking changes, version
52
+ bumps on shipped skills. Nothing more.
53
+
54
+ Links: link issues, PRs, docs, or skills where they help a reader jump to
55
+ context. Once per item per entry — don't re-link the same issue in summary,
56
+ narrative, and bullet. Skip links for inline symbol names; code spans speak
57
+ for themselves.
58
+
59
+ Issue/PR URLs: use full URLs. GitHub's bare `#NN` auto-link only resolves
60
+ inside its own UI, not in npm reads or local editors.
61
+
62
+ [#38](https://github.com/cyanheads/mcp-ts-core/issues/38) ← issue
63
+ [#42](https://github.com/cyanheads/mcp-ts-core/pull/42) ← PR
64
+
65
+ Verify numbers exist before linking (`gh issue view NN`, `gh pr view NN`).
66
+ Never speculate on a future number — `#42` for an upcoming PR silently
67
+ resolves to whatever real item already owns 42, and timeline previews pull
68
+ in that unrelated item's metadata.
69
+
70
+ TAG ANNOTATIONS — the annotated tag body renders as the GitHub Release body
71
+ via `gh release create --notes-from-tag`. The tag is a derivative of this
72
+ changelog entry — a condensed, scannable version, not a copy. Format:
73
+
74
+ <theme — omit version number, GitHub prepends it>
75
+ ← blank line
76
+ <1-2 sentence context: what this release does>
77
+ ← blank line
78
+ Dependency bumps: ← section header
79
+ ← blank line
80
+ - `@cyanheads/mcp-ts-core` ^0.9.1 → ^0.9.6 ← bullet
81
+ ← blank line
82
+ Changed: ← only sections with entries
83
+ ← blank line
84
+ - `format()` output includes `query` in text mode
85
+ ← blank line
86
+ Added:
87
+ ← blank line
88
+ - `manifest.json` scaffolded for MCPB bundle support
89
+ - Install badges (Claude Desktop, Cursor, VS Code)
90
+ ← blank line
91
+ <N> tests pass; `bun run devcheck` clean. ← footer
92
+
93
+ Never a flat comma-separated string. Always structured markdown with
94
+ sections. The tag must scan well as a rendered GitHub Release page.
95
+ -->
96
+
97
+ ## Added
98
+
99
+ -
100
+
101
+ ## Changed
102
+
103
+ -
104
+
105
+ <!-- ## Deprecated
106
+
107
+ - -->
108
+
109
+ <!-- ## Removed
110
+
111
+ - -->
112
+
113
+ ## Fixed
114
+
115
+ -
116
+
117
+ <!-- ## Security
118
+
119
+ - -->
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @fileoverview Server-specific environment variable configuration for usaspending-mcp-server.
3
+ * @module config/server-config
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ declare const ServerConfigSchema: z.ZodObject<{
7
+ baseUrl: z.ZodDefault<z.ZodString>;
8
+ timeoutMs: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
9
+ }, z.core.$strip>;
10
+ export type ServerConfig = z.infer<typeof ServerConfigSchema>;
11
+ export declare function getServerConfig(): ServerConfig;
12
+ export {};
13
+ //# sourceMappingURL=server-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.d.ts","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAG3C,QAAA,MAAM,kBAAkB;;;iBAatB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAI9D,wBAAgB,eAAe,IAAI,YAAY,CAM9C"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @fileoverview Server-specific environment variable configuration for usaspending-mcp-server.
3
+ * @module config/server-config
4
+ */
5
+ import { z } from '@cyanheads/mcp-ts-core';
6
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
7
+ const ServerConfigSchema = z.object({
8
+ baseUrl: z
9
+ .string()
10
+ .url()
11
+ .default('https://api.usaspending.gov/api/v2/')
12
+ .describe('USAspending.gov API v2 base URL'),
13
+ timeoutMs: z.coerce
14
+ .number()
15
+ .int()
16
+ .min(1000)
17
+ .max(120_000)
18
+ .default(30_000)
19
+ .describe('HTTP request timeout in milliseconds'),
20
+ });
21
+ let _config;
22
+ export function getServerConfig() {
23
+ _config ??= parseEnvConfig(ServerConfigSchema, {
24
+ baseUrl: 'USASPENDING_BASE_URL',
25
+ timeoutMs: 'USASPENDING_TIMEOUT_MS',
26
+ });
27
+ return _config;
28
+ }
29
+ //# sourceMappingURL=server-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-config.js","sourceRoot":"","sources":["../../src/config/server-config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,OAAO,EAAE,CAAC;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,sCAAsC,CAAC;CACpD,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;KACpC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview usaspending-mcp-server MCP server entry point.
4
+ * Provides access to USAspending.gov federal award, recipient, agency, and spending data.
5
+ * @module index
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;GAIG"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview usaspending-mcp-server MCP server entry point.
4
+ * Provides access to USAspending.gov federal award, recipient, agency, and spending data.
5
+ * @module index
6
+ */
7
+ import { createApp } from '@cyanheads/mcp-ts-core';
8
+ import { getServerConfig } from './config/server-config.js';
9
+ import { allToolDefinitions } from './mcp-server/tools/definitions/index.js';
10
+ import { initUSASpendingService } from './services/usaspending/usaspending-service.js';
11
+ await createApp({
12
+ tools: [...allToolDefinitions],
13
+ resources: [],
14
+ prompts: [],
15
+ instructions: 'USAspending.gov MCP server — federal award, recipient, agency, and spending data from the US Treasury DATA Act platform.\n' +
16
+ '- Start with usaspending_list_agencies or usaspending_autocomplete to discover agency codes and NAICS/PSC codes\n' +
17
+ '- Use usaspending_search_awards to find awards, then usaspending_get_award for full details\n' +
18
+ '- Chain recipient_id from usaspending_get_award into usaspending_get_recipient for entity profiles\n' +
19
+ '- Search window: 2007-10-01 onward. DoD contracts have a 90-day publication lag.',
20
+ setup(core) {
21
+ const serverConfig = getServerConfig();
22
+ initUSASpendingService(core.config, core.storage, serverConfig);
23
+ },
24
+ });
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,KAAK,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC9B,SAAS,EAAE,EAAE;IACb,OAAO,EAAE,EAAE;IACX,YAAY,EACV,4HAA4H;QAC5H,mHAAmH;QACnH,+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"}