MCP server for 7-day weather intelligence — rain, UV, heat & air quality with real SHAP explainability
Project description
Weather MCP
MCP server that predicts rain for the next 7 days in any city and explains the
prediction using SHAP values. Mirrors Part 3 of weather_shap.ipynb:
XGBoost + SHAP TreeExplainer + live Open-Meteo data.
Tools
| Tool | Purpose |
|---|---|
predict_rain_7day |
7-day rain probability forecast for a city. Trains an XGBoost model on 2 years of historical data on first call, then caches it. |
explain_rain_prediction |
SHAP factors for a specific forecasted day — which feature pushed the probability up or down and by how much. |
city_model_info |
Metadata about the cached model (accuracy, training window). |
Data source: Open-Meteo (no API key required).
Install
cd weather-mcp
python -m venv .venv
source .venv/bin/activate
pip install -e .
This installs the weather-mcp console script, which is what the MCP clients
below will launch.
Running locally (smoke test)
weather-mcp
The server speaks MCP over stdio — it will sit waiting for JSON-RPC. Use Ctrl-C to stop. Real testing happens through one of the clients below.
Connect to Claude Desktop
Edit ~/.config/Claude/claude_desktop_config.json (Linux) or
~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"weather": {
"command": "/absolute/path/to/weather-mcp/.venv/bin/weather-mcp"
}
}
}
Restart Claude Desktop. You should see a 🔌 icon listing predict_rain_7day,
explain_rain_prediction, and city_model_info.
Connect to Cursor
Settings → MCP → Add new MCP server:
- Name:
weather - Command:
/absolute/path/to/weather-mcp/.venv/bin/weather-mcp
Connect to VS Code (Continue extension or any MCP-aware client)
Add to your client's MCP config:
{
"mcpServers": {
"weather": {
"command": "/absolute/path/to/weather-mcp/.venv/bin/weather-mcp",
"args": []
}
}
}
Example conversation
You: Will it rain in Tokyo over the next 7 days?
(client calls
predict_rain_7day(city="Tokyo"))Claude: Tomorrow shows a 78% chance of rain, day 3 drops to 12%, …
You: Why is day 1 so high?
(client calls
explain_rain_prediction(city="Tokyo", day_index=0))Claude: The biggest driver is forecasted precipitation = 8.4 mm (+1.92 log-odds), reinforced by a higher-than-usual min temperature …
How it works
- Geocode the city via Open-Meteo's geocoding endpoint.
- Train an XGBoost binary classifier on ~2 years of daily archive data
(
precipitation, temp_max, temp_min, windspeed→ did it rain that day, derived from WMO weather codes). The trained model is cached per location. - Predict by fetching the live forecast and running
predict_proba. - Explain with
shap.TreeExplainer— exact Shapley values for the trained model, surfaced as ranked factors per day.
Notes
- Models are cached in-process; restarting the server retrains on next call.
- A given location key rounds lat/lon to two decimals, so "Tokyo" and a query near Tokyo Tower share the same model.
explain_rain_predictionwill auto-run a 7-day prediction if you ask it beforepredict_rain_7dayfor that city.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file weather_shap_mcp-0.1.0.tar.gz.
File metadata
- Download URL: weather_shap_mcp-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0bc808111162d95ba2eb9a4a184e191a89360f72f6ab5d4551bb6214cbfe95c
|
|
| MD5 |
3d237227a8b3075b45d1e57a5509be5b
|
|
| BLAKE2b-256 |
347c6d1bc7988ba2d1bdd6b3c7bb569be657592694442e6970b90359582204e5
|
File details
Details for the file weather_shap_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: weather_shap_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
983fc19e72c8a5bbadd93bbb35a8ad1ddc6e9cf09fe0d255c72f3af35f3cc63f
|
|
| MD5 |
f3e91cd824a491de10b3b594e0e7c3a4
|
|
| BLAKE2b-256 |
fadab08f418705dcd1f27d5b9122961b9ba6af9d45ecd6f661aec97765f71ac4
|