Skip to content
◀ Blog

How to connect Claude to government data

Add an MCP server to Claude and it can search public sources like Census, BLS and FRED, run SQL on the tables and link each number to its dataset.

Riley Hilliard8 min read

datamcpagents

To connect Claude to government data, you give it a tool that can reach the data. That tool is an MCP server: a small service Claude calls when a question needs facts it doesn’t have. Without one, Claude answers questions about unemployment, rent or electricity prices from whatever it absorbed in training, which is out of date at best and invented at worst. With one, it can fetch the actual table, run the math and show you where the number came from.

There are two ways to set this up. You can wire each agency in yourself: get an API key from the Census Bureau, another from FRED, another from BLS, and install a separate MCP server for each, or download CSVs and paste them in. That works if you only ever need one source. Once your questions cross sources, you’re dealing with a separate API, identifier scheme and set of quirks per agency, and the model still has to guess which dataset answers your question. The other way is one server that already holds many sources in a common shape. We build one, OpenData, and the second half of this post covers what it does differently.

How do you connect Claude to public data?

You add the server’s URL to your Claude client and sign in when it asks. The steps below use OpenData’s URL, https://mcp.tryopendata.ai/mcp; any remote MCP server follows the same flow with its own URL.

Claude on the web and in the desktop app

  1. Open Customize > Connectors in Claude.
  2. Click Add custom connector.
  3. Paste the server URL and click Add.

The first time Claude uses it, a browser window opens so you can sign in to the service. Once it’s added, you can switch it on or off for a single chat from the + button under Connectors. On the Free plan you can add one custom connector. On Team and Enterprise plans an Owner adds it under Organization settings > Connectors, and each member then clicks Connect on it. Anthropic’s page on adding a connector that isn’t in the directory has the full details, including the security notes.

Claude Code

Claude Code adds remote servers from the command line. Use --scope user if you want it in every project rather than only the current one:

$ claude mcp add --transport http --scope user opendata https://mcp.tryopendata.ai/mcp

Then run /mcp inside Claude Code and follow the browser sign-in. The Claude Code MCP docs cover scopes and the other flags.

What is an MCP server for data?

An MCP server for data is a program that exposes a set of tools (search, query, chart) over the Model Context Protocol, so any client that speaks MCP can call them. Claude decides when to call a tool based on your question and the tool’s description, reads the result and writes its answer from that.

The single-source servers you’ll find usually wrap one agency’s API. A FRED server takes a series ID and returns observations. A Census server takes a dataset, variable codes and a geography. These are thin layers over the agency’s own interface, which means you inherit that interface’s rules:

Source What you need first What the model has to know
Census An API key from the Census Bureau Variable codes like P1_001N and geography clauses like for=state:*
FRED An API key from the St. Louis Fed Series IDs like UNRATE
BLS A registration key for version 2 of the BLS API Series IDs like CUUR0000SA0 for the consumer price index

Each server is configured separately, with its key in an environment variable. When a question needs two of them, say wages against rent by state, the model calls both, gets two differently shaped responses and joins them itself in the conversation. Nothing checks that the state codes or date ranges line up, so that join is where mistakes happen.

Which government data sources can you query?

With single-source servers, you can query whatever you’ve installed. With OpenData, the catalog covers more than 200 sources, including BLS, Census, FRED, FEC, the World Bank and the EPA. It turns CSV, Excel, PDF and API responses into tables, so a dataset published as a spreadsheet on an agency website is queried the same way as one that came from an API.

Every dataset is addressed as provider/dataset, and they all answer the same DuckDB SQL, so a question that spans sources becomes one query instead of two API calls and a hand-merged result. OpenData’s query_sql tool accepts up to five datasets in one query, joined on whatever key they share: state FIPS codes, country codes or dates.

When the catalog doesn’t have what you asked about, the model is told to say so, and it can file the gap with the request_dataset tool.

How does the model find the right dataset?

Single-source servers skip the search step. A FRED server can fetch any series, but only if the model already knows the series ID. Ask it about “rent in Austin” and it has to recall an identifier from memory.

OpenData’s flow starts with search instead. The model calls search_datasets with plain-language queries, and the top results come back with their column names, types, descriptions and the allowed values of low-cardinality columns. That’s enough for the model to write a correct query without a separate schema lookup.

Multi-part questions go in as several queries in one call, and the response suggests joins between the datasets it found. Before a cross-dataset join, find_related_datasets returns a ready-to-run JOIN statement with the exact key columns. If a query still names a column that doesn’t exist, the error that comes back lists the real columns, so the model can fix it on the next try.

Here is a session from our home page, run against OpenData on November 4, 2026. The question was “Are AI data centers driving up electricity bills?” Claude searched for three things at once: residential electricity prices by state, data center locations and PJM capacity auction prices. Those matched eia/retail-electricity-prices, im3/data-center-atlas and pjm/capacity-market-clearing-prices.

Claude then ran one SQL query comparing each state’s home electricity price over the latest 12 months with its 2022 average. The District of Columbia came out on top, from 14.27 to 24.3 cents per kilowatt-hour, up 70.3%, with EIA data through August 2026. Virginia, which has the most mapped data center floor space, was up 24.2%. That gap led to the follow-up question about what changed in PJM, the grid operator for D.C. and several of the states near the top of the list.

