ipums-mcp
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ipums-mcpsearch for income variables in 2022 ACS"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
π IPUMS MCP
A Model Context Protocol (MCP) server that exposes the IPUMS API as tools for LLM clients. Supports IPUMS microdata collections (USA, CPS, IPUMSI, etc.) and NHGIS aggregate/GIS data. Includes tools for browsing metadata, submitting and downloading extracts, generating reproducible R/Python code, and producing formatted citations.
π Prerequisites
Node.js 18+
Any MCP-compatible client (Claude Desktop, Claude Code, Cursor, Windsurf, etc.)
Related MCP server: socrata-mcp
π οΈ Installation
1. Clone and build
git clone https://github.com/hesscl/ipums-mcp
cd ipums-mcp
npm install
npm run build2. Configure your MCP client
All MCP clients use the same server entry point β only the config file location differs. Set IPUMS_API_KEY as an environment variable; never hard-code it.
The server command is always:
node /absolute/path/to/ipums-mcp/dist/index.jsClaude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"ipums": {
"command": "node",
"args": ["/absolute/path/to/ipums-mcp/dist/index.js"],
"env": { "IPUMS_API_KEY": "your-key-here" }
}
}
}Restart Claude Desktop after saving.
Claude Code (CLI)
claude mcp add ipums node /absolute/path/to/ipums-mcp/dist/index.js \
-e IPUMS_API_KEY=your-key-hereOr add manually to .claude/settings.json:
{
"mcpServers": {
"ipums": {
"command": "node",
"args": ["/absolute/path/to/ipums-mcp/dist/index.js"],
"env": { "IPUMS_API_KEY": "your-key-here" }
}
}
}Cursor / Windsurf
Add to your editor's MCP settings (typically under Settings β MCP or a mcp.json file):
{
"mcpServers": {
"ipums": {
"command": "node",
"args": ["/absolute/path/to/ipums-mcp/dist/index.js"],
"env": { "IPUMS_API_KEY": "your-key-here" }
}
}
}Other MCP clients
Any client that supports the MCP stdio transport works. Provide:
Command:
nodeArgs:
["/absolute/path/to/ipums-mcp/dist/index.js"]Env:
IPUMS_API_KEY=your-key-here
π§ Tools
𧬠Microdata (USA, CPS, IPUMSI, ACS, NHIS, MEPS, β¦)
Tool | Description |
| Search the offline variable database by name, label, group, or sample (no API key needed) |
| List available samples for a collection (use to find sample IDs by year/survey) |
| List recent extracts for a collection |
| Get status and download links for an extract |
| Submit a new extract request |
| Poll until extract completes, with automatic bail-out for large extracts |
| Download completed extract files to disk, with SHA-256 verification |
| Generate reproducible R (ipumsr) or Python (ipumspy) code for an extract |
Variable search
microdata_search_variables queries a local database of 827 harmonized IPUMS USA variables scraped from usa.ipums.org β no API key or network request needed.
Each result includes:
nameβ variable mnemonic (e.g.INCTOT)labelβ short description (e.g."Total personal income")typeβ"H"(household-level) or"P"(person-level)groupsβ thematic category (e.g."Person: Income")samplesβ representative IPUMS USA sample IDs where the variable is available (e.g.["us2024a", "us2023a", ..., "us1850a"])
Filter by any combination of query, type, group, and sample:
microdata_search_variables({ query: "income", type: "P", sample: "us2024a" })
microdata_search_variables({ group: "Education" })
microdata_search_variables({ query: "veteran", sample: "us1990a" })The
samplesfield lists the representative display columns from usa.ipums.org β a subset of all available samples. Cross-reference withmicrodata_list_samplesfor the complete list.
Create extract
Samples and variables use array syntax:
{
"collection": "usa",
"dataFormat": "csv",
"dataStructure": { "rectangular": { "on": "P" } },
"description": "2022 ACS veterans",
"samples": [{ "id": "us2022a" }],
"variables": [
{ "name": "VETSTAT" },
{ "name": "AGE" },
{ "name": "SEX" },
{ "name": "STATEFIP" }
]
}The server converts these to the keyed-object format the IPUMS API v2 requires.
The response includes a size advisory based on samples Γ variables to help decide whether to poll immediately or check back later:
Complexity | Advisory |
β€ 200 | Small β |
β€ 2,000 | Medium β consider asking the user (3β15 min) |
> 2,000 | Large β recommend checking back with |
Wait for extract
microdata_wait_for_extract defaults to a 90-second timeout. If the extract is still processing when the timeout is reached, the tool returns early with:
{
"status": "still_processing",
"message": "Extract 42 is still queued after 90s (6 check(s)). Ask the user if they would like to wait longer, or tell them to check back later using: microdata_get_extract({ collection: \"usa\", extractNumber: 42 })",
"extract": { ... }
}This keeps the conversation responsive β the user gets the extract number and can ask to resume polling or check back manually at their convenience. Pass a higher timeoutSeconds only if the user explicitly agrees to wait.
Download a completed extract
{
"collection": "usa",
"extractNumber": 42,
"outputDir": "/data/ipums",
"fileTypes": ["data", "ddiCodebook"]
}Available fileTypes: data, ddiCodebook, basicCodebook, rCommandFile, spssCommandFile, stataCommandFile, stsCommandFile, sasCommandFile.
Note: The IPUMS API returns
stsCommandFile(notstataCommandFile) for Stata syntax files in some collections. Include both if unsure.
Returns { downloaded: [...], errors: [...] }. Each entry includes localPath, bytes, and sha256Verified.
πΊοΈ NHGIS (Aggregate & GIS Data)
Tool | Description |
| Search all datasets by keyword (name, census group, description) |
| Search data tables by keyword, optionally scoped to a dataset |
| Search all time series tables by keyword |
| Browse available datasets (paginated) |
| Get tables and geographic levels for a dataset |
| List all data tables (paginated) |
| Get variables in a data table |
| List time series tables (paginated) |
| Get detail for a time series table |
| List available shapefiles |
| List recent NHGIS extracts |
| Get NHGIS extract status and download links |
| Submit a new NHGIS extract |
| Generate reproducible R (ipumsr) or Python (ipumspy) code for an NHGIS extract |
Table search
Three tools enable natural-language discovery of NHGIS data, complementing the nhgis_list_* and nhgis_get_* tools:
nhgis_search_datasets β fetches all ~253 datasets in one call and returns those matching the keyword in their name, group (e.g. "2020 Census", "2019 ACS"), or description. Best first step when you know a topic or census year.
nhgis_search_time_series_tables β fetches all ~400 time series tables (which span multiple census years with consistent geographic definitions) and filters by keyword in name or description. Ideal for longitudinal analysis.
nhgis_search_data_tables β searches source data tables by keyword against description and universe:
With
datasetparameter: fetches all tables for that dataset comprehensively.Without
dataset: scans the first 2,500 tables across all datasets (limited coverage β see note in response).
Recommended workflow:
nhgis_search_datasets("poverty")
β pick a dataset (e.g. "2019_ACS5a")
nhgis_get_dataset("2019_ACS5a")
β confirm available tables and geographic levels
nhgis_search_data_tables("poverty", dataset="2019_ACS5a")
β pick a table (e.g. "B17001")
nhgis_create_extract(...)
nhgis_extract_to_code(...)
β generate R/Python code to reproduce the extractThe NHGIS public API does not support server-side filtering. The search tools fetch full metadata pages and filter client-side.
π Reproducibility & Citation
Three tools close the loop between "I pulled this data via AI" and "here's the exact code to pull it again."
Tool | Description |
| Generate R or Python code to reproduce a microdata extract |
| Generate R or Python code to reproduce an NHGIS extract |
| Return a formatted citation template with authors, DOI, and official citation link |
Code generation
After submitting or retrieving an extract, call microdata_extract_to_code (or nhgis_extract_to_code) to get ready-to-run code:
microdata_extract_to_code({ collection: "usa", extractNumber: 42, language: "both" })R output (ipumsr):
library(ipumsr)
extract <- define_extract_usa(
samples = c("us2022a"),
variables = c("VETSTAT", "AGE", "SEX", "STATEFIP"),
data_format = "csv",
data_structure = "rectangular"
)
extract <- submit_extract(extract)
extract <- wait_for_extract(extract)
path <- download_extract(extract)
ddi <- read_ipums_ddi(path$ddi)
data <- read_ipums_micro(ddi)Python output (ipumspy):
from ipumspy import IpumsApiClient, UsaExtract
import os
client = IpumsApiClient(api_key=os.environ["IPUMS_API_KEY"])
extract = UsaExtract(
samples=["us2022a"],
variables=["VETSTAT", "AGE", "SEX", "STATEFIP"],
data_format="csv"
)
extract = client.submit_extract(extract)
client.wait_for_extract(extract)
client.download_extract(extract, download_dir="./downloads")The language parameter accepts "r", "python", or "both" (default). For variables with case selections or data quality flags, R output uses var_spec() automatically. NHGIS output uses ds_spec()/tst_spec() for datasets and time series tables, with camelCase API keys converted to snake_case for both languages.
Citation
generate_ipums_citation returns the standard citation for any IPUMS collection β no API call needed:
generate_ipums_citation({ collection: "nhgis" })Returns the full author list, DOI, and a direct link to the official citation page where the current version number is always listed. Replace [YEAR] and VX with the current year and version before publishing.
π Workflow: Jupyter MCP + ipumsr
This server pairs naturally with a Jupyter MCP server to form a complete data pipeline β from browsing IPUMS metadata to live analysis in a notebook β without leaving your LLM client.
Full pipeline example
Step 1 β Browse and submit (via MCP tools in Claude) π€
1. nhgis_search_datasets β find datasets by keyword (topic, year, census program)
2. nhgis_search_data_tables β narrow to specific tables (scope to dataset for full coverage)
3. nhgis_get_dataset β confirm tables and geo levels
4. nhgis_create_extract β submit the extract
5. nhgis_get_extract β poll until status = "completed"
6. nhgis_extract_to_code β generate R/Python code to reproduce the extractOr for microdata:
1. microdata_search_variables β find variable names by keyword or group
2. microdata_list_samples β confirm the right sample ID ("2022 ACS" β us2022a)
3. microdata_create_extract β submit (size advisory tells you whether to wait or check back)
4. microdata_wait_for_extract β poll up to 90s; bail out gracefully for large extracts
5. microdata_download_extract β download data + DDI codebook
6. microdata_extract_to_code β generate R/Python code to reproduce the extractπ‘ Variable discovery: Use
microdata_search_variablesto look up mnemonics from natural language β search"income","veteran","race"β rather than relying on memorized variable names. Filter bysampleto confirm a variable is available in your target year. For NHGIS, usenhgis_search_datasetsandnhgis_search_data_tablesto find tables by keyword, thennhgis_get_data_tableto see all variables within a table.
Step 2 β Analyze in Jupyter with ipumsr (R kernel) π
Once microdata_download_extract has saved files locally, use the Jupyter MCP server to run R in a notebook:
library(ipumsr)
# Point at the DDI codebook downloaded by microdata_download_extract
ddi <- read_ipums_ddi("/data/ipums/usa_00042.xml")
data <- read_ipums_micro(ddi)
# Variable labels and value labels are attached automatically
head(data)
attr(data$VETSTAT, "labels")For Python notebooks π:
import pandas as pd
# CSV data file downloaded by microdata_download_extract
df = pd.read_csv("/data/ipums/usa_00042.csv.gz")
df.head()For NHGIS data (already CSV, no DDI needed):
library(ipumsr)
# read_nhgis reads the CSV and attaches codebook metadata
tbl <- read_nhgis("/data/ipums/nhgis0007_csv.zip", data_layer = 1)Suggested config with Jupyter MCP
Add both servers to your MCP client config:
{
"mcpServers": {
"ipums": {
"command": "node",
"args": ["/absolute/path/to/ipums-mcp/dist/index.js"],
"env": { "IPUMS_API_KEY": "your-key-here" }
},
"jupyter": {
"command": "uvx",
"args": ["jupyter-mcp-server"],
"env": { "JUPYTER_TOKEN": "your-jupyter-token" }
}
}
}With both servers running you can prompt your LLM client: "Submit a 2022 ACS extract for VETSTAT, AGE, SEX, STATEFIP, download it when ready, then open a Jupyter notebook and plot veteran counts by state with ggplot2." π―
π Security Notes
API key: Pass via
IPUMS_API_KEYenv var only. Never hard-code it or commit it to source control. For local development, store it in a.envfile (gitignored).Download URL validation:
microdata_download_extractvalidates that each download URL uses HTTPS and resolves to an*.ipums.orghost before sending your API key. URLs that fail this check are skipped and reported inerrors.Path traversal protection: Downloaded filenames are resolved against
outputDirand rejected if the resolved path would escape that directory.SHA-256 verification: Every downloaded file is verified against the checksum provided by the API. A mismatch is reported in
errorsbut the file is kept so you can inspect it.Error message sanitization: API error responses from 4xx errors are HTML-stripped and truncated before being surfaced; 5xx server error bodies are suppressed entirely.
Generated code safety: R code emitted by
microdata_extract_to_codeandnhgis_extract_to_codeescapes all string values to prevent code injection from API-returned identifiers.
π» Development
Create a .env file in the project root (already gitignored):
IPUMS_API_KEY=your-key-hereThen run:
export $(cat .env | xargs) && npm run dev # load key + run via tsx
npm run build # compile TypeScript β dist/Source layout:
src/
index.ts entry point
client.ts shared HTTP client (ipumsRequest, getApiKey)
types.ts Zod schemas
data/
usa-variables.ts offline DB β 827 harmonized IPUMS USA variables
tools/
microdata.ts microdata tools (search vars, list, get, create, wait, download)
nhgis.ts NHGIS tools (search datasets/tables/TSTs + list/get/create/extract)
codegen.ts reproducibility tools (extractβcode for R/Python, citation lookup)π License
MIT β Β© 2026 hesscl
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Flicense-qualityDmaintenanceA demo MCP server with streamable HTTP transport and auto tool registry, enabling LLMs to connect with external data sources and tools.21
- AlicenseAqualityBmaintenanceAn MCP server that gives LLM agents typed, cached access to civic open-data portals via Socrata (SODA 2.1 + Discovery API), enabling search, query, profiling, sampling, and CSV export of datasets.6MIT
- Alicense-qualityAmaintenanceMCP server to query U.S. Census Bureau data, variables, and geography through 7 tools supporting dataset discovery, variable search, geography resolution, and data queries with suppression code decoding.1,1781Apache 2.0
- Flicense-qualityCmaintenanceAn MCP server that answers natural-language questions over CSV, Excel, and SQL data by providing deterministic tools for loading, profiling, querying, cleaning, statistical analysis, visualization, and reporting. It enables LLMs to plan and interpret while all computation is done exactly through MCP tools.
Related MCP Connectors
MCP server providing access to the Scorecard API to evaluate and optimize LLM systems.
MCP server exposing the Backtest360 engine API as tools for AI agents.
MCP server for AI dialogue using various LLM models via AceDataCloud
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/hesscl/ipums-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server