abg011/WeatherMCP
If you are the rightful owner of WeatherMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
WeatherMCP is a sample Model Context Protocol (MCP) server designed to provide weather-related data and services through a structured protocol interface.
WeatherMCP
A simple Model Context Protocol (MCP) server that exposes tools for fetching live weather alerts and forecasts from the U.S. National Weather Service (NWS) API.
Features
- Weather alerts by state: Fetches active NWS alerts for any U.S. state using its two-letter code (e.g.
CA,NY). - Point forecast by coordinates: Returns a human-readable short-term forecast for a latitude/longitude pair.
- No API key required: Uses the public
api.weather.govendpoints.
Requirements
- Python: 3.10+
- Dependencies (also listed in
pyproject.toml):httpxmcp[cli]
You can install dependencies with your preferred tool (e.g. uv, pip).
# using uv
yuv sync
# or using pip
pip install -r requirements.txt # or equivalent
Running the MCP server
The MCP server implementation lives in weather.py and is built with FastMCP.
To run it directly (stdio transport):
python weather.py
In tools that support MCP configuration (e.g. Claude Desktop, Cursor, or other MCP clients), point the server command to something equivalent to:
python /path/to/weather.py
or, if you are using uv:
uv run python weather.py
Exposed tools
The server currently exposes two tools:
get_alerts(state: str) -> str
Description: Returns active NWS weather alerts for a U.S. state.
- Parameters:
state(str): Two-letter U.S. state code (e.g.CA,NY).
- Output: A formatted string summarizing each alert (event, area, severity, description, and recommended instructions), or a message indicating there are no active alerts / data could not be fetched.
get_forcast(latitude: float, longitude: float) -> str
Note: The tool name is intentionally
get_forcast(with this exact spelling) to match the server implementation.
Description: Returns a short-term forecast for a specific location.
- Parameters:
latitude(float): Latitude of the location.longitude(float): Longitude of the location.
- Output: A formatted string summarizing the next few forecast periods (name, temperature, wind, and detailed forecast text), or a message indicating data could not be fetched.
Development
- Main MCP server entrypoint:
weather.py - Simple test script:
main.py(prints a greeting; not used by the MCP server itself).
You can modify or extend the server by adding new @mcp.tool() functions in weather.py.
Notes
- This project is intended as a minimal sample MCP server for experimentation and learning.
- It currently uses only public NWS endpoints and does not require authentication or secrets.