usaspending-mcp
Production-grade MCP server for US federal spending data via api.usaspending.gov.
Features
- 8 decision-tree tools covering the full USASpending API (awards, agencies, recipients, spending, disaster funding, accounts, downloads)
- Dual transport: STDIO (Claude Desktop/Code) and Streamable HTTP + SSE (hosted deployments)
- Progress notifications for long-running paginated searches and bulk downloads
- 4 MCP resources: agencies list, current fiscal year, data freshness, glossary
- Lazy-loaded reference data with TTL cache (no blocking startup calls)
- No authentication required — USASpending API is public
Installation
# From PyPI (when published)
pip install usaspending-mcp
# From GitHub
pip install git+https://github.com/asachs01/usaspending-mcp.git
# For development
git clone https://github.com/asachs01/usaspending-mcp.git
cd usaspending-mcp
pip install -e ".[dev]"
Quick Start
# STDIO mode (default — for Claude Desktop / Claude Code)
usaspending-mcp
# HTTP mode (for hosted/remote deployments)
usaspending-mcp-http
# With custom port
usaspending-mcp-http --port 9000
# Auto-detect transport
python -m usaspending_mcp.server --transport http
Configuration
Claude Desktop
{
"mcpServers": {
"usaspending": {
"command": "uvx",
"args": ["usaspending-mcp"]
}
}
}
Claude Code
{
"mcpServers": {
"usaspending": {
"command": "uvx",
"args": ["usaspending-mcp"]
}
}
}
Remote HTTP (e.g., gateway deployment)
# Start the HTTP server
USASPENDING_MCP_PORT=8765 usaspending-mcp-http
# Connect via mcp-remote in Claude Desktop
{
"mcpServers": {
"usaspending": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://your-server:8765/mcp"]
}
}
}
Environment Variables
| Variable | Default | Description |
|---|---|---|
USASPENDING_MCP_TRANSPORT |
(auto) | Force transport: stdio or http |
USASPENDING_MCP_HOST |
0.0.0.0 |
HTTP bind host |
USASPENDING_MCP_PORT |
8765 |
HTTP bind port |
Tools
| Tool | Description |
|---|---|
search_awards |
Search federal awards by keyword, agency, type, NAICS, PSC, recipient, amount |
get_award |
Get award detail, funding, subawards, transactions by award ID |
query_agency |
Agency overview + 7 breakdown types (budgets, sub-agencies, accounts, etc.) |
query_recipient |
Recipient autocomplete search and full profile detail |
query_spending |
Spending explorer by agency, budget function, object class, program activity |
query_disaster |
Disaster/emergency funding by DEFC code with 6 breakdown categories |
query_accounts |
Federal account detail, treasury account breakdown, account listing |
manage_download |
Initiate and poll bulk CSV download jobs |
Resources
| URI | Description |
|---|---|
usaspending://agencies |
Full list of toptier federal agencies |
usaspending://fiscal-year/current |
Current US federal fiscal year |
usaspending://data-freshness |
Last updated timestamp from the API |
usaspending://glossary |
Federal spending glossary terms |
Deployment
Docker
docker build -t usaspending-mcp .
docker run -p 8765:8765 usaspending-mcp
DigitalOcean App Platform
The .do/app.yaml spec deploys the server as a container. Use the DO CLI or dashboard:
doctl apps create --spec .do/app.yaml
The server listens on port 8765 (/mcp). Connect Claude Desktop/Code via mcp-remote:
{
"mcpServers": {
"usaspending": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://your-app.ondigitalocean.app/mcp"]
}
}
}
Cloudflare Workers (edge proxy)
CF Workers can't host a persistent Python server, but workers/proxy.js puts CF's edge network in front of your DO deployment:
# Point the worker at your DO app URL
wrangler secret put BACKEND_URL
# → https://usaspending-mcp-api-xxxxx.ondigitalocean.app
# Deploy
wrangler deploy
Then update your mcp-remote URL to the CF Worker endpoint.
Development
# Install with dev dependencies (requires uv)
uv sync --group dev
# Run tests
uv run pytest tests/ -v
# Run a specific test file
uv run pytest tests/test_tools_awards.py -v
Architecture
usaspending_mcp/
__init__.py # MCPB extension manifest
server.py # Entry point, transport detection, FastMCP setup
client/
api.py # Async httpx wrapper for all API domains
cache.py # In-memory lazy cache with per-key TTL
tools/
registry.py # Imports all tool modules for registration
awards.py # search_awards, get_award
agency.py # query_agency (8 sub-routes)
recipients.py # query_recipient
spending.py # query_spending
disaster.py # query_disaster
accounts.py # query_accounts
downloads.py # manage_download
decision_tree/
router.py # Parameter inspection and missing-param detection
elicitor.py # JSON Schema builder for elicitation
resources/
registry.py # MCP resource definitions
transport/
http.py # HTTP config
session.py # Per-session subscription tracking
notifications/
progress.py # Progress notification helpers
License
MIT
Metadata
Release files for usaspending-mcp 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| usaspending_mcp-0.1.1.tar.gz | 45.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| usaspending_mcp-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 71.8 kB
Release files / usaspending_mcp-0.1.1.tar.gz
| Download URL | usaspending_mcp-0.1.1.tar.gz |
|---|---|
| Size | 45.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75da954d0b62db7ae48cfbc5f892d44c4a30b9089faec523b0084a28f8b4bd44
|
|
BLAKE2b-256 checksum How to use checksums |
1f4b43ee972d0738f0d345b3a7a89c76beb6a28fb6f5898614f0aa0cbae66ac9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 2, 2026.
Transparency logRelease files / usaspending_mcp-0.1.1-py3-none-any.whl
| Download URL | usaspending_mcp-0.1.1-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ed74162bd94bb40f7b75c679fa93aa8c0492699003429d671a52712a7483334
|
|
BLAKE2b-256 checksum How to use checksums |
e90c62e5b5590f4599f725669e9b1fef4dbbc51575117093d7e3110d3c769bd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 2, 2026.
Transparency logSecurity for usaspending-mcp 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for usaspending_mcp-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.