usas_search_subagency_spending
Break down a parent agency's spending by sub-agency or office to identify which office holds the budget.
Instructions
Break down a parent agency's spending by sub-agency / office. Surfaces which office holds the budget (e.g. VA OI&T vs VHA, DoD vs Army vs DISA).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agency | Yes | ||
| fiscalYear | No |
Implementation Reference
- src/usaspending.ts:590-609 (handler)The main handler function for the tool. Calls the USAspending API endpoint 'search/spending_by_category/awarding_subagency' with a filter by agency (and optional fiscalYear), and returns a list of sub-agencies with name, amount, and award count.
export async function searchSubAgencySpending(args: { agency: string; fiscalYear?: number; }) { const filters = buildFilters(args); type Resp = { results?: { name?: string; amount?: number; count?: number }[]; }; const json = await postUsas<Resp>( "search/spending_by_category/awarding_subagency", { filters, limit: 10, page: 1 }, ); return { subAgencies: (json.results ?? []).map((r) => ({ name: r.name ?? "", amount: r.amount ?? 0, awards: r.count ?? 0, })), }; } - src/server.ts:87-90 (schema)Zod input schema for the tool: requires 'agency' (string) and optional 'fiscalYear' (integer >= 2007).
const UsasSubAgencyInput = z.object({ agency: z.string(), fiscalYear: z.number().int().min(2007).optional(), }); - src/server.ts:331-336 (registration)Registration of the tool in the server's tool list, linking the name 'usas_search_subagency_spending' to its description and input schema.
{ name: "usas_search_subagency_spending", description: "Break down a parent agency's spending by sub-agency / office. Surfaces which office holds the budget (e.g. VA OI&T vs VHA, DoD vs Army vs DISA).", inputSchema: UsasSubAgencyInput, }, - src/server.ts:689-690 (registration)Case branch in the server's tool dispatch that parses args with UsasSubAgencyInput and calls usas.searchSubAgencySpending().
case "usas_search_subagency_spending": return await usas.searchSubAgencySpending(UsasSubAgencyInput.parse(args)); - src/usaspending.ts:42-67 (helper)Helper function buildFilters() that constructs the USAspending API filter object (agency, fiscalYear as time_period, etc.) used by the handler.
function buildFilters(args: { agency?: string; naics?: string; fiscalYear?: number; setAside?: string; pscCodes?: string[]; }): UsasFilters { const filters: UsasFilters = { award_type_codes: ["A", "B", "C", "D"] }; if (args.agency) { filters.agencies = [ { type: "awarding", tier: "toptier", name: args.agency }, ]; } if (args.naics) filters.naics_codes = [args.naics]; if (args.fiscalYear) { filters.time_period = [ { start_date: `${args.fiscalYear - 1}-10-01`, end_date: `${args.fiscalYear}-09-30`, }, ]; } if (args.setAside) filters.set_aside_type_codes = [args.setAside]; if (args.pscCodes?.length) filters.psc_codes = args.pscCodes; return filters; }