| title | emoji | colorFrom | colorTo | sdk | sdk_version | app_file | pinned |
|---|---|---|---|---|---|---|---|
MCP Postal Geocoder |
📍 |
blue |
green |
streamlit |
1.39.0 |
streamlit_app.py |
false |
Complete MCP Server & Client Implementation for US Postal Code Geocoding
A full-featured Model Context Protocol implementation including both MCP Server (FastMCP backend) and MCP Client (Streamlit demo app). Provides a drop-in replacement for GeoNames postal code API using US Census Bureau ZIP Code Tabulation Areas (ZCTAs). Fast, accurate, and comprehensive with 33,791 US postal codes.
- Complete MCP Implementation: Both server (5 tools) and client (Streamlit app)
- 5 MCP Tools: Search, geocode, reverse geocode, validate, and statistics
- Census Accuracy: Official US Census Bureau ZCTA data
- High Performance: <1ms exact lookups, <50ms reverse geocoding
- Complete Coverage: All 33,791 US postal codes with cities and states
- Reference Implementation: Perfect example for building MCP clients
- Multi-Environment: Works in development, containers, and cloud deployments
Try the live demo: MCP Postal Geocoder on HuggingFace Spaces
- 📊 Database Statistics - Real-time stats on 33,791 postal codes
- 🔍 Search Tools - Exact match and prefix search with maps
- 🌍 Geocoding - Convert postal codes to coordinates
- 📍 Reverse Geocoding - Find postal codes near any location
- ✅ Validation - Quick postal code validation
- postal_code_search - Search postal codes (exact match or prefix)
- geocode_postal - Convert postal code to coordinates
- reverse_geocode - Find postal codes near coordinates
- validate_postal - Check if postal code exists
- postal_stats - Database statistics and health
pip install -e .# Start MCP server
mcp-postal-server
# Or with Python
python -m mcp_postal_geocoder.server.mcp_server# Test all tools
postal-cli test
# Individual commands
postal-cli geocode 90210
postal-cli reverse 47.606 -122.332
postal-cli statsstreamlit run streamlit_app.py- zcta_code (TEXT) - 5-digit ZIP code (primary key)
- latitude, longitude (REAL) - WGS84 coordinates
- state (TEXT) - State abbreviation
- city (TEXT) - City name
- land_area_sqm, water_area_sqm (REAL) - Area measurements
- country_code (TEXT) - Always "US"
# Install in development mode
pip install -e .
# Run tests
pytest
# Lint and format
ruff check src/
black src/
mypy src/- Exact postal code lookup: <1ms
- Prefix searches: <10ms
- Reverse geocoding: <50ms
- Concurrent connections: 100+
- Database size: 6.9MB SQLite
src/mcp_postal_geocoder/
├── server/
│ ├── mcp_server.py # Main MCP server (FastMCP)
│ ├── database/
│ │ ├── connection.py # SQLite connection management
│ │ ├── models.py # Pydantic data models
│ │ └── queries.py # Optimized SQL queries
│ └── utils/
│ └── formatters.py # Response formatting
├── client/
│ └── cli_tool.py # CLI client for testing
└── data/
└── postal_census_complete.db # SQLite database (33,791 records)
Designed as a drop-in replacement for GeoNames postal API:
{
"totalResultsCount": 1,
"geonames": [
{
"postalCode": "90210",
"lat": 34.102512,
"lng": -118.415075,
"countryCode": "US",
"state": "CA",
"placeName": "Santa Monica"
}
]
}MIT License - see LICENSE file for details.
- Create a new Space on HuggingFace with Streamlit SDK
- Copy files:
streamlit_app.py,requirements.txt,src/,data/ - Use
space_config.ymlfor Space configuration - Or use the GitHub Action for automatic sync
- Add
HF_TOKENto GitHub repository secrets - Update USERNAME/SPACENAME in
.github/workflows/sync-to-hf.yml - Push to main branch triggers automatic deployment
streamlit run streamlit_app.py- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- ✅ Phase 1: Core MCP server implementation
- ✅ Phase 2: Advanced search and city assignments
- ✅ Phase 3: CLI client and testing tools
- ✅ Phase 4: Streamlit demo and deployment
- 🔄 Phase 5: Documentation and optimization
- US Census Bureau for ZCTA data
- Anthropic for MCP framework
- FastMCP for modern server implementation