raseniero/mcp-server-weather
If you are the rightful owner of mcp-server-weather and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Weather MCP Server is a lightweight FastMCP service that provides access to National Weather Service alerts and forecasts through simple RPC-style tools.
Weather MCP Server
A lightweight FastMCP service exposing National Weather Service alerts and forecasts via simple RPC-style "tools".
Installation
First, install uv (a fast Python package manager) if you don't have it already:
curl -LsSf https://astral.sh/uv/install.sh | sh
Create virtual environment and activate it
uv venv
source .venv/bin/activate
Install dependencies
uv add "mcp[cli]" httpx
Then install from PyPI:
pip install weather-mcp-server
Or install from source for development:
git clone https://github.com/YourOrg/weather-mcp-server.git
cd weather-mcp-server
pip install -e ".[dev]"
Usage
As a Python library
from weather.nws_client import NWSClient
import asyncio
async def main():
client = NWSClient()
alerts = await client.get_alerts("CA")
for alert in alerts:
print(alert["headline"], alert["event"], alert["severity"])
asyncio.run(main())
As a FastMCP server
weather-mcp-server --transport stdio
Or
uv run main.py
To run the MCP Inspector:
npx @modelcontextprotocol/inspector
Copy the Session token and the Proxy server address (see example below).
Proxy server listening on 127.0.0.1:6277
Session token: dc7a47f8b6b1a3eede7c507a8d1c9a7f7e6b3ff46c138f8480bbfbae3c45a9e4
Open the MCP Inspector in your browser:http://127.0.0.1:6274, and in the Configuration, paste the values to the following fields below:
Command: uv
Argument: run main.py
Inspector Proxy Address: http://127.0.0.1:6274
Proxy Session Token: dc7a47f8b6b1a3eede7c507a8d1c9a7f7e6b3ff46c138f8480bbfbae3c45a9e4
API Reference
get_alerts
Fetch formatted weather alerts for a given two-letter US state code.
Arguments:
state
(str): Two-letter uppercase state abbreviation (e.g. "CA").
Returns:
str
: Formatted alerts separated by---
, or an error message.
get_forecast
Fetch formatted weather forecast for a location.
Arguments:
latitude
(float): Latitude between -90 and 90.longitude
(float): Longitude between -180 and 180.
Returns:
str
: Forecast for up to next 5 periods or an error message.
/health
Health check endpoint.
HTTP GET /health
Returns JSON:
{"status": "ok"}
Testing & Coverage
- Tests use
pytest
,pytest-asyncio
, andpytest-cov
. - Network calls are monkeypatched for isolation in unit tests.
- Run all tests with:
pytest
- Generate an HTML coverage report with:
pytest --cov=src --cov-report=html open htmlcov/index.html
Fixtures & Mocking
- Test fixtures and monkeypatching are used to mock NWS API responses and isolate tests from network dependencies.
- See
tests/conftest.py
for reusable fixtures.