# Agent MCP (New)

### Background

Use Tydro's MCP with any AI agent to query live rates, check positions, and execute onchain actions like supply, borrow, repay, and withdraw.

### Installation

```
npm install
npm run build
```

### Configuration

```
# Required: network (mainnet only for now)
export TYDRO_NETWORK=mainnet

# Optional: only needed for write operations (supply/borrow/repay/withdraw)
export PRIVATE_KEY=0x...
```

### Usage with Claude Desktop

```
{
  "mcpServers": {
    "tydro": {
      "command": "node",
      "args": ["/path/to/tydro-mcp/build/index.js"],
      "env": {
        "TYDRO_NETWORK": "mainnet",
        "PRIVATE_KEY": "0x..."
      }
    }
  }
}
```

### Tools

#### `get_reserve_data`

Get supply/borrow APYs, liquidity, and utilization for any reserve.

```
{ "asset": "WETH" }
{ "asset": "kBTC" }
{ "asset": "USDT0" }
```

#### `get_user_account`

Get overall health factor, collateral, debt, and borrow capacity.

```
{ "address": "0x..." }
```

#### `get_user_reserve`

Get a user's position for a specific asset (supplied, borrowed, collateral status).

```
{ "asset": "USDT0", "address": "0x..." }
```

#### `supply`

Deposit assets to earn interest. Auto-approves if needed.

```
{ "asset": "USDT0", "amount": "1000" }
{ "asset": "WETH",  "amount": "0.5"  }
```

#### `borrow`

Borrow against collateral. Variable rate only (stable rate deprecated in Aave V3).

```
{ "asset": "USDT0", "amount": "500" }
```

#### `repay`

Repay borrowed assets. Use `"max"` to repay full debt including accrued interest.

```
{ "asset": "USDT0", "amount": "500"  }
{ "asset": "WETH",  "amount": "max"  }
```

#### `withdraw`

Withdraw supplied assets. Use `"max"` to withdraw full aToken balance.

```
{ "asset": "USDT0", "amount": "max" }
```

### Notes

* **Read-only tools** (`get_reserve_data`, `get_user_account`, `get_user_reserve`) work without `PRIVATE_KEY`
* **Write tools** (`supply`, `borrow`, `repay`, `withdraw`) require `PRIVATE_KEY`
* Approvals are checked before sending — no redundant approval transactions
* Max repay/withdraw uses `type(uint256).max` — Aave caps at actual balance/debt
* Health factor warnings trigger below 1.5 (liquidation threshold is 1.0)
