CropProphEU

Created By
DasClowna month ago
Overview

🌾 CropProphEU — EU Crop Intelligence MCP Server

CI Python ≥3.11 License: MIT GitHub stars Discussions Tests Latest Release

13 MCP Tools, 5 Crops, 26 EU Countries, 123 NUTS2 Regions — Yield forecasts, market values (€/ha), risk analysis, environmental risk scoring & portfolio optimization for European agriculture. Built for AI agents, by AI agents.

"How will wheat perform in Sachsen-Anhalt this year? What's my best €/ha allocation across 100 ha?"

pip install git+https://github.com/DasClown/CropProphEU.git

Features (13 MCP Tools)

#ToolWhat it doesV
1yield_and_valueYield + market value (€/ha) + plain-language summary (DE/EN)V4.6
2europe_yield_forecastPan-European RF forecast with Yield-at-Risk (P10/P50/P90) + NDVI correctionV4.3
3crop_forecastCurrent season: GDD, rain, soil moisture, drought index, frost warningsV4.0
4compare_regionsBatch-compare 20 regions × 5 crops with live market pricesV5.1
5portfolio_optimizerAI investment engine: budget → optimal allocation across regions × cropsV5.1e
6season_comparisonCompare this season to historical yearsV4.0
7region_healthAll crops for one region, single callV4.5
8weather_outlook16-day weather forecastV4.0
9climate_scenarioWhat-if: +2°C, -20% rain, etc.V4.4
10yield_forecastAnalog-year yield matching (DE-focused)V3.0
11list_regions123 NUTS2 regions across 26 countriesV4.2
12list_cropsCrop parameters (GDD base, season, frost sensitivity)V4.5
13environmental_riskNEW V5.4 — ERS (forest, erosion, storm, hail) + wild boar damage risk for DEV5.4

Quick Start

1. Install

pip install git+https://github.com/DasClown/CropProphEU.git

2. Use as MCP Server

CLI (stdio):

crop-mcp

Python API:

from crop_mcp import predict_europe_yield

result = predict_europe_yield("DE11", "DE", crop="wheat", gdd=3050, precip_mm=650)
print(f"Yield: {result['predicted_yield_t_ha']} t/ha")
print(f"Revenue: ~{result['predicted_yield_t_ha'] * 239:.0f} €/ha")

3. Claude Desktop / Cursor

{
  "mcpServers": {
    "crop": {
      "command": "python3",
      "args": ["-m", "crop_mcp.server"]
    }
  }
}

4. HTTP Server (Remote / Smithery)

pip install crop-mcp[http]
crop-mcp --http --port 8080

Connect via SSE: http://your-server:8080/sse

5. Docker

docker build -t crop-mcp .
docker run -p 8080:8080 crop-mcp crop-mcp --http --port 8080

Verified Crops — Data Integrity ✅

Every prediction traces to a verified Eurostat crop code. No hallucinations, no silent wrong-crop training.

CropEurostat CodeSamplesCountriesMAE (LOYO)
🌾 WheatC11001,60326 (🇪🇺+🇺🇦)11.5%0.87
🌽 Corn (Maize)C15001,79721 (🇪🇺+🇬🇧)11.6%0.72
🌿 BarleyC13001,88526 (🇪🇺+🇬🇧)11.2%0.85
🌻 RapeseedI11101,8252510.8%0.83
🌻 SunflowerI11201,2291716.1%0.74

⚠️ V5.1d Data Fix: Rapeseed + Sunflower were previously trained on RICE data (wrong Eurostat codes C2000/C2200). Now corrected to Industrial crop codes I1110/I1120. DE rapeseed prediction fell from 7.21t to 2.63t — real, not extrapolated.


Why CropProphEU?

CapabilityCropProphEUOpen-Meteo MCPGro Intelligence
Yield forecasts✅ 5 crops✅ $10K+/yr
Soil features✅ 11 properties
Yield-at-Risk (P10/P90)
Live market prices (€/ha)✅ CBOT + MATIF
Climate what-if
Frost warnings
NDVI satellite correction
Portfolio optimizer
Multi-language (DE/EN)
Environmental Risk✅ V5.4
PriceFreeFree$10K+/yr

