--- title: Early Depression Detection MCP Agent emoji: ๐Ÿง  colorFrom: blue colorTo: purple sdk: gradio sdk_version: 6.2.0 app_file: app.py pinned: true tags: - mcp-in-action-track-consumer - sambanova - nebius - huggingface - depression-detection - mental-health - longformer - mcp - agents license: mit short_description: Agentic depression detection using Kimi K2/Llama 3 --- # ๐Ÿง  Early Depression Detection MCP Agent **Hackathon:** MCP 1st Birthday - Track 2: MCP in Action (Consumer) **Author:** Hassan Hassanzadeh Aliabadi | [LinkedIn](https://www.linkedin.com/in/hassanzh/) ## ๐Ÿ“น Demo Video [YOUTUBE LINK](https://youtu.be/U32a4QjXNz0) ## ๐ŸŽฏ Project Description This MCP-enabled agent detects depression risk from social media text by orchestrating specialized tools and LLM reasoning. It is built on Master's thesis research and is rigorously validated, achieving an F1-score of **0.7668** on the eRisk 2025 test data. ### ๐Ÿค– Multi-Provider Agent Architecture (MCP in Action) The agent operates in a two-tier structure: 1. **Tool Layer (The "Eyes"):** * **Tool:** `detect_depression_risk` (My Longformer model). * **Capability:** 4,096-token context window for long user timelines. * **Core Logic:** Implements thesis-derived thresholds (0.4 / 0.6) and classification based on behavioral patterns. 2. **Reasoning Layer (The "Brain"):** * **Purpose:** Provides empathetic, research-backed interpretation. * **Providers:** Uses **SambaNova** (Meta-Llama-3.3) and **Nebius** (Kimi K2) via the same `OpenAI` client for enhanced robustness and sponsor stacking. ## ๐Ÿงช Thesis Findings Integrated The agent doesn't just output a probability; it looks for and reports on specific linguistic biomarkers identified in my Master's Thesis: * **"Nocturnal Posting" & "High-Effort, Low-Frequency":** The primary behavioral signature of high-risk users. * **"Echo Chamber Interaction":** The signature of moderate-risk, supportive users engaging with high-risk topics (11.7x higher interaction rate). ## ๐Ÿ† Research Background Built on Master's thesis research at **University of Malaya**: - **Model:** `avtak/erisk-longformer-depression-v1`. - **Validation:** Rigorous 5-fold cross-validation. - **Data Augmentation:** Used Gemini 2.5 Flash Lite to balance the depressed class. ## โš ๏ธ Ethical Considerations This is a research tool, **not a medical diagnostic instrument**. **Crisis Resources:** - ๐Ÿ†˜ Crisis Text Line: Text HOME to 741741 (US) - ๐ŸŒ International: [befrienders.org](https://befrienders.org)