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.
| Analysis | What it shows |
|---|---|
| Worst-Case Impact | PAC money → committee vote → law signed → measurable public cost (one case per party) |
| Best-Case Impact | Senators defying industry pressure to pass legislation with positive outcomes |
| Presidential Economic Scorecard | Clinton through Trump II, identical metrics, side-by-side, with context |
| Deficit Reduction Comparison | Best 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.
| API | What it covers | Auth |
|---|---|---|
| Treasury Fiscal Data | 53 datasets, 181 endpoints: national debt, revenue, spending, interest rates, exchange rates, gold reserves | None |
| FRED | 800K+ economic time series: GDP, CPI, unemployment, interest rates, money supply, housing, S&P 500 | FRED_API_KEY |
| BLS | Employment by industry, wages, CPI by component, PPI, JOLTS, labor productivity | BLS_API_KEY (optional) |
| BEA | State GDP, GDP by industry, personal income by state, national accounts (NIPA) | BEA_API_KEY |
| EIA | Petroleum, electricity, natural gas prices; state energy profiles | EIA_API_KEY |
| Census Bureau | Population, demographics, income, housing from ACS and Decennial Census | CENSUS_API_KEY |
| OpenFEC | Campaign finance: candidates, committees, contributions, expenditures | DATA_GOV_API_KEY |
| Congress.gov | Bills, members, laws, amendments, House & Senate roll call votes (1990+) | DATA_GOV_API_KEY |
| Federal Register | Executive orders, presidential documents, rules, agency notices, document detail, 470+ agency directory | None |
| USAspending | Federal contracts, grants, loans, $6T+ annually by agency, recipient, state | None |
| SEC EDGAR | Company filings, XBRL financials, full-text search | SEC_CONTACT_EMAIL |
| FBI Crime Data | Crime statistics by state, national estimates, arrests | DATA_GOV_API_KEY |
| GovInfo | Full text of bills, laws, CBO reports, Federal Register | DATA_GOV_API_KEY |
| NOAA Climate | Weather observations, temperature, precipitation from U.S. stations | NOAA_API_KEY |
| USDA NASS | Crop production, livestock, farm prices, Census of Agriculture | USDA_NASS_API_KEY |
| World Bank | International indicators: GDP, population, health spending for 200+ countries | None |
| CDC Health Data | Leading causes of death, life expectancy, mortality rates, county/city health indicators (PLACES), drug overdose, obesity, disability, birth indicators, weekly death surveillance, COVID-19 | None |
| NAEP (Nation's Report Card) | Reading, math, science test scores by state, grade, race, gender, poverty | None |
| College Scorecard | College costs, graduation rates, post-graduation earnings, student debt, admission rates for every U.S. college | DATA_GOV_API_KEY |
| NREL (Clean Energy) | EV charging stations, alt fuel infrastructure, electricity rates, solar resource data | DATA_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 recalls | None |
| EPA | Air quality data, facility compliance/violations, UV index forecasts | None |
| Senate Lobbying Disclosures | Lobbying filings, expenditures by issue, campaign contributions, individual lobbyist search | None |
| Regulations.gov | Federal rulemaking: proposed rules, final rules, public comments, regulatory dockets | DATA_GOV_API_KEY |
| USDA FoodData Central | Nutritional data for 300K+ foods: calories, macros, vitamins, minerals for branded and reference foods | DATA_GOV_API_KEY |
| FEMA | Disaster declarations, housing assistance, public assistance, NFIP flood claims, hazard mitigation | None |
| NHTSA | Vehicle safety recalls, consumer complaints, NCAP 5-star safety ratings, VIN decoding, make/model lookup | None |
| CMS Provider Data | Hospital quality ratings, nursing home inspections, home health, hospice, dialysis facility data | None |
| HUD | Fair Market Rents by bedroom count, income limits by household size, county/metro area housing data | HUD_USER_TOKEN |
| USPTO PatentsView | U.S. patent search by keyword, assignee, inventor, CPC class; inventor and assignee lookup | None |
| CFPB | Consumer complaint database: 13M+ complaints against financial companies, searchable by company/product/state/issue with trend analysis | None |
| FDIC | Bank data: 5,000+ insured institutions, failures since 1934, quarterly financials, branch deposits, merger history | None |
| DOL | OSHA inspections/violations/accidents, WHD wage theft enforcement, weekly unemployment insurance claims (national + state) | DOL_API_KEY |
| Open Payments | CMS Sunshine Act data: 15M+ payments/year from pharma/device companies to doctors. Search by company, doctor, state, specialty | None |
| USGS | Earthquake events (magnitude, location, depth, tsunami risk), water resources monitoring (real-time and daily historical streamflow, water levels) from 13,000+ stations | None |
| ClinicalTrials.gov | 400K+ clinical trials: search by condition, drug, sponsor, phase, status, location. Track pharma drug pipelines | None |
| BTS | Bureau of Transportation Statistics: monthly transport stats (airline traffic, transit, rail, safety, fuel), border crossings at U.S. ports of entry | None |
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-mcpIf 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 8080Selective 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.jsThe 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.
| Key | Where to get it | Used by |
|---|---|---|
DATA_GOV_API_KEY | api.data.gov/signup | Congress, FEC, FBI, GovInfo, College Scorecard, NREL, Regulations.gov, USDA FoodData |
FRED_API_KEY | fredaccount.stlouisfed.org/apikeys | FRED |
CENSUS_API_KEY | api.census.gov/data/key_signup.html | Census |
BLS_API_KEY | bls.gov/developers | BLS (optional, works without, higher limits with) |
BEA_API_KEY | apps.bea.gov/API/signup | BEA |
EIA_API_KEY | eia.gov/opendata/register.php | EIA |
NOAA_API_KEY | ncei.noaa.gov/cdo-web/token | NOAA |
USDA_NASS_API_KEY | quickstats.nass.usda.gov/api | USDA NASS |
HUD_USER_TOKEN | huduser.gov/hudapi/public/register | HUD |
SEC_CONTACT_EMAIL | Any valid email | SEC EDGAR |
DOL_API_KEY | data.dol.gov/registration | DOL (OSHA, WHD, UI Claims) |
Links
- Docs: https://lzinga.github.io/us-gov-open-data-mcp/
- NPM: us-gov-open-data-mcp
- GitHub: https://github.com/lzinga/treasury-mcp
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.