aave-lending-mcp

Kimchiigu/aave-lending-mcp

3.2

If you are the rightful owner of aave-lending-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

Aave Lending MCP is an autonomous DeFi agent designed to manage lending positions on Aave V3 using natural language commands.

Tools
6
Resources
0
Prompts
0

🛡️ Aave Lending MCP & Agent

License: MIT Python 3.12 FastAPI Docker Azure Verisense

Aave Lending MCP is an MCP built for autonomous DeFi agent. It acts as an intelligent guardian for Aave V3 users, allowing them to manage lending positions, monitor health factors, and execute safe borrows using natural language commands.

Built on the Model Context Protocol (MCP) and fully compatible with the Agent2Agent (A2A) protocol.


🏗️ Architecture

This project follows a "Brain-Hands-Face" architecture to ensure security and non-custodial operation:

  • 🧠 The Brain (Verisense Agent): The AI reasoning engine (Homebrew/Ambient) that interprets user intent and decides which tools to call.
  • 🛠️ The Hands (Azure MCP): A Python-based MCP Server running on Azure Container Apps. It handles the "hard math" of DeFi—calculating health factors, checking balances, and building raw transaction data.
  • 👤 The Face (Mini App): A frontend interface where the user connects their wallet to sign the transactions prepared by the MCP.

⚡ Features

🏦 Aave V3 Tools (MCP)

These tools are exposed to the AI Agent via the MCP protocol:

  • supply_assets: Prepares a transaction to supply tokens (e.g., USDC, ETH) to Aave. Handles ERC20 approvals automatically.
  • borrow_assets: Prepares a borrow transaction. Safety Check: Automatically blocks borrowing if the resulting Health Factor would drop below 1.1.
  • repay_assets: Prepares a transaction to repay debt.
  • check_health_factor: Real-time risk analysis. Returns the user's current Health Factor and a "Safe/Risky" assessment.
  • check_balance: Scans the user's wallet for underlying assets, aTokens (supply), and vTokens (debt).
  • simulate_action: Dry-runs a supply or borrow action to predict the exact impact on the Health Factor before execution.

🌐 A2A & Verisense Integration

  • SSE Transport: Uses Server-Sent Events (SSE) for persistent, streamable connections required by Verisense.
  • Protocol Compliance: Implements the mcp.run() loop for full tool discovery and execution.
  • Non-Custodial: The MCP never asks for a private key. It returns transaction_data JSON for the user to sign via their own wallet.

🛠️ Tech Stack

  • Framework: Python 3.12, FastAPI (Async)
  • Protocol: Model Context Protocol (MCP) SDK
  • Web3: web3.py for EVM interaction
  • Infrastructure: Docker, Azure Container Apps (Serverless Consumption Plan)
  • Data Source: Aave V3 Smart Contracts (Base Sepolia)

🚀 Getting Started

Prerequisites

  • Docker & Docker Compose
  • Python 3.12+
  • Azure CLI (for deployment)
  • A Verisense Developer Account

1. Environment Setup

Create a .env file in the aave-concierge-api folder:

ALCHEMY_API_KEY="your_alchemy_key"
NETWORK="base-sepolia"

2. Run Locally (Docker)

We use Docker Compose to spin up the API and mount the configuration files correctly.

docker compose up --build

3. Run Locally (Python Manual)

If you prefer running without Docker

# 1. Update address files
cd aave-updater
npm install && npx ts-node update-addresses.ts

# 2. Start API
cd ../aave-concierge-api
python -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install -r requirements.txt
uvicorn main:app --reload --port 8000