US Gov Open Data MCP

US Gov Open Data MCP

Published:
9 min read
Last Updated:
  • mcp
  • ai
  • api
  • government
  • open source

US Government Open Data MCP

I was listening to things like the State of the Union and hearing numbers thrown around from news articles, from the left, from the right, from everyone. I kept wanting to actually verify what was being said or at least get more context around it. The problem was that the data is spread across dozens of different government agencies with different APIs, different authentication methods, and different formats.

If you've ever tried to look something up on a government site, you probably know the experience. The information is there but actually getting to it is a whole other story. I found myself constantly jumping between sites trying to piece things together and thought

There has to be a better way to do this.

So, I built an MCP server that connects to 37 different U.S. government and international data APIs. It currently has 198 tools covering things like economic data, health statistics, campaign finance, lobbying records, patents, energy, education, and a lot more. The whole idea is that this information should be transparent and easily accessible for people.

The whole thing is built with FastMCP, has disk caching so you're not hammering the APIs with duplicate requests, rate limiting to stay within the various API limits, and automatic retries with backoff for when things fail.

What is MCP?

For those who don't know, MCP (Model Context Protocol) is basically a standard that lets AI assistants call external tools. So instead of the AI just guessing at an answer about the national debt or unemployment rate, it can actually go query the real data from the source and give you an accurate response with actual numbers.

Why I built it

As I mentioned, this information is public and paid for by taxpayers. I figured if I could make it easier for myself to look things up and cross reference what I was hearing then maybe it could help others do the same.

Manually going to each agency's site was tedious and the APIs all have their own quirks. Some use REST, some use GraphQL-style queries, some have weird pagination, and nearly all of them have different error handling. Wrapping all of them in a consistent interface seemed like the right move.

What started as "let me just wrap the Treasury API real quick" turned into 37 APIs and 198 tools. I kept finding more sources and thinking "oh that would be useful too" and here we are. AI was a huge help throughout the process for dealing with the sheer number of different API formats and documentation styles. As with my other projects I see it as a tool, not a replacement, and there was plenty of manual work figuring out how each API actually behaves versus what their docs say it does.

Example Analyses

To show what this thing can actually do I put together a few example analyses. These were generated entirely from live government API data with no manual data entry.

AnalysisWhat it shows
Worst-Case ImpactPAC money → committee vote → law signed → measurable public cost (one case per party)
Best-Case ImpactSenators defying industry pressure to pass legislation with positive outcomes
Presidential Economic ScorecardClinton through Trump II, identical metrics, side-by-side, with context
Deficit Reduction ComparisonBest Democratic plan vs. best Republican plan, graded on realism

Data Sources

Here is everything it currently covers. Some of these have multiple tools under them so the actual number of things you can query is quite a bit higher than this list makes it seem.

