{"id":50993886,"url":"https://github.com/cyanheads/census-mcp-server","last_synced_at":"2026-06-20T06:32:39.027Z","repository":{"id":360104259,"uuid":"1248230978","full_name":"cyanheads/census-mcp-server","owner":"cyanheads","description":"Query U.S. Census Bureau data, variables, and geography via MCP. STDIO or Streamable HTTP.","archived":false,"fork":false,"pushed_at":"2026-06-12T07:23:33.000Z","size":879,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T09:16:07.562Z","etag":null,"topics":["acs","ai","bun","census","census-bureau","demographic-data","fips","geography","government-data","llm","mcp","mcp-server","model-context-protocol","open-data","stdio","streamable-http"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@cyanheads/census-mcp-server","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyanheads.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":"cyanheads","buy_me_a_coffee":"cyanheads"}},"created_at":"2026-05-24T11:15:29.000Z","updated_at":"2026-06-12T07:23:36.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cyanheads/census-mcp-server","commit_stats":null,"previous_names":["cyanheads/census-mcp-server"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/cyanheads/census-mcp-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fcensus-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fcensus-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fcensus-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fcensus-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyanheads","download_url":"https://codeload.github.com/cyanheads/census-mcp-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fcensus-mcp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34560265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acs","ai","bun","census","census-bureau","demographic-data","fips","geography","government-data","llm","mcp","mcp-server","model-context-protocol","open-data","stdio","streamable-http"],"created_at":"2026-06-20T06:32:37.715Z","updated_at":"2026-06-20T06:32:39.007Z","avatar_url":"https://github.com/cyanheads.png","language":"TypeScript","funding_links":["https://github.com/sponsors/cyanheads","https://buymeacoffee.com/cyanheads"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e@cyanheads/census-mcp-server\u003c/h1\u003e\n  \u003cp\u003e\u003cb\u003eQuery U.S. Census Bureau data, variables, and geography via MCP. STDIO or Streamable HTTP.\u003c/b\u003e\n  \u003cdiv\u003e7 Tools\u003c/div\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Version](https://img.shields.io/badge/Version-0.1.10-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square\u0026logo=docker\u0026logoColor=white)](https://github.com/users/cyanheads/packages/container/package/census-mcp-server) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/census-mcp-server?style=flat-square\u0026logo=npm\u0026logoColor=white)](https://www.npmjs.com/package/@cyanheads/census-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.3.2-blueviolet.svg?style=flat-square)](https://bun.sh/)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge\u0026logo=anthropic\u0026logoColor=white)](https://github.com/cyanheads/census-mcp-server/releases/latest/download/census-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=census-mcp-server\u0026config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvY2Vuc3VzLW1jcC1zZXJ2ZXIiXX0=) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge\u0026logo=visualstudiocode\u0026logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22census-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fcensus-mcp-server%22%5D%7D)\n\n[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n**Public Hosted Server:** [https://census.caseyjhand.com/mcp](https://census.caseyjhand.com/mcp)\n\n\u003c/div\u003e\n\n---\n\n## Tools\n\n7 tools covering the full Census data workflow — from dataset discovery and variable search through geography resolution and ranked comparisons:\n\n| Tool | Description |\n|:-----|:------------|\n| `census_list_datasets` | Browse available Census Bureau datasets (ACS5, ACS1, Population Estimates, Decennial) with vintage years and dataset codes. |\n| `census_list_geographies` | List the geography levels supported by a dataset and year, with parent requirements and example FIPS values. |\n| `census_search_variables` | Keyword search across variable labels and concept groups. Returns estimate and margin-of-error codes together. |\n| `census_get_variable` | Fetch full metadata for one or more variable codes — label, concept, predicate type, universe, MOE sibling. |\n| `census_resolve_geography` | Convert place names (e.g., \"King County, WA\") or street addresses to Census FIPS identifiers via TIGERweb and Census Geocoder. |\n| `census_query_data` | Query a Census dataset for variables at a specific geography. Returns estimates with MOE, suppression codes resolved to readable reasons. |\n| `census_compare_geographies` | Rank and compare variables across multiple geographies — all counties in a state, all states nationally, or a named set. Sorted table output. |\n\n### `census_list_datasets`\n\nBrowse available Census Bureau datasets.\n\n- Returns dataset codes, names, descriptions, and available vintage years\n- Covers ACS5, ACS5 Data Profiles, ACS5 Subject Tables, ACS1, ACS1 Data Profiles, Population Estimates, Decennial Redistricting (P.L. 94-171), and Decennial DHC\n- Accepts an optional keyword filter\n- Dataset codes (e.g., `acs/acs5`) are the values to pass to other tools\n\n---\n\n### `census_search_variables`\n\nSearch Census variables by keyword.\n\n- Full-text search across label and concept fields with relevance scoring (exact concept match \u003e label match \u003e partial)\n- Returns estimate (E suffix) and margin-of-error (M suffix) codes together so both can be requested in one query\n- Configurable limit (default 20, max 100); `total_matches` indicates how many matched before the limit\n- Cache-backed: variables.json is fetched once per dataset+year with a configurable TTL (default 24h)\n\n---\n\n### `census_resolve_geography`\n\nConvert place names and addresses to Census FIPS identifiers.\n\n- Named places (e.g., \"King County, WA\", \"California\") resolved via TIGERweb MapServer\n- Street addresses resolved to tract level via Census Geocoder\n- Auto-detects geography type from the name; accepts explicit `geography_type` override\n- Detects ambiguous names (multiple states) and returns candidates with recovery hints\n- Returns `state_fips` (→ `parent_fips`) and `fips_summary` (→ `geography_fips`) ready to pass to other tools\n\n---\n\n### `census_query_data`\n\nQuery a Census dataset for one or more variables at a specific geography.\n\n- Requires FIPS codes — use `census_resolve_geography` first for place names\n- Use `geography_fips: \"*\"` to return all geographies at the level within the parent\n- Suppression codes (geography too small, data not collected, etc.) resolved to human-readable reasons\n- Variable labels enriched from cache and surfaced alongside estimates\n- Requires `CENSUS_API_KEY`\n\n---\n\n### `census_compare_geographies`\n\nRank and compare variables across multiple geographies.\n\n- Fetches all geographies at a level (e.g., all WA counties) in one API call, then sorts and slices\n- Optional `within` parameter to constrain to a parent FIPS; omit for national comparison\n- Optional `geographies` list to filter to specific FIPS values\n- Configurable sort variable, direction, and limit (default 50, max 500)\n- Suppressed values sorted to end of results and labeled rather than passed through as negative sentinels\n- Requires `CENSUS_API_KEY`\n\n---\n\n## Features\n\nBuilt on [`@cyanheads/mcp-ts-core`](https://www.npmjs.com/package/@cyanheads/mcp-ts-core):\n\n- Declarative tool definitions — single file per tool, framework handles registration and validation\n- Unified error handling — handlers throw, framework catches, classifies, and formats with recovery hints\n- Structured logging with optional OpenTelemetry tracing\n- STDIO and Streamable HTTP transports\n\nCensus-specific:\n\n- In-process variable cache with configurable TTL — variables.json fetched once per dataset+year, searched client-side\n- Three-API backend: Census Data API for data queries, TIGERweb for named-place resolution, Census Geocoder for address-to-tract\n- Automatic retry with backoff on all external API calls\n- FIPS formatting helpers — zero-padded state, county, and tract codes ready to pass between tools\n\nAgent-friendly output:\n\n- Workflow-oriented tool surface — `fips_summary` and `state_fips` return values are ready to pass as `geography_fips` and `parent_fips` to the next tool\n- Suppression codes decoded — Census negative sentinel values (e.g., `-666666666`) surfaced as human-readable reasons instead of raw numbers\n- Recovery hints on errors — ambiguous geography names include candidate lists; missing API key errors include registration URL\n\n---\n\n## Getting started\n\n\u003e **API key:** Register a free key at [api.census.gov/data/key_signup.html](https://api.census.gov/data/key_signup.html). Variable search and geography resolution work without a key; data queries (`census_query_data`, `census_compare_geographies`) require one.\n\nAdd the following to your MCP client configuration file:\n\n```json\n{\n  \"mcpServers\": {\n    \"census-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"bunx\",\n      \"args\": [\"@cyanheads/census-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\",\n        \"CENSUS_API_KEY\": \"your-census-api-key\"\n      }\n    }\n  }\n}\n```\n\nOr with npx (no Bun required):\n\n```json\n{\n  \"mcpServers\": {\n    \"census-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@cyanheads/census-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\",\n        \"CENSUS_API_KEY\": \"your-census-api-key\"\n      }\n    }\n  }\n}\n```\n\nOr with Docker:\n\n```json\n{\n  \"mcpServers\": {\n    \"census-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"docker\",\n      \"args\": [\n        \"run\", \"-i\", \"--rm\",\n        \"-e\", \"MCP_TRANSPORT_TYPE=stdio\",\n        \"-e\", \"CENSUS_API_KEY=your-census-api-key\",\n        \"ghcr.io/cyanheads/census-mcp-server:latest\"\n      ]\n    }\n  }\n}\n```\n\nFor Streamable HTTP, set the transport and start the server:\n\n```sh\nMCP_TRANSPORT_TYPE=http MCP_HTTP_PORT=3010 CENSUS_API_KEY=... bun run start:http\n# Server listens at http://localhost:3010/mcp\n```\n\n### Prerequisites\n\n- [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+).\n- A Census API key — register free at [api.census.gov/data/key_signup.html](https://api.census.gov/data/key_signup.html). Required for `census_query_data` and `census_compare_geographies`; other tools work without it.\n\n### Installation\n\n1. **Clone the repository:**\n\n```sh\ngit clone https://github.com/cyanheads/census-mcp-server.git\n```\n\n2. **Navigate into the directory:**\n\n```sh\ncd census-mcp-server\n```\n\n3. **Install dependencies:**\n\n```sh\nbun install\n```\n\n4. **Configure environment:**\n\n```sh\ncp .env.example .env\n# edit .env and set CENSUS_API_KEY\n```\n\n---\n\n## Configuration\n\n| Variable | Description | Default |\n|:---------|:------------|:--------|\n| `CENSUS_API_KEY` | **Required for data queries.** Register free at api.census.gov/data/key_signup.html. | — |\n| `CENSUS_DEFAULT_YEAR` | Default vintage year when no year is specified. | `2024` |\n| `CENSUS_VARIABLE_CACHE_TTL_HOURS` | Hours to cache variables.json per dataset+year in memory. | `24` |\n| `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |\n| `MCP_HTTP_PORT` | Port for HTTP server. | `3010` |\n| `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |\n| `MCP_LOG_LEVEL` | Log level (`debug`, `info`, `notice`, `warning`, `error`). | `info` |\n| `OTEL_ENABLED` | Enable OpenTelemetry instrumentation. | `false` |\n\nSee [`.env.example`](./.env.example) for the full list of optional overrides.\n\n---\n\n## Running the server\n\n### Local development\n\n```sh\n# One-time build\nbun run rebuild\n\n# Run the built server\nbun run start:stdio\n# or\nbun run start:http\n```\n\nRun checks and tests:\n\n```sh\nbun run devcheck   # Lint, format, typecheck, security audit\nbun run test       # Vitest test suite\nbun run lint:mcp   # Validate MCP definitions against spec\n```\n\n### Docker\n\n```sh\ndocker build -t census-mcp-server .\ndocker run --rm -e CENSUS_API_KEY=your-key -p 3010:3010 census-mcp-server\n```\n\nThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to `/var/log/census-mcp-server`. OpenTelemetry peer dependencies are installed by default — build with `--build-arg OTEL_ENABLED=false` to omit them.\n\n---\n\n## Project structure\n\n| Path | Purpose |\n|:-----|:--------|\n| `src/index.ts` | `createApp()` entry point — registers tools and initializes services. |\n| `src/config/server-config.ts` | Census-specific env var parsing and validation with Zod. |\n| `src/mcp-server/tools/definitions/` | Tool definitions (`*.tool.ts`). |\n| `src/services/census-api/` | Census Data API client — data queries, suppression code mapping, retry logic. |\n| `src/services/geography/` | Geography resolution — TIGERweb named-place lookup and Census Geocoder address-to-tract. |\n| `src/services/variable-cache/` | In-process variables.json cache with TTL and keyword search. |\n| `tests/` | Vitest tests mirroring `src/` structure. |\n\n---\n\n## Development guide\n\nSee [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:\n\n- Handlers throw, framework catches — no `try/catch` in tool logic\n- Use `ctx.log` for request-scoped logging, `ctx.state` for tenant-scoped storage\n- Register new tools via the barrel in `src/mcp-server/tools/definitions/index.ts`\n- Wrap external API calls: validate raw → normalize to domain type → return output schema; never fabricate missing fields\n\n---\n\n## Contributing\n\nIssues and pull requests are welcome. Run checks and tests before submitting:\n\n```sh\nbun run devcheck\nbun run test\n```\n\n---\n\n## License\n\nApache-2.0 — see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fcensus-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyanheads%2Fcensus-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fcensus-mcp-server/lists"}