Quick Setup Guide

Quick Setup Guide

Step-by-Step Setup

1. Get Your Census API Key

  1. Visit: https://api.census.gov/data/key_signup.html
  2. Fill out the form to get your free API key
  3. Copy the key (looks like: 541100b6baa56ca3bafeffa63e59e80ba1f10d34)

2. Set Up Environment

# Navigate to the MCP server directory
cd /Users/nickjackolaisen/Documents/GitHub/BI/mcp-servers/government-data

# Create .env file
echo "CENSUS_API_KEY=your_key_here" > .env

# Install dependencies
pip install -r requirements.txt

3. Test the Census Client

Create a test file test_client.py:

from census_client import CensusAPIClient

client = CensusAPIClient()
result = client.fetch_bds_data(
    variables=["ESTABS_ENTRY"],
    year=2023,
    geography="us:*"
)
print(result)

Run it:

python test_client.py

4. Configure Cursor

  1. Open Cursor Settings
  2. Find “MCP Servers” or “Model Context Protocol” section
  3. Add the server configuration:
{
  "mcpServers": {
    "government-data": {
      "command": "python3",
      "args": [
        "/Users/nickjackolaisen/Documents/GitHub/BI/mcp-servers/government-data/server.py"
      ],
      "env": {
        "CENSUS_API_KEY": "your_key_here"
      }
    }
  }
}
  1. Restart Cursor

5. Verify It Works

In Cursor, try asking:

  • “Fetch business startup data for 2023 from the Census BDS API”
  • “Get population data for California from ACS”

The AI assistant should be able to use the MCP tools automatically!

Troubleshooting

“ModuleNotFoundError: No module named ‘mcp’”

The MCP Python SDK might have a different package name. Try:

pip install mcp-python
# or
pip install git+https://github.com/modelcontextprotocol/python-sdk.git

“CENSUS_API_KEY must be set”

Make sure you’ve created the .env file or set the environment variable:

export CENSUS_API_KEY=your_key_here

Server not connecting in Cursor

  1. Check the path in your MCP config is absolute and correct
  2. Make sure python3 (or python) is in your PATH
  3. Test the server manually: python server.py should start without errors
  4. Check Cursor’s MCP logs/console for error messages