Skip to main content
Glama
cliwant

mcp-sam-gov

by cliwant

usas_spending_over_time

Aggregate federal spending over time by fiscal year, quarter, or month. Filter by agency, NAICS code, or set-aside to analyze trends, such as VA 541512 spending over 5 years.

Instructions

Time-series aggregation of federal spending. Group by fiscal_year / quarter / month, filter by agency / NAICS / set-aside. Use for 'how has VA 541512 spending trended over the past 5 years' — returns yearly/quarterly/monthly $ rollups.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
groupNo
agencyNo
naicsNo
setAsideNo

Implementation Reference

  • Zod schema for usas_spending_over_time input validation: optional group (fiscal_year/quarter/month), agency, naics, setAside.
    const UsasSpendingOverTimeInput = z.object({
      group: z.enum(["fiscal_year", "quarter", "month"]).optional(),
      agency: z.string().optional(),
      naics: z.string().optional(),
      setAside: z
        .enum(["SBA", "8A", "HZS", "SDVOSBC", "WOSB", "EDWOSB", "VSA", "VSS"])
        .optional(),
    });
  • src/server.ts:368-374 (registration)
    Tool registration entry in server.ts: name 'usas_spending_over_time', description, and inputSchema reference.
    // ━━━ USAspending — Aggregate Analysis (6) ━━━
    {
      name: "usas_spending_over_time",
      description:
        "Time-series aggregation of federal spending. Group by fiscal_year / quarter / month, filter by agency / NAICS / set-aside. Use for 'how has VA 541512 spending trended over the past 5 years' — returns yearly/quarterly/monthly $ rollups.",
      inputSchema: UsasSpendingOverTimeInput,
    },
  • Handler function spendingOverTime that POSTs to USAspending search/spending_over_time/ and returns timeline data with timePeriod, total, contractObligations, grantObligations, idvObligations.
    export async function spendingOverTime(args: {
      group?: "fiscal_year" | "quarter" | "month";
      agency?: string;
      naics?: string;
      setAside?: string;
    }) {
      const filters = buildFilters(args);
      type Resp = {
        group?: string;
        results?: {
          time_period?: { fiscal_year?: string; quarter?: string; month?: string };
          aggregated_amount?: number;
          Contract_Obligations?: number;
          Grant_Obligations?: number;
          Idv_Obligations?: number;
        }[];
      };
      const json = await postUsas<Resp>("search/spending_over_time/", {
        group: args.group ?? "fiscal_year",
        filters,
      });
      return {
        group: json.group,
        timeline: (json.results ?? []).map((r) => ({
          timePeriod: r.time_period ?? {},
          total: r.aggregated_amount ?? 0,
          contractObligations: r.Contract_Obligations ?? 0,
          grantObligations: r.Grant_Obligations ?? 0,
          idvObligations: r.Idv_Obligations ?? 0,
        })),
      };
    }
  • Switch-case dispatch in server.ts that routes 'usas_spending_over_time' to usas.spendingOverTime() with parsed args.
    case "usas_spending_over_time":
      return await usas.spendingOverTime(
        UsasSpendingOverTimeInput.parse(args),
      );
  • buildFilters helper used by spendingOverTime to construct USAspending API filter objects from args (agency, naics, setAside).
    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;
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description bears full burden. It explains the tool returns aggregated dollar rollups by time period, which is a read-only operation. It does not discuss authorization, rate limits, or data freshness, but is adequate for a straightforward aggregation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: one sentence explaining the function plus a usage example. Every word contributes value, and key information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and four parameters, the description covers the core functionality: what it returns (yearly/quarterly/monthly rollups) and how to filter. It omits details like pagination or error handling, but is holistic enough for typical use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must compensate. It explains the purpose of each parameter (group for time granularity, filters for agency, NAICS, set-aside) and gives enum values implicitly. However, it does not specify data types or format constraints beyond the enum, which limits semantic richness.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool aggregates federal spending over time with grouping and filtering options, and provides a concrete example. It distinguishes from sibling tools by focusing on time-series, though not explicitly naming alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives a clear use case ('how has VA 541512 spending trended over the past 5 years'), indicating when to use this tool for trend analysis. It does not specify when not to use or list alternatives, but the context is sufficient.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cliwant/mcp-sam-gov'

If you have feedback or need assistance with the MCP directory API, please join our Discord server