A feature-rich MCP (Model Context Protocol) server that provides comprehensive weather data using the NWS (National Weather Service) public APIs. Includes input validation, error handling, geocoding, and a unique weather comparison feature.
- Install uv (macOS / Linux):
curl -LsSf https://astral.sh/uv/install.sh | sh
# restart your terminal- Create project, venv and install deps:
uv init weather
cd weather
uv venv
source .venv/bin/activate
uv add "mcp[cli]" httpx- Run the server:
uv run main.py
# or
uv run weather.pyThe server provides the following MCP tools:
Get active weather alerts for a US state.
- Input: Two-letter US state code (e.g., "CA", "NY", "TX")
- Features: Validates state codes, provides detailed alert information
Get detailed weather forecast for a location using coordinates.
- Input: Latitude (-90 to 90) and Longitude (-180 to 180)
- Features: 10-period forecast (5 days), includes humidity and precipitation probability
Get weather forecast by city name (no coordinates needed!).
- Input: City name (e.g., "San Francisco", "New York", "Chicago")
- Features: Automatic geocoding, works with city names
Get real-time current weather conditions.
- Input: Latitude and Longitude
- Features: Temperature, humidity, wind, pressure, visibility, and more
Compare weather conditions between two locations side-by-side.
- Input: Two locations (city names or "lat,lon" format)
- Features: Side-by-side comparison, temperature difference analysis, supports both city names and coordinates
- ✅ Input Validation: Validates state codes and coordinate ranges
- ✅ Better Error Handling: Specific, helpful error messages
- ✅ Geocoding Support: Search by city name using Open-Meteo geocoding API
- ✅ Current Conditions: Real-time weather observations
- ✅ Enhanced Forecasts: More detailed information including humidity and precipitation
- ✅ Weather Comparison: Unique feature to compare two locations
- ✅ Location Detection: Automatically detects and displays city/state names
weather.py— Main MCP server implementation with all toolsmain.py— Entry point that imports and runs the server
- Python 3.11+ required (see
pyproject.toml) - NWS Coverage: The NWS API only covers US territories. International locations will not work.
- Transport: The server uses stdio transport by default
- MCP Clients: Use Claude Desktop,
mcpCLI, or another MCP client to connect - Geocoding: City name search uses Open-Meteo's free geocoding API (no API key required)
Once connected to an MCP client, you can use the tools like:
# Get alerts for California
get_alerts("CA")
# Get forecast by city name
get_forecast_by_city("San Francisco")
# Get current conditions
get_current_conditions(37.7749, -122.4194)
# Compare weather between two cities
compare_weather("New York", "Los Angeles")
Apache License 2.0 — see LICENSE. Replace the placeholder year/name in LICENSE if needed.