OpenData / Claude
LOCALREADY

You: Are AI data centers driving up electricity bills?

Bills rose fastest on the PJM gridHome electricity price change, last 12 months vs. 2022 average, through August 2026
050Change since 2022 (%)Other 43 statesWest VirginiaVirginiaDelawarePennsylvaniaOhioNew JerseyMarylandD.C.U.S. 20.3%17.017.024.230.130.232.340.955.270.3
050Change since 2022 (%)Other 43 statesWest VirginiaVirginiaDelawarePennsylvaniaOhioNew JerseyMarylandD.C.U.S.20.3%17.017.024.230.130.232.340.955.270.3

Source: eia/retail-electricity-prices (opens in a new tab)

Claude: Mostly where the grid is, not where the buildings are. Home electricity in the seven states and D.C. at the core of PJM, the grid that runs from New Jersey to Ohio, rose 38% on average since 2022. The other 43 states rose 17%. 6 of the 8 biggest increases are in PJM, led by D.C. at 70% and Maryland at 55%.

You: Virginia has the most data centers. Why isn't it at the top?

Claude: Because the buildings don't set the price. Virginia has 41.8 million square feet of mapped data-center space, the most of any state, and its prices rose 24%. Maryland has 0.5 million, ranks 31st, and rose 55%. Across states, floor space explains about 1% of the difference in price increases. Being on the PJM grid explains far more.

You: So what changed in PJM?

PJM's capacity price jumped ninefoldSystem-wide auction price by delivery year, $ per MW-day
2019/202020/212021/222022/232023/242024/252025/262026/272027/28Delivery year0100200300$ per MW-day10077140503429270329333
2019/202020/212021/222022/232023/242024/252025/262026/272027/28Delivery year0100200300$ per MW-day100333

Source: pjm/capacity-market-clearing-prices (opens in a new tab)

Claude: Its capacity auction. That's what the grid pays power plants to be available on the hottest and coldest days. It cleared at $28.92 per megawatt-day for 2024/25, then $269.92 for 2025/26, and the next two auctions went higher, to $333.44. PJM's market monitor found that data-center load made the 2026/27 auction 82% more expensive, $7.3 billion, and PJM spreads that cost across every state it serves. So data-center growth anywhere on the grid lands on bills in D.C. and Maryland.

You: Can you explain that in plain English, with a picture?

About $45 of every $100 in standby costs comes from data-center demandPJM's 2026/27 standby (capacity) cost, split across every bill on the grid
Added by data-center demandWhat the grid would cost without it
Added by data-center demandWhat the grid would cost without it

Source: pjm/capacity-market-clearing-prices (opens in a new tab), PJM market monitor, Oct 2025 (opens in a new tab)

Claude: Think of PJM as one shared electric bill. Thirteen states and D.C. buy their power through it together. Each year it pays power plants to stand by for the hottest and coldest days, like an insurance premium, and everyone on the grid splits that premium. Data centers need a lot of standby power, so the premium went up, and it went up for everyone, including households in Maryland, which has almost no data centers. Of every $100 in standby costs on 2026/27 bills, about $45 is there because of data-center demand.

Example Claude session with OpenData.

Fig. 1 A scripted Claude session using OpenData, with the figures from real queries. Source: EIA retail electricity prices, IM3 Data Center Atlas and PJM capacity auction results via OpenData, queried November 4, 2026; PJM's independent market monitor, October 2025

The last step is openchart, which takes the same SQL and draws the chart from it, so the model never copies rows by hand into the chart. Why a validated spec works better than generated plotting code is covered in how to generate charts with an LLM.

How do you check a number Claude gives you?

You check it against the query and the dataset it came from. Ask Claude to show the SQL it ran; a correct answer should come with a query you can read.

OpenData puts that trail in the result. Each query_sql call carries a one-sentence description of what it looks for, shown above the results in clients that render OpenData’s interface, and the result includes a link that opens the same query in OpenData’s browser sandbox. Dataset details include the source’s landing page, so you can go from a number to the table to the agency that published it. Charts have a source line for the attribution.

A few habits catch most errors, whatever server you use:

  • Check the definition. “Electricity price” could be residential or all sectors, monthly or annual. Ask which one the query used.
  • Check the date range. Agencies revise and publish on a lag, so “latest” means the latest month in the table, which may be several months back.
  • Rerun the query yourself when the number matters. If it came from SQL, you can paste the SQL into the sandbox and see the same rows.

What about ChatGPT and other clients?

MCP is an open protocol, so the same server URL works in other clients that support remote MCP servers over HTTP. OpenData’s server uses Streamable HTTP and standard OAuth sign-in, and its sign-in is set up for Claude, ChatGPT and Cursor.

ChatGPT adds custom MCP servers through its connector settings, which aren’t available on every plan. Check OpenAI’s help center for where the option sits on your account. In Cursor, add the URL to your mcp.json:

{
  "mcpServers": {
    "opendata": {
      "url": "https://mcp.tryopendata.ai/mcp"
    }
  }
}

Clients that support MCP Apps, which include Claude and ChatGPT, show OpenData’s results as interactive tables and charts inside the conversation. Clients that don’t get the same numbers and source links as text: a summary, a table of rows and the next query to run.

OpenData is where to start if you want to try it.