Defi Mcp

io.github.matiosera3-ops由 GitHub 帳號 matiosera3-ops 發布v0.1.6更新於 Oct 25, 2026

AI agent access to on-chain DeFi data on Polygon & Arbitrum: balances, positions, prices.

已驗證STDIO僅桌面資料庫金融

概覽

AI 產生的概覽

一個本機 MCP 伺服器,讓助理讀取 Polygon 與 Arbitrum 上的鏈上 DeFi 資料:代幣餘額、Aave v3 部位、Chainlink 價格與 Uniswap 兌換模擬。

可以做什麼
讀取 Polygon 與 Arbitrum 上支援代幣的錢包餘額,含原始數值與小數位。讀取錢包的 Aave v3 借貸部位:抵押品、債務、可借額度、LTV 與健康因子。從 Chainlink 價格來源讀取代幣目前美元價格。在四個費率級別上模擬 Uniswap v3 兌換,回傳最佳輸出量與 gas 估算,不送出交易。用簡單的 hello 工具檢查伺服器連線。
適用情境
適合讓助理回答關於 Polygon 或 Arbitrum 上錢包持倉、Aave v3 借貸健康狀況或代幣價格的問題,或在手動操作前預覽兌換的預期輸出。適合偏好直接讀取鏈上資料而非中心化 DeFi 資料 API 的使用者。
執行需求
以 Python 套件形式在本機執行(需 Python 3.10+),可透過 pip 安裝或以 uvx 執行。需要 RPC 服務商 API 金鑰,透過環境變數 POLYGON_RPC_URL(必要)與選用的 ARBITRUM_RPC_URL 設定;未設定時 Arbitrum 工具會優雅失敗。需要網路存取鏈。僅支援桌面用戶端。
安裝前請注意
需要在環境變數中提供 RPC 服務商憑證(POLYGON_RPC_URL、ARBITRUM_RPC_URL),請勿放入共用設定。工具為唯讀,兌換模擬不送出交易也不需要錢包,但結果僅是某一時刻的鏈上資料,不應視為財務建議。README 提到計畫推出獨立的託管雲端版本。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Defi Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

defi-mcp

An MCP (Model Context Protocol) server that gives AI agents direct, on-chain access to DeFi data on EVM chains — wallet balances, Aave v3 lending positions, and live token prices, with no centralized API in the middle.

Status: Live and functional. 5 tools available today, more on the roadmap.

Why

Most "DeFi + AI" integrations route through a centralized API that can rate-limit, paywall, or simply disappear. defi-mcp talks directly to the chain (via your own RPC provider) and to first-party oracles (Chainlink), so the data your AI agent gets is exactly what's on-chain — verifiable, and not dependent on a third-party API staying online.

Tools

get_token_balance

Reads the ERC-20 balance of any wallet address for a supported token.

Supported tokens:

  • Polygon: USDC, USDC.e, USDT, WETH, WMATIC, WBTC, DAI, AAVE
  • Arbitrum: USDC, USDC.e (bridged), USDT, WETH, WBTC, ARB
json
// get_token_balance(address="0x...", token_symbol="USDC", chain="polygon"){  "address": "0x...",  "token": "USDC",  "chain": "polygon",  "balance": 268.21,  "raw_balance": "268210000",  "decimals": 6}

get_aave_position

Reads a user's full Aave v3 lending/borrowing position: collateral, debt, available borrowing power, and health factor — straight from the Aave v3 Pool contract.

json
// get_aave_position(address="0x...", chain="polygon"){  "address": "0x...",  "chain": "polygon",  "total_collateral_usd": 969.78,  "total_debt_usd": 288.16,  "available_borrows_usd": 484.86,  "liquidation_threshold_pct": 82.79,  "ltv_pct": 79.71,  "health_factor": 2.79,  "has_active_position": true}

A health_factor below 1.0 means the position is at risk of liquidation. A null health factor means the user has no outstanding debt.

