us-census-bureau-data-api-mcp
Copilot instructions97 starsChanged 17 months agoCC0-1.0View on GitHub
Technology Stack: - Language: TypeScript (Node.js runtime) - API: U.S. Census Bureau API - Database: PostgreSQL (for caching dataset metadata) - Validation: Zod schemas - Testing: Vitest - Build: TypeScript compiler (tsc) - Package Manager: npm - Containerization: Docker & Docker Compose Repository Size: Medium-sized TypeScript project with: - MCP server application (mcp-server/) - Database ETL service (mcp-db/) - Multi-profile Docker Compose setup (dev/test/prod) - Comprehensive test suite with unit and integration tests Project Purpose: To enable use of official…
- Reads credentials
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
13 rules. About 0 are common, 7 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 4
Ensure best practices are followed in terms of code organization, validation, and error handling
- Distinctive: line 5
Ensure architectural consistency across the codebase, especially in how MCP tools are implemented and how Census API interactions are …
- Distinctive: line 71
All validation (build, lint, tests) is handled by CI/GitHub Actions on pull requests.
- Distinctive: line 79
If modifying database schema, migrations will auto-run on next startup </BuildInstructions>
- Distinctive: line 141
Must complete successfully before MCP server can start
- Distinctive: line 150
All other tools - Query PostgreSQL database populated by mcp-db service
- Very specific: line 169
Test helpers in tests/helpers/
- Distinctive: line 175
All PRs must pass: build + lint + test suite
- Very specific: line 178
Tool Naming: All tools extend base.tool.ts
- Very specific: line 179
Schema Validation: Every tool has a corresponding .schema.js file
- Very specific: line 187
Only fetch-aggregate-data queries Census API directly - all other tools query PostgreSQL
- Very specific: line 188
All tools depend on base.tool.ts
- Very specific: line 191
Test utilities centralized in tests/helpers/
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<Goals>
- Provide expert-level review of the repository's structure, technology stack, and critical patterns, with a focus on Model Context Protocol (MCP) best practices
- Highlight any non-obvious dependencies or architectural decisions that may impact code changes
- Ensure best practices are followed in terms of code organization, validation, and error handling
- Ensure architectural consistency across the codebase, especially in how MCP tools are implemented and how Census API interactions are handled
</Goals><HighLevelDetails>
This repository is a Model Context Protocol (MCP) server that provides AI-ready U.S. Census Bureau data.Technology Stack:
- Language: TypeScript (Node.js runtime)
- API: U.S. Census Bureau API
- Database: PostgreSQL (for caching dataset metadata)
- Validation: Zod schemas
- Testing: Vitest
- Build: TypeScript compiler (tsc)
- Package Manager: npm
- Containerization: Docker & Docker Compose
Repository Size: Medium-sized TypeScript project with:
- MCP server application (mcp-server/)
- Database ETL service (mcp-db/)
- Multi-profile Docker Compose setup (dev/test/prod)
- Comprehensive test suite with unit and integration tests
Project Purpose: To enable use of official Census Bureau statistics with AI assistants, leveraging the Model Context Protocol to provide token-optimized data that reduces hallucinations.
</HighLevelDetails>
<BuildInstructions>
**Prerequisites:**
- Docker and Docker Compose installed
- Node.js 18+ (for local development outside Docker)Local Development Setup:
The project uses Docker Compose with multiple profiles (dev, test, prod).
Start Development Environment:
docker compose --profile dev upThis starts:
- PostgreSQL database on port 5433
- Runs migrations automatically
- Leaves the dev container running for interactive commands
Run Tests in Development:
docker compose --profile dev exec census-mcp-db-dev-init npm run testRun Linter in Development:
docker compose --profile dev exec census-mcp-db-dev-init npm run lintRun Tests (Standalone):
docker compose --profile test up census-mcp-db-test-initStarts test database and runs the test suite, then exits.
Production Deployment:
docker compose --profile prod upStarts production services with MCP server on standard PostgreSQL port 5432.
Validation: All validation (build, lint, tests) is handled by CI/GitHub Actions on pull requests.
Important Notes:
- The project is containerized - all services run in Docker
- Development uses port 5433, test uses 5434, prod uses 5432
- Database migrations run automatically on container startup
- The MCP server runs as a containerized service, not standalone
- Focus on writing correct code - let CI handle validation
- If modifying database schema, migrations will auto-run on next startup
</BuildInstructions>
<ProjectLayout>
**Directory Structure:**
```
/
├── mcp-db/ # Database ETL service (CRITICAL - runs first)
│ ├── src/
│ │ ├── seeds # Orchestrates seeding process
│ │ │ ├── configs # Configs for seeding different data types
│ │ │ ├── scripts # Generic seeding utilities
│ │ │ │ ├── seed-runner # Orchestrates seeding process
│ │ │ │ └── seed-database # Executes ETL pipeline
│ ├── migrations/ # Database schema migrations
│ ├── tests/ # Test suite (mirrors src/)
│ ├── Dockerfile
│ ├── package.json
│ ├── tsconfig.json
│ ├── vitest.config.ts
│ └── eslint.config.js
├── mcp-server/ # Main MCP server application
│ ├── src/
│ │ ├── tools/ # MCP tool implementations
│ │ │ ├── base.tool.ts
│ │ │ ├── fetch-aggregate-data.tool.ts
│ │ │ ├── fetch-dataset-geography.tool.ts
│ │ │ ├── list-datasets.tool.ts
│ │ │ └── resolve-geography-fips.tool.ts
│ │ ├── types/ # TypeScript definitions
│ │ ├── schema/ # Zod validation schemas
│ │ ├── prompts/ # MCP prompts
│ │ ├── services/ # Database service
│ │ ├── index.js # Entry point
│ │ └── server.js
│ ├── tests/ # Test suite (mirrors src/)
│ ├── Dockerfile
│ ├── package.json
│ ├── tsconfig.json
│ ├── vitest.config.ts
│ └── eslint.config.js
├── docker-compose.yml # Multi-profile orchestration
```Configuration Files:
mcp-server/tsconfig.json- TypeScript strict mode, local developmentmcp-server/tsconfig.docker.json- TypeScript config for Docker buildsmcp-server/vitest.config.ts- Test configuration with coveragemcp-server/eslint.config.js- Linting rulesmcp-server/.prettierrc- Code formatting rulesmcp-db/Dockerfile- Multi-stage build (dev/prod targets) for ETL servicemcp-db/tsconfig.json- TypeScript config for database ETLmcp-db/package.json- Dependencies for migration and seedingdocker-compose.yml- Multi-profile service orchestration (dev/test/prod)
Key Architectural Elements:
- MCP Database Service (
mcp-db/)- CRITICAL: Extracts, transforms, and loads (ETL) all Census metadata into PostgreSQL
- Runs migrations and seeds database on container startup
- Provides metadata used by all tools EXCEPT
fetch-aggregate-datatool - Tools like
list-datasets,resolve-geography-fips, andfetch-dataset-geographyquery this database - Must complete successfully before MCP server can start
- Multi-stage Dockerfile (dev/prod targets)
- MCP Tools (
mcp-server/src/tools/)base.tool.ts- Abstract base class for all tools- Each tool file implements one MCP tool following Model Context Protocol
- Tools use Zod schemas for validation
- Data sources:
fetch-aggregate-data.tool.ts- Queries Census API directly- All other tools - Query PostgreSQL database populated by mcp-db service
- Schemas (
mcp-server/src/schema/)- Zod validation schemas for all Census API responses
validators.js- Shared validation utilities- Each tool has a corresponding schema file
- Prompts (
mcp-server/src/prompts/)- MCP prompt implementations
base.prompt.js- Base prompt functionality- Example:
population.prompt.jsfor population-related queries
- Services (
mcp-server/src/services/)database.service.js- PostgreSQL connection and query handling- Used by most tools to retrieve metadata from database
- Testing Structure (
mcp-server/tests/)- Unit tests:
*.test.ts - Integration tests:
*.integration.test.ts - Test helpers in
tests/helpers/ - Mocks in
tests/mocks/
- Unit tests:
CI/CD Checks:
- GitHub Actions workflows (not visible in tree, assumed present)
- Local validation via Docker Compose test profile
- All PRs must pass: build + lint + test suite
Critical Patterns:
- Tool Naming: All tools extend
base.tool.ts - Schema Validation: Every tool has a corresponding
.schema.jsfile - Test Organization: Tests mirror
src/structure with unit + integration - FIPS Geography Codes: Handled in
resolve-geography-fips.tool.ts - Database Service: Centralized in
database.service.js
Dependencies Not Obvious from Structure:
- mcp-db service MUST run successfully before mcp-server starts - it populates the metadata database
- Most tools (
list-datasets,resolve-geography-fips,fetch-dataset-geography) depend on database populated by mcp-db - Only
fetch-aggregate-dataqueries Census API directly - all other tools query PostgreSQL - All tools depend on
base.tool.ts - Tools use schemas from
schema/directory for validation - Database connection managed by
database.service.js - Test utilities centralized in
tests/helpers/
Important Files:
mcp-server/src/index.js- MCP server entry pointmcp-server/src/server.js- Server initialization and configurationmcp-server/sample.env- Required environment variables templatemcp-db/src/seeds/configs/*- Config files for seeding different data types (datasets, geographies, variables)mcp-db/src/seeds/scripts/seed-runner- Orchestrates database seeding processmcp-db/src/seeds/scripts/seed-database- Executes ETL pipeline to populate metadatadocker-compose.yml- Service orchestration with dev/test/prod profiles
Trust These Instructions:
The information above reflects the actual repository structure. Only search for additional information if these instructions are incomplete or incorrect for your specific task.
</ProjectLayout>
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

