Skip to main content
Glama

usaspending-mcp-server

Spending by Geography

usaspending_spending_by_geography
Read-onlyIdempotent

Aggregate federal spending by state, county, or congressional district. Useful for per-capita analysis, regional comparisons, and mapping federal investment patterns. Geographic filters accept FIPS codes and 2-letter state abbreviations — NOT place names. Resolve place names to FIPS codes using a geocoding server (Census or OpenStreetMap) before applying location filters. Chain per-capita results with Census population data for meaningful comparisons.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum geographic areas to return, ranked by aggregated_amount descending (1–500). The upstream endpoint is not paginated — it returns every matching area in one response — so this caps client-side. A nationwide county query matches over 3,000 areas.
scopeYesWhich location to aggregate by: place_of_performance (where work is done) or recipient_location (where the recipient is based)
filtersNoOptional filters to scope the spending aggregation
geo_layerYesGeographic granularity: state (50 states), county (county-level), or district (congressional district)
subawardsNoInclude subaward data instead of prime award data

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
capNoThe limit that was applied.
errorNoPresent when the call failed. Absent on success.
scopeNoLocation scope used for aggregation
shownNoNumber of geographic areas returned.
totalNoNumber of geographic areas returned
noticeNoHow to reach areas omitted by limit, which time-period bound was filled in when only the other was supplied, and how to broaden filters when results are empty. Absent when none applies.
resultsNoSpending totals by geographic area
geo_layerNoGeographic granularity used
truncatedNoTrue when the area list was capped at limit.
area_countNoNumber of geographic areas returned
applied_scopeNoLocation scope applied: place_of_performance or recipient_location
applied_keywordsNoKeyword filters applied (comma-separated)
applied_geo_layerNoGeographic granularity applied: state, county, or district
truncationCeilingNoObligation amount of the lowest-ranked area shown — an upper bound on omitted ones.
applied_agency_nameNoAwarding agency name filter applied
applied_naics_codesNoNAICS code filters applied (comma-separated)
total_areas_availableNoNumber of geographic areas the filters matched, before limit was applied
applied_time_period_endNoEnd of the time period sent (YYYY-MM-DD), including a filled-in end
applied_time_period_startNoStart of the time period sent (YYYY-MM-DD), including a filled-in start
applied_award_type_defaultNoDisclosure that no filters were supplied, so award_type_codes defaulted to the complete set. Absent when the caller supplied at least one filter.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed11 schema fields changed
    • addedInput schema / properties / filters / properties / time_period_end / anyOf
      Added value: +[
      +  {
      +    "const": "",
      +    "type": "string"
      +  },
      +  {
      +    "description": "Date as YYYY-MM-DD; month and day may be unpadded",
      +    "pattern": "^\\d{4}-\\d{1,2}-\\d{1,2}$",
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / filters / properties / time_period_end / description
      Previous value: -"End of time period in ISO 8601 format (YYYY-MM-DD)"New value: +"End of time period (YYYY-MM-DD). Given alone, the period starts at 2007-10-01, the earliest searchable date."
    • removedInput schema / properties / filters / properties / time_period_end / type
      Removed value: -"string"
    • addedInput schema / properties / filters / properties / time_period_start / anyOf
      Added value: +[
      +  {
      +    "const": "",
      +    "type": "string"
      +  },
      +  {
      +    "description": "Date as YYYY-MM-DD; month and day may be unpadded",
      +    "pattern": "^\\d{4}-\\d{1,2}-\\d{1,2}$",
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / filters / properties / time_period_start / description
      Previous value: -"Start of time period in ISO 8601 format (YYYY-MM-DD)"New value: +"Start of time period (YYYY-MM-DD), 2007-10-01 or later. Given alone, the period runs through today (UTC)."
    • removedInput schema / properties / filters / properties / time_period_start / type
      Removed value: -"string"
    • changedOutput schema / properties / applied_time_period_end / description
      Previous value: -"End date filter applied (YYYY-MM-DD)"New value: +"End of the time period sent (YYYY-MM-DD), including a filled-in end"
    • changedOutput schema / properties / applied_time_period_start / description
      Previous value: -"Start date filter applied (YYYY-MM-DD)"New value: +"Start of the time period sent (YYYY-MM-DD), including a filled-in start"
    • changedOutput schema / properties / error / properties / data / properties / reason / description
      Previous value: -"Machine-readable failure mode. Declared by this tool: `api_unavailable`: USAspending.gov API is unreachable or returns an error. `api_timeout`: USAspending.gov did not respond before the request deadline elapsed. Other values are possible when a failure originates below the handler."New value: +"Machine-readable failure mode. Declared by this tool: `api_unavailable`: USAspending.gov API is unreachable or returns an error. `api_timeout`: USAspending.gov did not respond before the request deadline elapsed. `date_range_inverted`: Both filters.time_period_start and filters.time_period_end were supplied and the start falls after the end. `date_before_earliest`: The resolved start date precedes the 2007-10-01 earliest date this endpoint can search. Other values are possible when a failure originates below the handler."
    • changedOutput schema / properties / error / properties / data / properties / reason / examples
      Previous value: -[
      -  "api_unavailable",
      -  "api_timeout"
      -]New value: +[
      +  "api_unavailable",
      +  "api_timeout",
      +  "date_range_inverted",
      +  "date_before_earliest"
      +]
    • changedOutput schema / properties / notice / description
      Previous value: -"Recovery hint when results are empty — suggests how to broaden filters. Absent when results are present."New value: +"How to reach areas omitted by limit, which time-period bound was filled in when only the other was supplied, and how to broaden filters when results are empty. Absent when none applies."
  2. Changed6 schema fields changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedInput schema / additionalProperties
      Added value: +false
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • addedOutput schema / anyOf
      Added value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "scope",
      +      "geo_layer",
      +      "results",
      +      "total",
      +      "total_areas_available",
      +      "applied_scope",
      +      "applied_geo_layer",
      +      "area_count"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • addedOutput schema / properties / error
      Added value: +{
      +  "additionalProperties": {},
      +  "description": "Present when the call failed. Absent on success.",
      +  "properties": {
      +    "code": {
      +      "description": "JSON-RPC error code for this failure.",
      +      "maximum": 9007199254740991,
      +      "minimum": -9007199254740991,
      +      "type": "integer"
      +    },
      +    "data": {
      +      "additionalProperties": {},
      +      "properties": {
      +        "reason": {
      +          "description": "Machine-readable failure mode. Declared by this tool: `api_unavailable`: USAspending.gov API is unreachable or returns an error. `api_timeout`: USAspending.gov did not respond before the request deadline elapsed. Other values are possible when a failure originates below the handler.",
      +          "examples": [
      +            "api_unavailable",
      +            "api_timeout"
      +          ],
      +          "type": "string"
      +        },
      +        "recovery": {
      +          "additionalProperties": {},
      +          "description": "Actionable next step for the caller.",
      +          "properties": {
      +            "hint": {
      +              "type": "string"
      +            }
      +          },
      +          "required": [
      +            "hint"
      +          ],
      +          "type": "object"
      +        },
      +        "retryable": {
      +          "description": "Whether retrying may succeed.",
      +          "type": "boolean"
      +        }
      +      },
      +      "type": "object"
      +    },
      +    "message": {
      +      "description": "Human-readable description of what went wrong.",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "code",
      +    "message"
      +  ],
      +  "type": "object"
      +}
    • removedOutput schema / required
      Removed value: -[
      -  "scope",
      -  "geo_layer",
      -  "results",
      -  "total",
      -  "total_areas_available",
      -  "applied_scope",
      -  "applied_geo_layer",
      -  "area_count"
      -]
  3. Changed9 schema fields changed
    • changedInput schema / properties / filters / properties / award_type_codes / description
      Previous value: -"Award type codes: A/B/C/D (contracts), 02–05 (grants), 06/10 (direct payments), 07/08 (loans)"New value: +"Award type codes: A/B/C/D (contracts), IDV_A–IDV_E (IDVs), 02–05 (grants), 06/10 (direct payments), 07/08 (loans), 09/11 (insurance and other assistance), -1 (unspecified). Groups may be mixed here. Omit to aggregate every type."
    • addedInput schema / properties / limit
      Added value: +{
      +  "default": 50,
      +  "description": "Maximum geographic areas to return, ranked by aggregated_amount descending (1–500). The upstream endpoint is not paginated — it returns every matching area in one response — so this caps client-side. A nationwide county query matches over 3,000 areas.",
      +  "maximum": 500,
      +  "minimum": 1,
      +  "type": "integer"
      +}
    • addedOutput schema / properties / applied_award_type_default
      Added value: +{
      +  "description": "Disclosure that no filters were supplied, so award_type_codes defaulted to the complete set. Absent when the caller supplied at least one filter.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / cap
      Added value: +{
      +  "description": "The limit that was applied.",
      +  "type": "number"
      +}
    • addedOutput schema / properties / shown
      Added value: +{
      +  "description": "Number of geographic areas returned.",
      +  "type": "number"
      +}
    • addedOutput schema / properties / total_areas_available
      Added value: +{
      +  "description": "Number of geographic areas the filters matched, before limit was applied",
      +  "type": "number"
      +}
    • addedOutput schema / properties / truncated
      Added value: +{
      +  "description": "True when the area list was capped at limit.",
      +  "type": "boolean"
      +}
    • addedOutput schema / properties / truncationCeiling
      Added value: +{
      +  "description": "Obligation amount of the lowest-ranked area shown — an upper bound on omitted ones.",
      +  "type": "number"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "scope",
      -  "geo_layer",
      -  "results",
      -  "total",
      -  "applied_scope",
      -  "applied_geo_layer",
      -  "area_count"
      -]New value: +[
      +  "scope",
      +  "geo_layer",
      +  "results",
      +  "total",
      +  "total_areas_available",
      +  "applied_scope",
      +  "applied_geo_layer",
      +  "area_count"
      +]
  4. Changed5 schema fields changed
    • addedOutput schema / properties / applied_agency_name
      Added value: +{
      +  "description": "Awarding agency name filter applied",
      +  "type": "string"
      +}
    • addedOutput schema / properties / applied_keywords
      Added value: +{
      +  "description": "Keyword filters applied (comma-separated)",
      +  "type": "string"
      +}
    • addedOutput schema / properties / applied_naics_codes
      Added value: +{
      +  "description": "NAICS code filters applied (comma-separated)",
      +  "type": "string"
      +}
    • addedOutput schema / properties / applied_time_period_end
      Added value: +{
      +  "description": "End date filter applied (YYYY-MM-DD)",
      +  "type": "string"
      +}
    • addedOutput schema / properties / applied_time_period_start
      Added value: +{
      +  "description": "Start date filter applied (YYYY-MM-DD)",
      +  "type": "string"
      +}
  5. Changed1 schema field changed
    • addedOutput schema / properties / notice
      Added value: +{
      +  "description": "Recovery hint when results are empty — suggests how to broaden filters. Absent when results are present.",
      +  "type": "string"
      +}
  6. Changed4 schema fields changed
    • addedOutput schema / properties / applied_geo_layer
      Added value: +{
      +  "description": "Geographic granularity applied: state, county, or district",
      +  "type": "string"
      +}
    • addedOutput schema / properties / applied_scope
      Added value: +{
      +  "description": "Location scope applied: place_of_performance or recipient_location",
      +  "type": "string"
      +}
    • addedOutput schema / properties / area_count
      Added value: +{
      +  "description": "Number of geographic areas returned",
      +  "type": "number"
      +}
    • changedOutput schema / required
      Previous value: -[
      -  "scope",
      -  "geo_layer",
      -  "results",
      -  "total"
      -]New value: +[
      +  "scope",
      +  "geo_layer",
      +  "results",
      +  "total",
      +  "applied_scope",
      +  "applied_geo_layer",
      +  "area_count"
      +]
  7. First observed

TDQS

A4.3/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, openWorldHint, and idempotentHint, so the safety profile is covered. The description adds valuable behavioral context beyond the annotations: it warns that geographic inputs must be FIPS codes or state abbreviations, not place names, and advises geocoding beforehand. This is a non-obvious input constraint that materially affects how the agent should call the tool. It does not contradict any annotation.

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 five sentences and front-loads the core purpose first. Each sentence adds distinct information: purpose, use cases, input format warning, geocoding remedy, and analytical follow-up. It is not overly long, but the geocoding instruction could be tightened to two sentences without losing content. Overall, it is structured and efficient.

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 the 5-parameter schema, nested filters object, and an output schema, the description does not need to restate return formats. It covers the essential operational guidance: granularity choices, input preparation, and analytical use. The only gap is that the 'location filters' phrase implies a parameter that is not clearly present in the schema, which could confuse an agent, but the output schema and parameter descriptions cover most invocation concerns.

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

Parameters4/5

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

Schema coverage is 100% and includes detailed descriptions for all five parameters, so the baseline is 3. The description goes further by explaining geographic input format expectations (FIPS/state abbreviations) and recommending chaining with Census population data, which are not in the schema. This adds practical meaning about how to prepare inputs and interpret results, though the exact parameter that accepts FIPS codes is not explicitly identified in the schema – a minor ambiguity.

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 starts with a specific verb-resource pair: 'Aggregate federal spending by state, county, or congressional district.' This clearly distinguishes it from sibling tools like spending_by_category or spending_over_time, which aggregate on different dimensions. The phrase 'by state, county, or congressional district' also maps directly to the geo_layer enum in the schema.

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 concrete use cases ('per-capita analysis, regional comparisons, mapping federal investment patterns') and provides a critical prerequisite: resolving place names to FIPS codes before using location filters. It does not explicitly name sibling tools to avoid, but the use-case framing plus the tool name make the intended context clear. It could be stronger with an explicit 'use this when you need geographic aggregation, not when you need...' statement.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.