get_token_price

Reads the current USD price of a token directly from a Chainlink price feed — the same oracle DeFi protocols use internally, so the price is consistent with what get_aave_position reports.

Supported feeds:

  • Polygon: ETH/WETH, MATIC/WMATIC, WBTC, USDC, USDT
  • Arbitrum: ETH/WETH, WBTC, ARB, USDC, USDT
json
// get_token_price(token_symbol="WBTC", chain="polygon"){  "token": "WBTC",  "chain": "polygon",  "price_usd": 63835.77,  "decimals": 8,  "updated_at": 1782032816}

simulate_swap

Simulates a Uniswap v3 swap on-chain via the QuoterV2 contract — no transaction submitted, no wallet needed. Tries all four fee tiers (0.01%, 0.05%, 0.3%, 1%) and returns the best available output amount.

Supported tokens:

  • Polygon: USDC, USDC.e, USDT, WETH, WMATIC, WBTC, DAI, AAVE
  • Arbitrum: USDC, USDC.e (bridged), USDT, WETH, WBTC, ARB
json
// simulate_swap(token_in="WMATIC", token_out="USDC", amount_in=100.0, chain="polygon"){  "chain": "polygon",  "token_in": "WMATIC",  "token_out": "USDC",  "amount_in": 100.0,  "amount_out": 7.990547,  "fee_tier_used_pct": 0.05,  "fee_tier_used_bps": 500,  "gas_estimate": 122770}

If no pool exists for the pair at any fee tier, returns {"error": "No liquidity found for this pair on any fee tier"}.

hello

Simple connectivity check — confirms the MCP server is reachable and responding.

Supported chains

Chainget_token_balanceget_aave_positionget_token_pricesimulate_swap
Polygon✅✅✅✅
Arbitrum✅✅✅✅

Installation

Requires Python 3.10+ and an RPC provider API key (e.g. Alchemy, free tier works).

bash
pip install defi-mcp

Create a .env file in your working directory (see .env.example):

POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEYARBITRUM_RPC_URL=https://arb-mainnet.g.alchemy.com/v2/YOUR_API_KEY

Each chain only needs its RPC URL configured. Tools called with chain="arbitrum" will fail gracefully if ARBITRUM_RPC_URL is not set.

Usage with Claude Desktop

Add this to your Claude Desktop MCP config (claude_desktop_config.json):

json
{  "mcpServers": {    "defi-mcp": {      "command": "uvx",      "args": ["defi-mcp"],      "env": {        "POLYGON_RPC_URL": "https://polygon-mainnet.g.alchemy.com/v2/YOUR_API_KEY",        "ARBITRUM_RPC_URL": "https://arb-mainnet.g.alchemy.com/v2/YOUR_API_KEY"      }    }  }}

Restart Claude Desktop, and the tools above will be available to the model.

Testing locally

You can test the server directly with the official MCP Inspector:

bash
npx @modelcontextprotocol/inspector uvx defi-mcp

Roadmap

  • Track Uniswap v3 LP positions and impermanent loss
  • Monitor protocol TVLs
  • Additional chains (Ethereum, Base)
  • defi-mcp-cloud — hosted tier with MEV-specific tools, caching, and higher rate limits

Architecture

Open-core model: this repository (MIT licensed) covers standard on-chain read tools. A separate defi-mcp-cloud will offer a hosted version with MEV-related tools, request caching, and managed RPC access for users who don't want to run their own infrastructure.

Resources

  • defi-storage-cheatsheet — verified EVM storage slot layouts for Aave v3 and Uniswap v3, with web3.py snippets. Useful if you want to read on-chain state directly via eth_getStorageAt instead of calling view functions — the lower-level approach behind some of what this server does under the hood.

Contributing

Issues and PRs welcome. This is an early-stage project — feedback on what tools would actually be useful to you is especially valuable.

License

MIT

來源:README.md,提交 9f8a8ed

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.6最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分