APIWhat it coversAuth
Treasury Fiscal Data53 datasets, 181 endpoints: national debt, revenue, spending, interest rates, exchange rates, gold reservesNone
FRED800K+ economic time series: GDP, CPI, unemployment, interest rates, money supply, housing, S&P 500FRED_API_KEY
BLSEmployment by industry, wages, CPI by component, PPI, JOLTS, labor productivityBLS_API_KEY (optional)
BEAState GDP, GDP by industry, personal income by state, national accounts (NIPA)BEA_API_KEY
EIAPetroleum, electricity, natural gas prices; state energy profilesEIA_API_KEY
Census BureauPopulation, demographics, income, housing from ACS and Decennial CensusCENSUS_API_KEY
OpenFECCampaign finance: candidates, committees, contributions, expendituresDATA_GOV_API_KEY
Congress.govBills, members, laws, amendments, House & Senate roll call votes (1990+)DATA_GOV_API_KEY
Federal RegisterExecutive orders, presidential documents, rules, agency notices, document detail, 470+ agency directoryNone
USAspendingFederal contracts, grants, loans, $6T+ annually by agency, recipient, stateNone
SEC EDGARCompany filings, XBRL financials, full-text searchSEC_CONTACT_EMAIL
FBI Crime DataCrime statistics by state, national estimates, arrestsDATA_GOV_API_KEY
GovInfoFull text of bills, laws, CBO reports, Federal RegisterDATA_GOV_API_KEY
NOAA ClimateWeather observations, temperature, precipitation from U.S. stationsNOAA_API_KEY
USDA NASSCrop production, livestock, farm prices, Census of AgricultureUSDA_NASS_API_KEY
World BankInternational indicators: GDP, population, health spending for 200+ countriesNone
CDC Health DataLeading causes of death, life expectancy, mortality rates, county/city health indicators (PLACES), drug overdose, obesity, disability, birth indicators, weekly death surveillance, COVID-19None
NAEP (Nation's Report Card)Reading, math, science test scores by state, grade, race, gender, povertyNone
College ScorecardCollege costs, graduation rates, post-graduation earnings, student debt, admission rates for every U.S. collegeDATA_GOV_API_KEY
NREL (Clean Energy)EV charging stations, alt fuel infrastructure, electricity rates, solar resource dataDATA_GOV_API_KEY
FDA (OpenFDA)Drug adverse events (20M+ reports), drug recalls, FDA-approved drugs (Drugs@FDA), drug labels, food recalls, food adverse events (CAERS), medical device events, device recallsNone
EPAAir quality data, facility compliance/violations, UV index forecastsNone
Senate Lobbying DisclosuresLobbying filings, expenditures by issue, campaign contributions, individual lobbyist searchNone
Regulations.govFederal rulemaking: proposed rules, final rules, public comments, regulatory docketsDATA_GOV_API_KEY
USDA FoodData CentralNutritional data for 300K+ foods: calories, macros, vitamins, minerals for branded and reference foodsDATA_GOV_API_KEY
FEMADisaster declarations, housing assistance, public assistance, NFIP flood claims, hazard mitigationNone
NHTSAVehicle safety recalls, consumer complaints, NCAP 5-star safety ratings, VIN decoding, make/model lookupNone
CMS Provider DataHospital quality ratings, nursing home inspections, home health, hospice, dialysis facility dataNone
HUDFair Market Rents by bedroom count, income limits by household size, county/metro area housing dataHUD_USER_TOKEN
USPTO PatentsViewU.S. patent search by keyword, assignee, inventor, CPC class; inventor and assignee lookupNone
CFPBConsumer complaint database: 13M+ complaints against financial companies, searchable by company/product/state/issue with trend analysisNone
FDICBank data: 5,000+ insured institutions, failures since 1934, quarterly financials, branch deposits, merger historyNone
DOLOSHA inspections/violations/accidents, WHD wage theft enforcement, weekly unemployment insurance claims (national + state)DOL_API_KEY
Open PaymentsCMS Sunshine Act data: 15M+ payments/year from pharma/device companies to doctors. Search by company, doctor, state, specialtyNone
USGSEarthquake events (magnitude, location, depth, tsunami risk), water resources monitoring (real-time and daily historical streamflow, water levels) from 13,000+ stationsNone
ClinicalTrials.gov400K+ clinical trials: search by condition, drug, sponsor, phase, status, location. Track pharma drug pipelinesNone
BTSBureau of Transportation Statistics: monthly transport stats (airline traffic, transit, rail, safety, fuel), border crossings at U.S. ports of entryNone

19 of these APIs require no key at all. The rest need free keys that most take under a minute to get.

How to use it

The quickest way to get started is just running it with npx.

npx us-gov-open-data-mcp

If you're using VS Code with Copilot you can add it to your settings like this:

{
  "servers": {
    "us-gov-open-data": {
      "command": "npx",
      "args": ["-y", "us-gov-open-data-mcp"],
      "env": {
        "FRED_API_KEY": "your_key",
        "DATA_GOV_API_KEY": "your_key"
        // ... other api keys
      }
    }
  }
}

For Claude Desktop you can add it to your claude_desktop_config.json:

{
  "mcpServers": {
    "us-gov-open-data": {
      "command": "npx",
      "args": ["-y", "us-gov-open-data-mcp"],
      "env": {
        "FRED_API_KEY": "your_key"
      }
    }
  }
}

It also supports HTTP streaming if you want to use it with web apps or remote access:

node dist/server.js --transport httpStream --port 8080

Selective Module Loading

You don't have to load all 37 APIs if you don't need them. You can pick and choose which modules you want for faster startup and a smaller tool list.

# Via CLI flag
node dist/server.js --modules fred,treasury,congress

# Via environment variable
MODULES=fred,bls,treasury node dist/server.js

The SDK

One thing I wanted to make sure of is that you don't have to use MCP to get value out of this. I built a standalone TypeScript SDK that you can import directly into your own projects.

// Individual module imports
import { getObservations } from "us-gov-open-data-mcp/sdk/fred";
import { getIndicator } from "us-gov-open-data-mcp/sdk/world-bank";
import { getLeadingCausesOfDeath } from "us-gov-open-data-mcp/sdk/cdc";
import { searchBills } from "us-gov-open-data-mcp/sdk/congress";

// Or barrel import everything
import * as sdk from "us-gov-open-data-mcp/sdk";
// FRED
const gdp = await getObservations("GDP", { sort: "desc", limit: 5 });
console.log(gdp.observations);

// World Bank - compare U.S. to Germany
const health = await getIndicator("SH.XPD.CHEX.PC.CD", {
  country: "US;DE",
  dateRange: "2015:2023"
});

// CDC
const deaths = await getLeadingCausesOfDeath({
  state: "California",
  year: 2017
});

All SDK functions include disk-backed caching, retry with exponential backoff, and rate limiting. This way if you're building your own app or tool and just want easy access to these APIs you can use the SDK without setting up a server or anything.

API Keys

Here is a quick reference for where to get each key. Again, 19 of the APIs don't need a key at all.

KeyWhere to get itUsed by
DATA_GOV_API_KEYapi.data.gov/signupCongress, FEC, FBI, GovInfo, College Scorecard, NREL, Regulations.gov, USDA FoodData
FRED_API_KEYfredaccount.stlouisfed.org/apikeysFRED
CENSUS_API_KEYapi.census.gov/data/key_signup.htmlCensus
BLS_API_KEYbls.gov/developersBLS (optional, works without, higher limits with)
BEA_API_KEYapps.bea.gov/API/signupBEA
EIA_API_KEYeia.gov/opendata/register.phpEIA
NOAA_API_KEYncei.noaa.gov/cdo-web/tokenNOAA
USDA_NASS_API_KEYquickstats.nass.usda.gov/apiUSDA NASS
HUD_USER_TOKENhuduser.gov/hudapi/public/registerHUD
SEC_CONTACT_EMAILAny valid emailSEC EDGAR
DOL_API_KEYdata.dol.gov/registrationDOL (OSHA, WHD, UI Claims)

Links

If you end up using it I would love to hear about it. Feel free to open an issue on GitHub if you run into anything or have suggestions. I am still actively working on it and hope to add more data sources over time. If you know of any free or publicly available government APIs that aren't covered yet please let me know. The more sources that are available the more robust the cross referencing can be and the easier it is to get a fuller picture of what is actually going on.

I would encourage anyone interested to give it a try, even if you just want to ask your AI assistant a question about the national debt or what your state spends on healthcare. The data is there and it should be easy to get to.

More posts you might enjoy based on what you're reading.