Unique: Only free MCP server covering EU agriculture with soil → yield → market value → environmental risk → portfolio optimization in one pipeline.


V5.4 — Environmental Risk Score + Wildschaden 🌍🐗

FeatureBeschreibung
Environmental Risk ScoreKomposit aus Waldanteil, Maisfläche, Bodenerosion, Sturm- + Hagelrisiko → 🟢🟡🔴
Wildschaden DEDJV-Jagdstreckendaten + Waldrandindex + Maisflächenanteil → €/ha-Verlustschätzung
Ampel-System🟢 low (<35), 🟡 moderate (35-65), 🔴 high (≥65)
MCP Toolenvironmental_risk(region='DE26') → sofortige Analyse inkl. Wildschaden

Beispiel Maßbach (DE26 Unterfranken):

{
  "overall_risk": "🔴 high",
  "ers_level": "🟡 moderate",
  "wild_boar_risk": {"level": "🔴 high", "loss_eur_ha": 158},
  "management": ["Waldrandstreifen 3-6m", "Drückjagd Nov-Dez", "8-Tage-Anzeigefrist §36 BayJG"]
}

V5.4 — Testing & CI 🧪

MaßnahmeStatus
pytest16 Tests, alle passing (tests/test_crop_mcp.py)
CI (GitHub Actions)✅ Aktiv bei jedem Push — Badge im Header grün
Git LFS*.pkl + große .json via LFS (aus Git-Tree entfernt)

Run tests:

pip install -e ".[test]"
pytest tests/ -v

Model Accuracy

MetricValue
LOYO MAE (Wheat)0.599 t/ha (11.5%)
Forward Validation (Train ≤2022, Test 2023-24)0.794 t/ha (15.0%)
R² (LOYO)0.871
R² (Forward)0.628

Most accurate for core EU (DE, FR, BE, NL, AT, CZ) where training data is dense.

Per-Crop Performance (V5.2)

CropAlgorithmTop FeatureKey Insight
🌾 WheatRF 200 treessolar_kwh (35%)Nord/Süd gradient dominates
🌽 CornRF 200 treesclay_pct (42%)Maize is extremely soil-sensitive
🌿 BarleyRidgeclay_pct (27%)Best coverage of all crops
🌻 RapeseedRF 200 treescoarse_pct (28%)Corrected — now 1,825 real samples
🌻 SunflowerRidgesilt_pct (24%)17 countries (post-fix)

Live Market Prices

CropSource€/t (Mai 2026)Market
Wheat✅ CBOT ZW=F + MATIF premium239Euronext MATIF
Corn✅ CBOT ZC=F + MATIF premium189Euronext MATIF
Barley✅ Reference (AMI regional)190AMI regional exchanges
Rapeseed✅ Reference470Euronext MATIF (ECO)
Sunflower✅ Reference420ICE / Black Sea

Production costs are country- and crop-specific (V5.3+). See market_prices.pyCOUNTRY_PRODUCTION_COSTS (28 EU countries × 5 crops). Sources: FADN, KTBL, ARVALIS. Examples:

CountryWheatCornBarleyRapeseedSunflower
🇩🇪 DE650700600780650
🇫🇷 FR700650600750600
🇵🇱 PL550600500650550
🇷🇴 RO450500400550450
🇪🇸 ES600650550700

ℹ️ Full table: COUNTRY_PRODUCTION_COSTS dict in crop_mcp/market_prices.py


Data Sources

SourceDataAccess
EurostatCrop yields (apro_cpshr) — 25+ years, verified codesFree, no key
NASA POWERGDD, precip, solar, soil moistureFree, no rate limits
Open-Meteo16-day forecast, GDDFree, no key
SoilGrids v2 (ISRIC)11 properties: SOC, pH, N, CEC, clay, sand, silt, bdod (bulk density), cfvo (coarse fragments), AWC, coarseFree REST API
LUCAS Soil (ESDAC)Texture ~20K field points + coarse fragmentsFree download
Sentinel-2 NDVIVegetation index (Copernicus STAC + Planetary Computer fallback)Free, no auth
Yahoo FinanceLive CBOT wheat/corn futures, EUR/USDFree, no key

Zero API keys required — all sources are free and public.


Example Output

German (default):

