NHANES (design-correct survey analysis) — Claude Code MCP server
Connects assistants directly to CDC NHANES files with built-in survey weights and design variance. Designed for analyses requiring Taylor linearization and NCHS standards.
claude mcp add --env NHANES_MCP_CACHE=<NHANES_MCP_CACHE> --env NHANES_MCP_DATA_DIR=<NHANES_MCP_DATA_DIR> --transport stdio nhanes-design-correct-survey-analysis -- uvx nhanes-mcpWhat NHANES (design-correct survey analysis) does
Standard language models often compute simple averages on NHANES files, yielding flawed numbers. This MCP server enforces valid survey methodology by default. It downloads public files from CDC servers, merges records on SEQN, and selects the appropriate sample weight in WT_ANALYSIS. Subsetting via the domain parameter keeps the full sample design intact, so Taylor linearization variance calculations stay sound.
The server provides 17 tools across the research workflow. They help explore CDC codebooks, recode missing values with set_missing, and collapse repeated rows via flag_from_long_table. For survival analysis, it supports design-based Cox models linked to mortality records. Supported cycles range from 1999–2000 through 2021–2023.
Running the server requires uv on your system. Black Swan Causal Labs is not affiliated with CDC, and researchers must comply with the public NCHS data use agreement.
What it helps with
- Merge multi-cycle NHANES survey files using individual
SEQNidentifiers - Assign correct probability weights automatically for exam or dietary data
- Calculate Korn-Graubard confidence intervals with official NCHS reliability flags
- Fit design-adjusted Cox survival models with Linked Mortality File follow-up
Example prompts for the agent
- Search NHANES codebooks for blood pressure variables from 2017 to 2020 and compute weighted prevalence.
- Pool 2015-2018 cycles, apply domain filtering for diabetes, and calculate mean fasting glucose.
- Run a design-based Cox model linking body mass index with mortality follow-up.
How to install NHANES (design-correct survey analysis)
Platform CLI
claude mcp add --env NHANES_MCP_CACHE=<NHANES_MCP_CACHE> --env NHANES_MCP_DATA_DIR=<NHANES_MCP_DATA_DIR> --transport stdio nhanes-design-correct-survey-analysis -- uvx nhanes-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from nhanes-mcp <command>
Platform CLI
codex mcp add nhanes-design-correct-survey-analysis --env NHANES_MCP_CACHE=<NHANES_MCP_CACHE> --env NHANES_MCP_DATA_DIR=<NHANES_MCP_DATA_DIR> -- uvx nhanes-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from nhanes-mcp <command>
Config file
{
"mcpServers": {
"nhanes-design-correct-survey-analysis": {
"command": "uvx",
"args": [
"nhanes-mcp"
],
"env": {
"NHANES_MCP_CACHE": "<NHANES_MCP_CACHE>",
"NHANES_MCP_DATA_DIR": "<NHANES_MCP_DATA_DIR>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from nhanes-mcp <command>
Config file
{
"servers": {
"nhanes-design-correct-survey-analysis": {
"type": "stdio",
"command": "uvx",
"args": [
"nhanes-mcp"
],
"env": {
"NHANES_MCP_CACHE": "<NHANES_MCP_CACHE>",
"NHANES_MCP_DATA_DIR": "<NHANES_MCP_DATA_DIR>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from nhanes-mcp <command>
Platform CLI
gemini mcp add -e NHANES_MCP_CACHE=<NHANES_MCP_CACHE> -e NHANES_MCP_DATA_DIR=<NHANES_MCP_DATA_DIR> nhanes-design-correct-survey-analysis uvx nhanes-mcpReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from nhanes-mcp <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about NHANES (design-correct survey analysis)
How do I install NHANES (design-correct survey analysis) in Claude Code?
Run claude mcp add nhanes-mcp -- uvx nhanes-mcp in your terminal. You need uv installed beforehand to execute the server.
Why use this MCP server instead of generic dataset analysis?
Naive calculations produce biased estimates because NHANES uses complex multi-stage sampling. The server enforces proper probability weights, strata tracking, and Taylor series variance estimation.
Which NHANES cycles are available?
It covers cycles from 1999–2000 through 2017–2018, the pre-pandemic 2017–March 2020 dataset, and the 2021–2023 release. Files are downloaded directly from CDC endpoints.