Census-MCP-Server
About
# Census-MCP-Server > **Disclaimer: This is an independent project and is not officially affiliated with or endorsed by the U.S. Census Bureau. All data is sourced from publicly available Census Bureau APIs with endpoint versions pinned to current releases. No Census seals, logos, or branding are used in compliance…
Details
- Transport
- SSE
- License
- MIT license
Explore
- Smart query translation from plain English to Census API calls.
- Domain knowledge integration for appropriate data source selection.
- Statistical context including margins of error, CV calculations, and suppression handling.
- Error prevention for common mistakes like geographic mismatches.
- Caching and throttling with exponential back-off (≤10 concurrent connections, ~500 calls/day unauthenticated).
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
Census-MCP-ServerCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
🚧 Implementation in Progress
git clone https://github.com/yourusername/Census-MCP-Server.git
cd Census-MCP-Server
pip install -r requirements.txt
python mcp_server.py
census_list_datasets
Browse available Census Bureau datasets with their supported vintage years. Use as the starting point when the right dataset is unknown — ACS5, ACS1, population estimates, and decennial census serve different use cases. Pass the dataset_id value to the dataset parameter in other census tools.
census_list_geographies
List the geography levels available for a given Census dataset and year, along with the parent geographies each level requires. Use before querying to confirm that the target geography level exists — ACS1 omits many sub-state levels, and not all datasets support tracts or block groups. The geography_level values returned here are the valid inputs to the geography_level parameter in census_query_data and census_compare_geographies.
census_search_variables
Search Census variables by keyword across variable labels and concept groups. Returns variable codes with human-readable labels — use this to go from a concept like "median household income" to the variable code B19013_001E needed for data queries. Returns both estimate (E suffix) and margin-of-error (M suffix) codes so you can request both. When total_matches exceeds the limit, narrow the query to see more specific results.
census_get_variable
Fetch full metadata for one or more Census variable codes — label, concept group, predicate type, universe, and margin-of-error sibling references. Use to confirm a variable code before building a query, or to look up what a known code means. Returns estimate_code and moe_code sibling references where applicable so you can request both without a separate search.
census_resolve_geography
Resolve a place name or street address to Census FIPS identifiers (state, county, tract codes). Converts names like "King County, WA" or "Seattle, WA" to the FIPS codes required by census_query_data and census_compare_geographies. Use before querying when you have a place name rather than raw FIPS codes — state_fips maps to parent_fips and fips_summary maps to geography_fips in downstream tools.
census_query_data
Query a Census dataset for one or more variables at a specific geography. Accepts FIPS codes for the target geography — use census_resolve_geography to convert place names to FIPS when needed. Labeled estimates and margin-of-error values are returned together. Suppression codes (geography too small, data not collected) are decoded into human-readable reasons rather than passed through as raw negative numbers. Pass geography_fips as "*" to return all geographies at the level within the parent.
census_compare_geographies
Compare one or more variables across multiple geographies at the same level — all counties in a state, all states nationally, or a named set of specific geographies. Results are sorted and ranked. Covers queries like "rank states by poverty rate", "compare median income across WA counties", or "which census tracts in King County have the highest renter rate." Omit within to compare all geographies nationally at the level. Suppressed values are decoded to human-readable labels rather than pass…
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"census-mcp-server": {
"Census-MCP-Server": {
"command": "python",
"args": [
"mcp_server.py"
]
}
}
}
}
McpServers
{
"Census-MCP-Server": {
"command": "python",
"args": [
"mcp_server.py"
]
}
}
> Disclaimer: This is an independent project and is not officially affiliated with or endorsed by the U.S. Census Bureau. All data is sourced from publicly available Census Bureau APIs with endpoint versions pinned to current releases. No Census seals, logos, or branding are used in compliance with Census graphic standards. Any views expressed are those of the authors and not those of the U.S. Census Bureau.
Census in Your Pocket 📱
Work in Progress - Building an AI interface for Census data
Turn any AI assistant into your personal Census data expert. Ask questions in plain English, get accurate demographic data with proper interpretation and context.
Before: "I need ACS Table B19013 for FIPS code 24510 with margin of error calculations..."
After: "What's the median income in Baltimore compared to Maryland?"
The Problem
U.S. Census data is incredibly valuable but has a steep learning curve for non-specialists. Even experienced researchers struggle with geographic hierarchies, variable naming conventions, margin of error calculations, and knowing which data combinations actually work. In our experience, the biggest impediment to demographic analysis is often just figuring out how to get the right data in the first place.
Vision: Democratizing America's Data
Today: Census data influences billions in government spending and policy decisions, but accessing it effectively requires specialized knowledge that creates barriers for many potential users.
Tomorrow: City council members fact-check claims in real-time during meetings. Journalists get demographic context while writing stories. Nonprofits understand their communities without hiring statisticians. Researchers spend time analyzing instead of wrestling with APIs.
The Goal: Make America's most valuable public dataset as easy to use as asking a question.
How It Works
graph LR
A["User Question: Poverty rate in rural counties?"] --> B["AI Assistant (ChatGPT, Claude, Gemini, etc.)"]
B --> C["Census MCP Server (Domain Expertise Layer)"]
C --> D["Python Census Package (censusdata, etc.)"]
C --> H["Metadata Endpoints (follows collection path, e.g., /data/{year}/acs/acs5/{collection}/variables.json where {collection} = profile, detailedprofile, comparisonprofile, or subject)"]
D --> E["Census Bureau API (Official Data Source)"]
H --> E
E --> D
E --> H
D --> C
H --> C
C --> F["Interpreted Results + Context + Caveats"]
F --> B
B --> G["User gets accurate answer with proper interpretation"]
style C fill:#e1f5fe
style F fill:#f3e5f5
Note: Complex queries may require multiple API calls and batch orchestration
Analogies: What This Is Like
GPS for Data Navigation: Instead of needing to read maps and calculate routes manually, you just say where you want to go and the system handles the navigation.
Having a Census Expert in Your Pocket: Like having a demographer sitting next to you who instantly knows which data to pull, how to interpret it properly, and what caveats to mention.
What Stripe Did for Payments: Stripe made online payments simple by hiding complexity behind a clean interface. We aim to make Census data simple by hiding complexity behind natural language.
Current Scope: Starting with ACS
Phase 1 Focus: American Community Survey (ACS) 5-year estimates
- Most flexible annual demographic dataset
- Well-supported by existing Python packages
- Covers demographics, economics, housing, social characteristics
- Note: 5-year estimates include every census tract and county; 1-year estimates do not
Future Expansion: Additional surveys (SIPP, Economic Census), geographic visualizations, multi-agency integration
What We're Building
Smart Query Translation: Convert natural language questions into proper Census API calls, handling geography codes (including disambiguation of ambiguous place names like "Springfield, IL" vs FIPS codes - disambiguation based on GNIS + TIGER place class with user prompting when duplicates exist, surfacing state FIPS like "Kansas City, MO 29-38000 or Kansas City, KS 20-36000?"), variable selection (mapping B19013_001E → "Median household income"), and valid combinations.
Domain Knowledge Integration: Encode expertise about which data sources are appropriate for different questions, when estimates are reliable, and how to interpret results correctly.
Statistical Context: Automatically include margins of error with proper propagation hierarchy (ACS Generalized Variance Function for supported tables → replicate weights if available via local summary file download → conservative quadratic formula for API-only derived statistics), suppression handling (if estimate in {(X), -666666666, -333333333, } → treat as suppressed), and CV calculations with numeric guardrails and vintage lag considerations (CV computation uses latest published GVF - CVs for current vintage lag by ~1 year).
Error Prevention: Guide users away from common mistakes like inappropriate geographic comparisons or mismatched time periods.
Example Use Cases
- Basic Demographics: "Population of Miami-Dade County"
- Comparative Analysis: "Compare unemployment rates between Detroit and Pittsburgh" (derived from B23025 variables)
- Housing Statistics: "How many renter-occupied units in Phoenix?"
- Geographic Patterns: "Rural poverty rates across the Southeast"
- Time Series: "How has median income changed in Austin since 2015?"
Note: Complex definitions like "vulnerable populations" will be clearly specified using established indices (e.g., CDC Social Vulnerability Index).
Architecture
The system consists of five main layers:
1. AI Client Layer: MCP-compatible assistants
2. MCP Server (This Project): Domain expertise, query translation, result interpretation
3. Cache/Store Layer: SQLite/DuckDB for repeated query optimization
4. Census Package Layer: Python libraries like censusdata that handle API communication
5. Data Source Layer: Official U.S. Census Bureau APIs
Each layer handles its specialized function, creating a maintainable system that can evolve as both AI tools and Census data infrastructure change.
Technical Approach
Built on: Model Context Protocol (MCP) - Note: MCP is experimental and subject to breaking changes
Dependencies: Python census packages (censusdata for ACS/decennial data, custom implementations for other surveys as needed)
Python Version: 3.9-3.12 (tested range)
Rate Limiting: Implements caching and throttling strategies with exponential back-off; limits concurrent connections (≤10) and stays under ~10 req/sec (empirically ≈500/day for unauthenticated calls) with back-off on any 429/500
Data Integrity: Returns only published aggregates with proper suppression checking (if estimate in {(X), -666666666, -333333333, } → suppressed), never record-level data
Quick Start
🚧 Implementation in Progress
Prerequisites
- MCP-compatible AI client (reference implementations: lm-studio, ollama) - Python 3.9-3.12Future Installation
git clone https://github.com/yourusername/Census-MCP-Server.git
cd Census-MCP-Server
pip install -r requirements.txt
python mcp_server.py
Contributing
This project aims to democratize access to public data. We welcome contributions in:
- Domain expertise improvements (especially from Census data veterans)
- Statistical methodology implementation
- Additional data source integration
- Documentation and examples
- Testing with real-world use cases
Roadmap
- [ ] Phase 1: ACS 5-year estimates with basic query translation
- [ ] Phase 2: Statistical rigor (MOE propagation using ACS Generalized Variance Function for ratios, CV ≥ 15% flagged as unreliable, CV ≥ 30% suppressed for small-denominator rates - GVF lag means CVs for current year appear the following spring)
- [ ] Phase 3: Additional Census surveys (SIPP, Economic Census with per-sector logic and version pinning - 2017 vs 2022 vs upcoming ECB schemas, PEP - Population Estimates Program)
- [ ] Phase 4: Geographic visualization capabilities
- [ ] Phase 5: Multi-agency data integration (BLS uses CBSA codes, BEA uses BEA regions - non-trivial crosswalks required)
Acknowledgments
Built on the excellent work of:
- censusdata Python package
- tidycensus R package (inspiration)
- The dedicated teams at the U.S. Census Bureau who collect and maintain this vital public data
---
<pre>
RPC DCE RDF
↓ ↓ ↓
CORBA DCOM OWL
↓ ↓ ↓
└─→ SOAP ←┘ SPARQL
↓ ↓
REST Knowledge Graphs
↓ ↓
GraphQL ↓
↓ ↓
MCP ←─────────────→ LLMs
</pre>
"The patterns never really die, they just get better UX"
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



