Provides asynchronous access to U.S. state-level weather alerts and precise location-based forecasts via the National Weather Service API using Model Context Protocol for efficient, formatted output ideal for chatbot and CLI integration.
Unlock the full potential of Weather Alert Forecast MCP Tool through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.
Free tier available • No credit card required
A lightweight microservice using FastMCP that fetches weather alerts and forecasts from the National Weather Service API. This tool provides U.S. state-level alerts and location-based forecasts.
httpx
for non-blocking API calls.pip install httpx pip install mcp # Or your local FastMCP package
Make sure you have Python 3.9+ and mcp
installed.
python weather.py
The MCP server will start and listen for commands using the stdio
transport.
get_alerts(state: str)
Fetch active weather alerts for a U.S. state.
Arguments:
state
: Two-letter state code (e.g., CA
, TX
, NY
)Returns:
A formatted string of current alerts or a message if none are available.
get_forecast(latitude: float, longitude: float)
Fetch a detailed forecast for a specific location.
Arguments:
latitude
: Latitude of the location (e.g., 37.7749
)longitude
: Longitude of the location (e.g., -122.4194
)Returns:
Up to 5 periods of detailed forecast data (e.g., "Tonight", "Monday").
Alert Example:
Event: Flood Warning
Area: San Joaquin County
Severity: Moderate
Description: Flooding is expected in low-lying areas...
Instructions: Turn around, don’t drown...
Forecast Example:
Tonight:
Temperature: 54°F
Wind: 10 mph NW
Forecast: Clear skies with calm wind.
---
Monday:
Temperature: 68°F
Wind: 5 to 10 mph W
Forecast: Sunny and warm.
This project is licensed under the MIT License.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!