defi-mcp
Reads Aave V3 reserves, wallet positions, and health-factor simulation data from Ethereum, enabling market comparison, account risk analysis, and what-if simulations.
Reads Aave V3 reserves, wallet positions, and health-factor simulation data from Optimism, enabling market comparison, account risk analysis, and what-if simulations.
Reads Aave V3 reserves, wallet positions, and health-factor simulation data from Polygon, enabling market comparison, account risk analysis, and what-if simulations.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@defi-mcp Check 0x1234…abcd Aave position on Base — how close am I to liquidation?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🏦 defi-mcp
Give your AI agent eyes on DeFi. An MCP server that lets Claude, Cursor or any MCP client read Aave V3 positions, compare markets and simulate the health-factor impact of an action — before anyone signs a transaction.
Why
LLMs are good at explaining risk but blind to on-chain state. defi-mcp gives an agent a small set of typed, read-only tools so it can answer questions like:
"How close am I to liquidation on Base?" "If I borrow 2,000 USDC more, what happens to my health factor?" "Where's the best stablecoin supply rate right now — Arbitrum or Optimism?"
No private keys, no signing, no transactions. The agent can look and simulate, the human decides.
Related MCP server: chain-data
Tools
Tool | What it does |
| All Aave V3 reserves on a chain: price, supply / borrow APY, LTV, liquidation threshold, utilization. Filter and sort. |
| A wallet's position: collateral, debt, health factor, risk label, net APY, per-asset breakdown, and how far each collateral price can drop before liquidation. |
| What-if for up to 10 chained actions ( |
| Native + ERC-20 balances (Aave reserve tokens) with USD values. |
Chains: Ethereum · Base · Arbitrum · Optimism · Polygon
Architecture
flowchart LR
A[Claude / Cursor / any MCP client] -- stdio --> S[defi-mcp]
S --> T[tools.ts<br/>zod-validated inputs]
T --> C[aave/client.ts<br/>viem multicall + 60s cache]
T --> M[math.ts<br/>HF, APY, liquidation drop<br/>pure + unit-tested]
C --> P[PoolAddressesProvider]
P --> Pool & Oracle & DataProviderOne address per chain. Only Aave's
PoolAddressesProvideris hard-coded; Pool, Oracle and DataProvider are resolved at runtime, so protocol upgrades don't break the server.Multicall everywhere. A full account read is ~3 RPC round-trips regardless of how many reserves a chain has.
Pure risk math. Health factor, APY compounding and liquidation-price math live in
math.tswith no network access and are covered by tests.
Quick start
git clone https://github.com/StanislavV01/defi-mcp && cd defi-mcp
npm install && npm run buildClaude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"defi": {
"command": "node",
"args": ["/absolute/path/to/defi-mcp/dist/index.js"],
"env": { "RPC_URL_BASE": "https://your-base-rpc" }
}
}
}Claude Code
claude mcp add defi -- node /absolute/path/to/defi-mcp/dist/index.jsTry it in the MCP Inspector
npm run inspectUse as a library
The same reads and risk math are exported for direct use, e.g. as tools in an AI SDK agent:
import { getAccount, toSimPositions, applyAction, computeHealth } from "defi-mcp";
const account = await getAccount("base", "0x…");
const after = applyAction(toSimPositions(account), "borrow", "USDC", 500);
console.log(computeHealth(after).healthFactor);npm install github:StanislavV01/defi-mcpConfiguration
Public RPCs work out of the box but are rate-limited. For real use set your own:
Variable | Chain |
| Ethereum |
| Base |
| Arbitrum |
| Optimism |
| Polygon |
Example
You: Check 0x… on Base. If I borrow 1,500 USDC, am I still safe?
The agent calls aave_account, then aave_simulate:
{
"before": { "healthFactor": 2.49, "debtUsd": 1000 },
"after": { "healthFactor": 0.996, "debtUsd": 2500 },
"risk": "LIQUIDATABLE",
"warning": "This sequence would make the position liquidatable — Aave would reject the borrow/withdraw."
}…and explains why, instead of guessing.
Development
npm run dev # run from source
npm test # unit tests (node:test)
npm run typecheckLimitations
Simulation does not model eMode, isolation mode or interest accrual — results are estimates, clearly labelled as such.
Read-only by design. Transaction building lives in the companion project DeFi Agent (coming next).
Roadmap
eMode-aware simulation
More protocols (Morpho, Compound V3)
prepare_transactiontool returning unsigned calldata for human signingPublish to npm (
npx defi-mcp)
License
MIT © Stanislav Verbytskyi
Available Tools
4 toolsaave_accountAave V3 accountB
Get a wallet's Aave V3 position: collateral, debt, health factor, risk level, net APY and per-asset breakdown. Health factor < 1 means the position can be liquidated.
Inputs: address (required), chain.
aave_marketsAave V3 marketsA
List Aave V3 reserves on a chain with price, supply/borrow APY, LTV, liquidation threshold and utilization. Use to compare where to supply or borrow. APYs are fractions (0.05 = 5%).
Inputs: chain, sortBy, symbols.
aave_simulateSimulate Aave actionA
What-if: estimate the health factor after a sequence of supply / withdraw / borrow / repay actions, without sending any transaction. Use before recommending an action to the user. Estimate ignores eMode and interest accrual; treat values close to 1 as unsafe.
Inputs: actions (required), address (required), chain.
wallet_balancesWallet balancesB
Native and ERC-20 balances of a wallet (tokens that are Aave reserves on the chain), with USD values.
Inputs: address (required), chain.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool targets a distinct facet: market data (aave_markets), a user's position (aave_account), hypothetical outcomes (aave_simulate), and raw wallet holdings (wallet_balances). The only mild overlap is aave_account vs wallet_balances, both returning per-asset holdings, but the descriptions make the Aave-position vs raw-balance boundary clear.
All four names are snake_case and follow a resource-prefix pattern (aave_*, wallet_*), which reads predictably. The verbs are implicit rather than an explicit verb_noun convention (e.g. 'aave_account' and 'aave_markets' are noun-only), a minor deviation from a strict pattern.
Four tools is on the lean side but each covers a genuinely different question (where to supply, what my position is, what would happen, what I hold). Nothing feels redundant or padded, though the set sits just below the typical 3-15 comfort range.
The read-only analytics lifecycle is coherent, but there is no path to actually execute or prepare supply/borrow/repay transactions, and no liquidation or historical-rate data. Despite the broad 'defi-mcp' name, coverage is limited to Aave V3, so agents hit a dead end when asked to act or to use another protocol.
Maintenance
Related MCP Connectors
Official Aave MCP for V3 and V4 markets, positions, governance, and transaction preparation.
Read-only on-chain intelligence for AI agents on Base: balances, tokens, gas, tx status.
Read-only on-chain intelligence for AI agents on Base: balances, tokens, gas, tx status.
Browse, deposit, withdraw & rebalance stablecoins on Aave, Morpho & Euler across major EVM chains.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to analyze Aave V3 positions on Ethereum, monitor health factors, identify liquidation opportunities, and query protocol data including collateral positions, debt composition, and real-time asset prices.81MIT
- AlicenseAqualityCmaintenanceEnables AI agents to fetch live multi-chain portfolio, token info, gas prices, and token prices across Ethereum, Base, Polygon, Arbitrum, and Optimism with a single call. No API key required.4MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to check DeFi liquidation risk levels for lending protocols like Aave, Compound, and Morpho, including at-risk positions, liquidation prices, current prices, and aggregate exposure. Access is pay-per-call via x402 micropayments with USDC on Base, requiring no API key or signup.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to monitor stablecoin yields, balances, and rewards across Aave, Morpho, and Euler on multiple EVM chains, and to deposit, withdraw, or rebalance positions via user-signed transactions.MIT