Government Data MCP Server

Government Data MCP Server

MCP (Model Context Protocol) server for accessing U.S. government data APIs, specifically designed for Business Initiative’s statistics content generation.

Purpose

This MCP server provides standardized access to:

  • Census Bureau Business Dynamics Statistics (BDS) API ✅
  • Census Bureau American Community Survey (ACS) API ✅
  • Census Bureau Annual Business Survey (ABS) API ✅
  • Census Bureau Business Formation Statistics (BFS) API ⚠️ (Code ready, endpoint needs verification)

Benefits

  • ✅ Centralized API access for all government data
  • ✅ Reusable by AI assistants for on-demand content creation
  • ✅ Centralized API key management
  • ✅ Built-in rate limiting and error handling
  • ✅ Consistent data format across all sources
  • ✅ Can be used by existing Python scripts

Setup

1. Install Dependencies

cd mcp-servers/government-data
pip install -r requirements.txt

Note: The MCP Python SDK package name may vary. If pip install mcp doesn’t work, try:

  • pip install mcp-python
  • Or install from: https://github.com/modelcontextprotocol/python-sdk

2. Configure API Key

Create a .env file in the mcp-servers/government-data/ directory:

CENSUS_API_KEY=your_api_key_here

Or set as environment variable:

export CENSUS_API_KEY=your_api_key_here

Get your API key from: https://api.census.gov/data/key_signup.html

3. Test the Server

python server.py

The server should start and wait for MCP protocol messages via stdio.

4. Configure in Cursor

Add to your Cursor MCP settings (usually in ~/.cursor/mcp.json or Cursor settings):

{
  "mcpServers": {
    "government-data": {
      "command": "python3",
      "args": [
        "/Users/nickjackolaisen/Documents/GitHub/BI/mcp-servers/government-data/server.py"
      ],
      "env": {
        "CENSUS_API_KEY": "541100b6baa56ca3bafeffa63e59e80ba1f10d34"
      }
    }
  }
}

Quick Setup: See CURSOR_SETUP.md for step-by-step instructions!

Available Tools

Once configured, AI assistants can use these tools:

  • fetch_census_bds_data - Business Dynamics Statistics ✅
  • fetch_census_acs_data - American Community Survey ✅
  • fetch_census_abs_data - Annual Business Survey ✅
  • fetch_census_bfs_data - Business Formation Statistics ⚠️ (Endpoint needs verification)

Usage Examples

From AI Assistant

“Fetch business startup data for 2020-2023 from BDS API”

From Python Scripts

from mcp_government_data import fetch_bds_data

data = fetch_bds_data(start_year=2020, end_year=2023, geography="us:*")

Architecture

mcp-servers/government-data/
├── server.py              # Main MCP server
├── census_client.py       # Census API client with rate limiting
├── tools.py               # MCP tool definitions
├── requirements.txt       # Python dependencies
├── .env.example          # Example environment config
└── README.md             # This file

Notes

  • Rate limiting: 1 request per second (Census API limit)
  • Caching: Consider adding Redis/file cache for frequently accessed data
  • Error handling: All tools return structured error responses