How to Add US Census Data to Claude Code
Claude Code is great at writing code, but when your work involves real demographic data — population counts, income distributions, housing stats — it can only guess from training data. Adding the Census Data tool through AgentPatch gives it direct access to the US Census Bureau’s American Community Survey.
Why This Matters
A surprising amount of development work touches demographic data. You might be building a dashboard that shows population by county, seeding a database with realistic income figures, or writing data models for a civic tech project. In all these cases, you need actual numbers — not approximations from a language model’s memory.
With Census Data available as a tool, Claude Code can fetch real ACS data mid-session. It pulls human-readable variable names like median_household_income or total_population instead of raw Census Bureau codes, so you can work with the output immediately. It supports queries at the national, state, county, zip code, and place level, and you can use plain state names like “Texas” instead of FIPS codes.
Setup
Install the AgentPatch CLI (zero dependencies, Python 3.10+):
pip install agentpatch
Set your API key:
export AGENTPATCH_API_KEY=your_api_key
Then use it:
ap search "web search"
ap run agentpatch google-search --input '{"query": "test"}'
Get your API key from the AgentPatch dashboard.
Run this command to add AgentPatch as an MCP server:
claude mcp add -s user --transport http agentpatch https://agentpatch.ai/mcp \
--header "Authorization: Bearer YOUR_API_KEY"
Replace YOUR_API_KEY with your actual key from the AgentPatch dashboard. Claude Code discovers all AgentPatch tools automatically.
Example
You’re building a data pipeline that normalizes county-level economic indicators. You need some real data to develop against:
“Pull median household income, per capita income, and poverty rate for all counties in California. I need it to design the data model.”
Claude Code calls the Census Data tool:
Fetching Census ACS data for California counties...
Variables: median_household_income, per_capita_income, poverty_rate
Geography: county level, state: California
Year: 2023, Dataset: acs5
Got 58 counties. Sample:
Los Angeles County: $73,532 median income, $37,924 per capita, 13.8% poverty
San Francisco County: $126,187 median income, $78,043 per capita, 9.7% poverty
Imperial County: $47,138 median income, $18,611 per capita, 22.4% poverty
Based on the actual value ranges, here's the schema:
interface CountyEconomicProfile {
countyName: string;
stateFips: string;
countyFips: string;
medianHouseholdIncome: number;
perCapitaIncome: number;
povertyRate: number;
year: number;
}
Writing this to types/economic.ts and seeding test fixtures with the real data.
Claude Code fetched real county-level economic data, inspected the value ranges, and designed a type that fits the actual data. That’s a stronger starting point than guessing at field types and ranges.
Wrapping Up
Adding AgentPatch to Claude Code gives it access to US Census Bureau data during any session. Population, income, education, housing, and demographic breakdowns — all available through one tool at 75 credits per call. The same connection also unlocks every other tool on the marketplace. Check out agentpatch.ai to see what’s available.