Skip to main content
Glama
cliwant

mcp-sam-gov

by cliwant

usas_search_agency_spending

Find which federal agencies spend the most on specific NAICS codes, filtered by fiscal year and set-aside category, to identify top buyers by dollar amount.

Instructions

Spending broken down by awarding agency. Use for 'which agencies spend the most on NAICS 541512' — top buyers by $.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
naicsNo
fiscalYearNo
setAsideNo
limitNo

Implementation Reference

  • src/server.ts:399-404 (registration)
    Tool registration in the TOOLS array — defines the tool name, description, and input schema binding.
    {
      name: "usas_search_agency_spending",
      description:
        "Spending broken down by awarding agency. Use for 'which agencies spend the most on NAICS 541512' — top buyers by $.",
      inputSchema: UsasAgencySpendingInput,
    },
  • Input schema (Zod) for usas_search_agency_spending — accepts optional naics, fiscalYear, setAside, limit.
    const UsasAgencySpendingInput = z.object({
      naics: z.string().optional(),
      fiscalYear: z.number().int().min(2007).optional(),
      setAside: z
        .enum(["SBA", "8A", "HZS", "SDVOSBC", "WOSB", "EDWOSB", "VSA", "VSS"])
        .optional(),
      limit: z.number().min(1).max(50).optional(),
    });
  • Handler function — POSTs to USAspending API v2 search/spending_by_category/awarding_agency, returns agencies sorted by total $.
    export async function searchAgencySpending(args: {
      naics?: string;
      fiscalYear?: number;
      setAside?: string;
      limit?: number;
    }) {
      const filters = buildFilters(args);
      type Resp = {
        results?: {
          name?: string;
          code?: string;
          amount?: number;
          agency_slug?: string;
        }[];
      };
      const json = await postUsas<Resp>(
        "search/spending_by_category/awarding_agency",
        { filters, limit: args.limit ?? 10, page: 1 },
      );
      return {
        agencies: (json.results ?? []).map((r) => ({
          name: r.name ?? "",
          code: r.code ?? "",
          slug: r.agency_slug ?? "",
          amount: r.amount ?? 0,
        })),
      };
    }
  • Helper that builds the common USAspending filter object used by searchAgencySpending (and other tools) — handles agency, naics, fiscalYear, 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;
    }
  • Generic HTTP POST helper for USAspending API calls with 15s timeout — used by searchAgencySpending to call the awarding_agency endpoint.
    async function postUsas<T>(
      endpoint: string,
      body: Record<string, unknown>,
    ): Promise<T> {
      const r = await fetch(`${USAS}/${endpoint}`, {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(body),
        signal: AbortSignal.timeout(15_000),
      });
      if (!r.ok) {
        throw new Error(`USAspending POST ${endpoint} returned ${r.status}`);
      }
      return (await r.json()) as T;
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It does not mention permissions, rate limits, pagination, data freshness, or any side effects, leaving significant gaps for an agent.

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

Conciseness4/5

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

The description is two sentences, front-loading the purpose and providing a concrete example. It is efficient with no wasted words.

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

Completeness2/5

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

Given the tool has 4 parameters and no output schema, the description is insufficient. It does not cover parameter context, return format, or limitations, leaving agents underinformed.

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

Parameters2/5

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

Schema description coverage is 0%, yet the description only mentions NAICS in the example and provides no explanation for fiscalYear, setAside, or limit. The description adds minimal value beyond the parameter names.

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

Purpose5/5

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

The description clearly states it breaks down spending by awarding agency and provides a concrete example ('which agencies spend the most on NAICS 541512'), making the tool's purpose immediately understandable and distinct from sibling tools.

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 explicitly tells when to use this tool: for finding top agency spenders on a NAICS code. Although it doesn't mention when not to use it, the example effectively conveys the primary use case.

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