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.
Metadata
Release files for weather-shap-mcp 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| weather_shap_mcp-0.1.0.tar.gz | 17.0 kB | Without provenance | Details for weather_shap_mcp-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| weather_shap_mcp-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for weather_shap_mcp-0.1.0-py3-none-any.whl |
Total release size: 37.1 kB
Release files / weather_shap_mcp-0.1.0.tar.gz
| Download URL | weather_shap_mcp-0.1.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0bc808111162d95ba2eb9a4a184e191a89360f72f6ab5d4551bb6214cbfe95c
|
|
BLAKE2b-256 checksum How to use checksums |
347c6d1bc7988ba2d1bdd6b3c7bb569be657592694442e6970b90359582204e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / weather_shap_mcp-0.1.0-py3-none-any.whl
| Download URL | weather_shap_mcp-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
983fc19e72c8a5bbadd93bbb35a8ad1ddc6e9cf09fe0d255c72f3af35f3cc63f
|
|
BLAKE2b-256 checksum How to use checksums |
fadab08f418705dcd1f27d5b9122961b9ba6af9d45ecd6f661aec97765f71ac4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for weather-shap-mcp 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.