Weizen – Region DEE0 (DE)
Ertrag: 7.35 t/ha (Spanne 6.50–8.20)
Temperatur: warm (2950°C Wärmesumme)
Niederschlag: ausreichend (480 mm)
Bodenfeuchte: feucht (48%)
Modellabweichung: ±11.5% (1603 Samples, 26 Länder)
Vergleich zu 2024: +0.15 t/ha (im Rahmen des Vorjahres)
Marktwert: 1.757 €/ha @ 239 €/t
Kosten: 650 €/ha → Deckungsbeitrag: 1.107 €/ha

English (with language="en"):

Wheat – Region DEE0 (DE)
Yield: 7.35 t/ha (range 6.50–8.20)
Temperature: warm (2950°C GDD)
...

Architecture

crop-mcp/
├── crop_mcp/
|├── server.py                 # 857 Zeilen — Pydantic-Modelle + Tool-Registry + MCP-Init
│   ├── tools/                  # **V5.4e** — Handler in logische Module aufgeteilt
│   │   ├── weather.py          # weather_outlook, crop_forecast, season_comparison, region_health
│   │   ├── yield_tools.py      # yield_forecast, europe_yield_forecast, yield_and_value, climate_scenario
│   │   ├── market.py           # compare_regions, portfolio_optimizer
│   │   ├── info.py             # list_regions, list_crops
│   │   ├── environmental.py    # environmental_risk (V5.4)
│   │   └── helpers.py          # Shared utilities (NDVI correction, frost, language)
│   ├── europe_model_api.py       # RF (200 trees) + Yield-at-Risk + NDVI correction
│   ├── environmental_risk.py     # V5.4 — ERS + Wildschaden DE
│   ├── ndvi_correction.py        # Sentinel-2 NDVI correction factor (±30%)
│   ├── market_prices.py          # Live CBOT/MATIF via Yahoo Finance
│   ├── feature_cache.py          # Sub-second historical queries
│   ├── simulate_yield.py         # Analog-year matching
│   ├── auto_update.py            # Monthly retrain cron
│   ├── core/regions.py           # 123 NUTS2 regions
│   └── sources/                  # Weather, soil, NDVI, Eurostat, FAOSTAT fetchers
├── models/                       # .pkl files ➜ download from Releases
├── data/                         # Training data ➜ download from Releases (or generated by build)
├── tests/                        # V5.4 — 16 pytest tests
├── .github/workflows/ci.yml      # V5.4 — CI workflow (lokal, benötigt PAT mit workflow-Scope für Push)
├── pyproject.toml
└── README.md

Key design principles:

  • No hallucination — every yield prediction traces to verified Eurostat data
  • Live prices — CBOT wheat/corn via Yahoo Finance, updated hourly
  • Self-updating — monthly cron rebuilds models with latest Eurostat data
  • Zero API keys — all data sources are free and public
  • AI-for-AI — built for agents, no dashboards

Building & Training

# Build training data (25 min per crop)
python3 build_europe.py --crop corn

# Train model (2 min)
python3 train_europe_fast.py --crop corn

# Auto-update monthly (cron: 1st of month at 06:00)

Commercial Use Cases

  • Agri-trading desks: "What's wheat worth in Picardie at current MATIF prices?"
  • Farm advisory: "How does this season compare to the last 5 years?"
  • Insurance / Risk: Yield-at-Risk (P10/P50/P90) per region + crop
  • EU policy analysis: Climate scenario impact on national yields
  • Investment: Portfolio optimizer for 100+ ha allocation decisions

🤝 Getting Help & Contributing

ChannelPurpose
💬 GitHub DiscussionsQuestions before coding, feature ideas, community chat
🐛 GitHub IssuesBug reports, confirmed feature requests
📖 CONTRIBUTING.mdDevelopment setup, branch naming, commit conventions, code style

New contributors welcome! See CONTRIBUTING.md to get started.


License

MIT — free to use, modify, and distribute.

Built with ❤️ for AI agents that need real, verifiable crop intelligence.

Project Info
Created At
a month ago
Updated At
a day ago
Author Name
DasClown
Star
-
Language
-
License
-
Category
Tags

Recommend Servers

View All
Traveltype Mcp Server

28 minutes ago