KrishiArtha-MCP
by 0xabhilok
README.md
# KrishiArtha-MCP (MandiPulse) ๐พ
### Autonomous Covariate Mandi Arbitrage, Weather-Spoilage Physics & Statutory Distress-Credit Engine
**A Multi-Agent Neuro-Symbolic Platform for Indian Agriculture**
[](https://krishiartha-mcp.streamlit.app/)
[](tests/)
[](https://github.com/0xabhilok/krishiartha-mcp/actions/workflows/ci.yml)
[-blue.svg)](#security-audit)
[](requirements.txt)
[](#submission-overview)
[](LICENSE)
---
<a name="submission-overview"></a>
## ๐ FORGE'26 Hackathon Submission Overview
- **Team:** INFINITE LOOP (IIIT Guwahati)
- **Members:** Abhilok Reddy Bellamkonda (Leader) & Nimmakayala Naga Venkata Shanmukha Sai Chandra
- **Chosen Track:** Climate, Resource Infrastructure & Global Supply Resilience *(with cross-cutting Digital Public Infrastructure & Governance impact)*
### ๐ฏ Fast Links for Judges & Evaluators
| Deliverable | Direct Link / Resource |
| :--- | :--- |
| **๐ Live Prototype (SSL)** | **[https://krishiartha-mcp.streamlit.app](https://krishiartha-mcp.streamlit.app)** *(24/7 Global Cloud Mirror)* |
| **๐ 1-Click Cloud Deploy** | **[Deploy to Streamlit Cloud](https://share.streamlit.io/deploy?repository=0xabhilok/krishiartha-mcp&branch=master&mainModule=frontend/app.py)** |
| **๐ World-Class Pitch Deck (PPTX)** | [docs/KrishiArtha_MCP_Pitch_Deck.pptx](docs/KrishiArtha_MCP_Pitch_Deck.pptx) *(8-Slide Native Morph Presentation)* |
| **๐ฅ๏ธ Interactive Web Slide Deck** | [docs/PITCH_DECK.html](docs/PITCH_DECK.html) *(Press `Ctrl+P` to export PDF)* |
| **๐ฌ 5-Minute Demo Video (MP4)** | **[Download & Watch Video](https://github.com/0xabhilok/krishiartha-mcp/releases/download/v1.0.0-demo/KrishiArtha_MCP_5Min_Demo.mp4)** / [Release Page](https://github.com/0xabhilok/krishiartha-mcp/releases/tag/v1.0.0-demo) |
| **๐ Video Walkthrough Script** | [docs/DEMO_VIDEO_SCRIPT.md](docs/DEMO_VIDEO_SCRIPT.md) |
| **๐ Official Portal Submission Copy** | [docs/PORTAL_SUBMISSION.md](docs/PORTAL_SUBMISSION.md) |
| **๐งช Pytest Verification Suite** | [tests/](tests/) *(70/70 Tests Passed in 13s)* |
---
## ๐ The Problem
Smallholder farmers and Farmer Producer Organizations (FPOs) across India lose **25% to 40%** of net crop value during unseasonal weather shifts and harvest gluts.
Existing government portals (Agmarknet 2.0, eNAM) fail because:
1. **Backward-Looking:** They display historical prices but cannot predict price crashes under approaching weather shocks.
2. **Ignorant of Spoilage:** They assume 0% crop loss, ignoring that hauling perishable commodities 200+ km under 32ยฐC heat and 85% humidity in open tarp trucks causes rapid biological rot ($Q_{10}$ microbial decay).
3. **Zero Safety Net:** When local prices crash below production costs, portals offer zero actionable financial recourse.
---
## ๐ก The Solution: Neuro-Symbolic Multi-Agent Architecture
KrishiArtha-MCP combines foundation time-series AI with thermodynamic transit decay physics and statutory warehouse pledge financing into an autonomous 4-node LangGraph pipeline:
```mermaid
flowchart TB
subgraph Client["Frontend Edge (Streamlit / Bhashini)"]
Voice["Bhashini Multilingual Speech / Audio Triggers (Marathi, Hindi, Telugu, English)"]
UI["Mission Control Cockpit & 3-Column Arbitrage Matrix"]
ShockSlider["What-If Unseasonal Rainfall Shock Slider (+0mm to +100mm)"]
end
subgraph FastMCP["FastMCP Ingestion & Telemetry"]
MandiAPI["mandi-api.onrender.com (Live APMC Prices)"]
WeatherAPI["Open-Meteo API (7-Day Rain/Temp Covariates)"]
OSRMAPI["OSRM Routing (Highway Distance & Geometry)"]
end
subgraph CoreEngine["Quantitative Foundation Models & Physics"]
Chronos["amazon/chronos-2 (P10, P50, P90 Quantiles)"]
Spoilage["Arrhenius Q10 Decay + Round-Trip Diesel Math"]
end
subgraph Governance["LangGraph v1.2.18 Stateful Orchestration"]
Node1["Node 1: quant_arbitrage"]
Node2["Node 2: policy_graphrag (LightRAG Hybrid Mode)"]
Gate["Node 3: human_approval_gate (interrupt() Consent Gate)"]
Node4["Node 4: execute_enwr_browser (Playwright WDRA Agent)"]
end
Voice --> UI
UI --> Node1
Node1 <--> FastMCP
FastMCP --> MandiAPI & WeatherAPI & OSRMAPI
Node1 <--> CoreEngine
CoreEngine --> Chronos & Spoilage
Node1 --> Node2
Node2 --> Gate
Gate -- "Command(resume=True)" --> Node4
Node4 --> UI
```
---
## ๐ฌ Mathematical & Physical Defensibility
### 1. Arrhenius $Q_{10}$ Biological Transit Decay
$$k(T_{\text{amb}}, RH) = k_{\text{base}} \cdot \left(Q_{10}\right)^{\frac{T_{\text{amb}} - 20.0}{10.0}} \cdot \left(1 + \alpha_{\text{hum}} \cdot \max\left(0, \frac{RH - 70}{100}\right)\right)$$
- $Q_{10} = 2.2$, $k_{\text{base}} = 0.0065$ (Tomato), $\alpha_{\text{hum}} = 1.5$.
- Total transit time: $t_{\text{transit}} = t_{\text{duration}} + 2.5\text{h}$ mandatory APMC unloading queue buffer.
- Spoilage loss fraction: $L = 1 - \exp\left(-k \cdot t_{\text{transit}}\right)$.
### 2. Freight & Net Realizable Price ($\text{NRP}$)
$$C_{\text{transport}} = 2 \cdot d_{\text{km}} \cdot โน22/\text{km} + Q \cdot โน35/\text{qtl}$$
$$\text{NRP}_m = \left[ P_{50} \cdot (1 - L) \cdot (1 - \gamma_{\text{APMC}}) \right] - \frac{C_{\text{transport}}}{Q}$$
---
## ๐ The 3-Column Financial Arbitrage Matrix (Nashik 50 qtl Lot)
| Metric | Option A: Local Panic Sale | Option B: Long-Distance Surat Transit | Option C: KrishiArtha Recommended (WDRA e-NWR) |
| :--- | :--- | :--- | :--- |
| **Market Destination** | Pimpalgaon APMC (Local) | Surat APMC (234 km) | MSWC Scientific Cold Storage, Ozar (14.2 km) |
| **Nominal Quoted Price** | โน900 / quintal | โน1,350 / quintal | Rebound: โน1,480 / quintal (10 days post-glut) |
| **$Q_{10}$ Transit Spoilage** | โน945 (2.1% loss) | **โน12,420 (18.4% rotting loss)** | โน0 (Accredited cold storage fiduciary guarantee) |
| **Round-Trip Diesel Freight** | โน1,925 | โน6,800 ($โน22/\text{km}$ round-trip) | โน750 (Local mini-truck transfer) |
| **Instant Liquidity** | โน45,000 | โน48,280 | **โน33,750 Immediate Cash (75% LTV @ 4% net interest)** |
| **Final Net Take-Home** | **โน45,000** | **โน48,280** | **โน68,400 Net** |
| **Net Arbitrage Gain** | Baseline | +โน3,280 (+7.3%) | **+โน23,400 (+52.0% Income Surge)** |
---
<a name="security-audit"></a>
## ๐ก๏ธ Security Audit (AgentShield)
Audited via `npx ecc-agentshield scan`:
- **Grade:** **A (100/100)**
- **Findings:** 0 Critical, 0 High, 0 Medium, 0 Low, 0 Info
- **Secrets:** 100/100 (Zero exposed API keys or tokens)
- **Permissions:** 100/100 (Safe sandbox compliance)
---
## โก Quick Start
### 1. Clone & Install Dependencies
```bash
git clone https://github.com/0xabhilok/krishiartha-mcp.git
cd krishiartha-mcp
pip install -r requirements.txt
```
### 2. Run the Full Test Suite
```bash
# Run all 70 unit tests in offline stage safe mode
pytest
```
### 3. Launch the Mission Control Cockpit
```bash
streamlit run frontend/app.py
```
Open **[http://localhost:8501](http://localhost:8501)** in your browser, or visit the live deployment at **[https://krishiartha-mcp.streamlit.app](https://krishiartha-mcp.streamlit.app)**.
---
## ๐ Project Organization
- `contracts/schemas.py`: Frozen Pydantic v2 schemas.
- `mcp_server/`: FastMCP server, Chronos-2 quantiles, $Q_{10}$ transit spoilage math.
- `policy_rag/`: LightRAG hybrid knowledge graph & NABARD/WDRA circular citations.
- `orchestrator/`: 4-node LangGraph StateGraph, `interrupt()` consent gate, Playwright WDRA agent.
- `frontend/`: Streamlit dashboard, Bhashini multilingual speech triggers, 3-column matrix.
- `data/offline_snapshots/`: Air-gapped deterministic stage snapshot for zero-fail live demos.
- `docs/`: 8-Slide World-Class Pitch Deck (Native Morph), 5-Minute Video Walkthrough Script, and Submission Copy.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues