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 分