A Model Context Protocol (MCP) server for retrieving weather alerts and forecasts using the National Weather Service (NWS) API.
- Get Weather Alerts: Retrieve active weather alerts for any US state
- Get Weather Forecast: Obtain weather forecasts for specific geographic coordinates
- MCP Integration: Built with FastMCP for seamless integration with AI assistants
- Async Support: Non-blocking asynchronous API calls for efficient performance
- Python >= 3.13
- httpx >= 0.28.1
- mcp[cli] >= 1.25.0
- Clone the repository:
git clone <repository-url>
cd weather- Install dependencies:
pip install -e .Or using uv:
uv syncpython main.pyGet weather alerts for a US state.
Parameters:
state(str): Two-letter US state code (e.g., CA, NY)
Example:
result = await get_alerts("CA")Get weather forecast for a specific location.
Parameters:
latitude(float): Latitude of the locationlongitude(float): Longitude of the location
Example:
result = await get_forecast(40.7128, -74.0060)The project uses the FastMCP framework to create a Model Context Protocol server that exposes weather-related tools. All API requests go through the National Weather Service API with proper error handling and timeout management.
- weather.py: Main server implementation with tool definitions
- main.py: Entry point for running the server
- pyproject.toml: Project configuration and dependencies
This server uses the National Weather Service API, which is:
- Free to use
- Public data
- No authentication required
- Covers the United States and its territories
The server includes comprehensive error handling for:
- Network timeouts (30-second limit)
- Invalid API responses
- Missing or unavailable data
To modify or extend the tools:
- Edit the tool definitions in
weather.py - Add new async functions with the
@mcp.tool()decorator - Include proper docstrings with argument descriptions
- Test with the running server
Add license information here.
Contributions are welcome! Please feel free to submit a pull request.