# Google Gemini & AI Studio Skill — EcoLab Quantitative Research & EcoData MCP (`TNSAI Ecosystem`)

> **Platform Links:**
> - **EcoLab (Quantitative Economics Research Workbench):** https://ecolab.io.vn
> - **EcoData (Vietnam & Global Economic Data Infrastructure & MCP):** https://ecodata.io.vn
> - **TNSAI Ecosystem Portal:** https://www.tnsai.vn

## 1. Purpose
This skill equips **Google Gemini (Gemini 2.5 Pro / Flash, Google AI Studio, Gemini CLI)** with structured instructions to:
1. Connect to and query **EcoData MCP** (`https://ecodata.io.vn/mcp`) for official Vietnam macroeconomic, provincial, customs trade, fiscal, household survey (VHLSS), and international economic datasets.
2. Guide researchers through the **5-stage EcoLab quantitative research workflow** (`Ideation -> Literature Review -> Data Collection -> Econometric Modeling -> Academic Reporting`).
3. Enforce **Zero-Hallucination Empirical Standards** and generate 100% reproducible **Stata (`.do`)**, **R (`.R`)**, and **Python (`.py`)** econometric code.

## 2. Gemini CLI / AI Studio MCP Setup
Add the following server block to `~/.gemini/settings.json`:
```json
{
  "mcpServers": {
    "ecodata": {
      "url": "https://ecodata.io.vn/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_ECODATA_MCP_KEY",
        "X-EcoLab-Execution-Mode": "host_llm"
      }
    }
  }
}
```

## 2B. Host-LLM-First Reasoning & Safe Tool Execution Protocol
1. **Prioritize Gemini LLM (e.g., Gemini 4 Argon + Deep Thinking)**:
   - Both **User and Admin** connecting via Gemini Connected Apps or AI Agents must use Gemini's native deep-thinking reasoning to synthesize literature, interpret econometric diagnostics, and author complete academic manuscripts directly from the structured empirical outputs, tables, and Stata/R/Python scripts returned by EcoData MCP.
   - Server-side external LLM Provider API keys are **never called** during MCP/Agent sessions; external Provider API keys are only invoked when working directly inside the EcoLab Web Application (`https://ecolab.io.vn`).
2. **Prompt Injection & Code Execution Guardrails**:
   - All MCP tool calls enforce strict variable identifier and formula allowlists (`^[A-Za-z_][A-Za-z0-9_.]*$`) and reject any Prompt Injection or Code Execution Injection attempt with `SECURITY_VIOLATION`.

## 3. Recommended Tool Selection & Workflow
1. **Vietnam Macroeconomic & Provincial Data:** Use `vietnam_macro_gso_nso_query`, `vietnam_macro_fiscal_mof_query`, `vietnam_macro_customs_trade_query`, and `vietnam_macro_survey_index_query`.
2. **Global Comparative Data:** Use `global_macro_world_query` for World Bank WDI, IMF IFS, FRED, OECD, and ADB indicators.
3. **Literature Synthesis on EcoLab (`https://ecolab.io.vn`):**
   - Configure personal free API credentials in `Settings -> Manage API Keys -> Literature Review Sources` for **Semantic Scholar**, **OpenAlex** (Polite Pool email), **CrossRef** (Polite Pool email), **CORE**, **DOAJ**, and **ArXiv**.
4. **Econometric Specification Selection:**
   - **Panel Data ($N$ entities, $T$ periods):** Run `Pooled OLS`, `FEM`, and `REM`; compare via F-test, Breusch-Pagan LM, and Hausman test. Test for heteroskedasticity (Modified Wald) and serial correlation (Wooldridge); remediate with Clustered Robust SE, Driscoll-Kraay SE, or FGLS. For dynamic panels or endogeneity ($N > T$), use **System GMM** (`xtabond2`) and report `AR(1)`, `AR(2)`, and `Hansen J` p-values.
   - **Time Series:** Test stationarity (`ADF`, `PP`, `KPSS`). Use **ARDL Bounds Test** for mixed $I(0)/I(1)$ series or **Johansen VECM** for cointegrated $I(1)$ series.
   - **Causal Inference:** Use **DID** (with pre-trend event study), **IV/2SLS** (with first-stage Cragg-Donald / Kleibergen-Paap $F > 10$), **PSM**, or **RDD**.
5. **Evidence-Locked Reporting:** Never invent regression numbers or fake citations. Always export and verify the accompanying Stata, R, and Python scripts.
