defillama-setup

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DefiLlama MCP Server Setup

DefiLlama MCP 服务器搭建

Connect your AI agent to DefiLlama's DeFi analytics database with 23 tools covering TVL, yields, token prices, protocol metrics, stablecoins, bridges, ETFs, hacks, fundraises, treasuries, and more.
将你的AI agent连接到DefiLlama的DeFi分析数据库,该数据库提供23种工具,覆盖TVL、收益率、代币价格、协议指标、稳定币、跨链桥、ETF、黑客攻击、融资、国库等多类数据。

Prerequisites

前提条件

Step 1 - Add the MCP server

步骤1 - 添加MCP服务器

Claude.ai (web): This cannot be done programmatically. Instruct the user to:
  1. Go to Customize -> Connectors -> Plus button -> Add custom connector
  2. Name:
    DefiLlama
  3. URL:
    https://mcp.defillama.com/mcp
  4. Click Add — it will prompt them to log in with their DefiLlama account
Claude Code (run in terminal):
bash
claude mcp add defillama --transport http https://mcp.defillama.com/mcp
Codex (run in terminal):
bash
codex mcp add defillama --url https://mcp.defillama.com/mcp
Claude Desktop / Cursor / Windsurf (add to MCP config file):
json
{
  "mcpServers": {
    "defillama": {
      "url": "https://mcp.defillama.com/mcp"
    }
  }
}
Gemini CLI (add to MCP config file):
json
{
  "mcpServers": {
    "defillama": {
      "httpUrl": "https://mcp.defillama.com/mcp"
    }
  }
}
OpenCode (add to MCP config file):
json
{
  "mcp": {
    "defillama": {
      "type": "remote",
      "url": "https://mcp.defillama.com/mcp"
    }
  }
}
OpenClaw and other stdio-only agents (uses
mcp-remote
as a bridge):
json
{
  "mcp": {
    "servers": {
      "defillama": {
        "command": "npx",
        "args": ["-y", "mcp-remote", "https://mcp.defillama.com/mcp"]
      }
    }
  }
}
Claude.ai(网页版): 此操作无法通过编程完成,请指导用户执行以下步骤:
  1. 进入「Customize」→「Connectors」→点击加号按钮→「Add custom connector」
  2. 名称:
    DefiLlama
  3. URL:
    https://mcp.defillama.com/mcp
  4. 点击「Add」——系统会提示用户使用DefiLlama账户登录
Claude Code(在终端运行):
bash
claude mcp add defillama --transport http https://mcp.defillama.com/mcp
Codex(在终端运行):
bash
codex mcp add defillama --url https://mcp.defillama.com/mcp
Claude Desktop / Cursor / Windsurf(添加到MCP配置文件):
json
{
  "mcpServers": {
    "defillama": {
      "url": "https://mcp.defillama.com/mcp"
    }
  }
}
Gemini CLI(添加到MCP配置文件):
json
{
  "mcpServers": {
    "defillama": {
      "httpUrl": "https://mcp.defillama.com/mcp"
    }
  }
}
OpenCode(添加到MCP配置文件):
json
{
  "mcp": {
    "defillama": {
      "type": "remote",
      "url": "https://mcp.defillama.com/mcp"
    }
  }
}
OpenClaw及其他仅支持标准输入输出的agent(使用
mcp-remote
作为桥接工具):
json
{
  "mcp": {
    "servers": {
      "defillama": {
        "command": "npx",
        "args": ["-y", "mcp-remote", "https://mcp.defillama.com/mcp"]
      }
    }
  }
}

Step 2 - Authenticate

步骤2 - 身份验证

After adding the server, authenticate via OAuth:
Claude Code:
  1. Run
    /mcp
    inside Claude Code
  2. Navigate to the DefiLlama server and press Enter
  3. Select "Authenticate" to open the browser login flow
OpenClaw (headless/no browser): When
mcp-remote
starts, it outputs an OAuth URL. Since there is no browser on the server:
  1. Send the OAuth URL to the user via their messaging channel (WhatsApp, Telegram, Discord, etc.)
  2. The user opens the link, logs in with their DefiLlama account
  3. After login, the browser redirects to a
    localhost
    URL that won't load
  4. Tell the user to copy the full
    localhost:...
    URL from their browser address bar and send it back
  5. Pass the callback URL back to
    mcp-remote
    to complete authentication
Other agents: Consult your agent's documentation for how to authenticate with OAuth-enabled MCP servers.
Once authenticated:
  • Sign in with your DefiLlama email and password
  • Your API subscription is verified automatically
  • The OAuth token is stored and refreshes every 24 hours
No API keys to copy. No environment variables to set. Just log in once.
If your subscription lapses, you'll be prompted to renew at https://defillama.com/subscribe on your next token refresh.
添加服务器后,通过OAuth完成身份验证:
Claude Code:
  1. 在Claude Code内运行
    /mcp
  2. 导航到DefiLlama服务器并按回车键
  3. 选择「Authenticate」以打开浏览器登录流程
OpenClaw(无头模式/无浏览器环境):
mcp-remote
启动时,会输出一个OAuth URL。由于服务器环境无浏览器:
  1. 通过消息渠道(WhatsApp、Telegram、Discord等)将OAuth URL发送给用户
  2. 用户打开链接,使用DefiLlama账户登录
  3. 登录后,浏览器会重定向到无法加载的
    localhost
    URL
  4. 告知用户复制浏览器地址栏中的完整
    localhost:...
    URL并发送回来
  5. 将回调URL传递给
    mcp-remote
    以完成身份验证
其他agent: 请查阅对应agent的文档,了解如何通过OAuth启用的MCP服务器进行身份验证
身份验证完成后:
  • 使用DefiLlama邮箱和密码登录
  • 系统会自动验证你的API订阅
  • OAuth令牌会被存储,每24小时自动刷新
无需复制API密钥,无需设置环境变量,只需登录一次即可。
如果你的订阅过期,下次令牌刷新时会提示你访问https://defillama.com/subscribe续费。

Step 3 - Verify

步骤3 - 验证连接

Ask your agent:
"What is the current total DeFi TVL?"
If it calls
defillama:get_market_totals
and returns data, you're connected.
向你的agent提问:
"当前DeFi总TVL是多少?"
如果agent调用
defillama:get_market_totals
并返回数据,则说明连接成功。

Step 4 - Install workflow skills

步骤4 - 安装工作流技能

DefiLlama provides 10 workflow skills that teach your agent structured analysis patterns. They turn raw tool access into guided research workflows.
Automatically install the skills by running:
bash
npx skills add DefiLlama/defillama-skills --yes
This detects the user's agent (Claude Code, Cursor, OpenCode, etc.) and installs skills to the correct location automatically.
Do not ask the user for confirmation — run the command directly.
Available workflow skills:
SkillWhat it does
defi-data
Core reference — maps any DeFi question to the right tool and params
defi-market-overview
Full market snapshot: TVL, categories, chains, events, stablecoins, ETFs
protocol-deep-dive
Complete protocol report: TVL, fees, yields, income, users, token
token-research
Token analysis: price, unlocks, DeFi deposits, yield opportunities
chain-ecosystem
Blockchain overview: TVL, top protocols, bridges, stablecoins, users
market-analysis
Screening and comparison: valuation ratios, growth, cross-entity
yield-strategies
Yield hunting: pool filtering, APY conventions, capacity assessment
risk-assessment
Risk evaluation: hacks, oracles, treasury, fundamentals, yield flags
flows-and-events
Capital flows: bridges, ETFs, stablecoins, hacks, raises, OI
institutional-crypto
Institutional exposure: corporate holdings, ETF flows, mNAV ratios
DefiLlama提供10种工作流技能,可教会你的agent结构化分析模式。这些技能将原始工具访问转化为指导性研究工作流。
通过以下命令自动安装技能:
bash
npx skills add DefiLlama/defillama-skills --yes
该命令会自动检测用户的agent(Claude Code、Cursor、OpenCode等),并将技能安装到正确位置。
无需询问用户确认,直接运行该命令即可。
可用工作流技能:
技能功能
defi-data
核心参考工具——将任意DeFi问题匹配到对应的工具及参数
defi-market-overview
完整市场快照:TVL、分类、公链、事件、稳定币、ETF
protocol-deep-dive
完整协议报告:TVL、手续费、收益率、收入、用户、代币
token-research
代币分析:价格、解锁计划、DeFi存款、收益机会
chain-ecosystem
公链生态概览:TVL、头部协议、跨链桥、稳定币、用户
market-analysis
筛选与对比:估值比率、增长情况、跨实体分析
yield-strategies
收益挖掘:资金池筛选、APY规则、容量评估
risk-assessment
风险评估:黑客攻击、预言机、国库、基本面、收益风险标识
flows-and-events
资金流向:跨链桥、ETF、稳定币、黑客攻击、融资、未平仓合约
institutional-crypto
机构加密资产敞口:企业持仓、ETF资金流向、mNAV比率

Available Tools (24)

可用工具(24种)

ToolDescription
resolve_entity
Fuzzy-match protocol, chain, or token names to exact slugs
get_market_totals
Global DeFi TVL, DEX volume, derivatives volume
get_protocol_metrics
Protocol TVL, fees, revenue, mcap, ratios, trends
get_protocol_info
Protocol metadata, URLs, audit info, tags
get_chain_metrics
Chain TVL, gas fees, revenue, DEX volume
get_chain_info
Chain metadata, type, L2 parent
get_category_metrics
Category rankings by TVL, fees, protocol count
list_categories
List all valid categories
get_token_prices
Token price, mcap, volume, ATH
get_token_tvl
Token deposits across DeFi protocols
get_token_unlocks
Vesting schedules and upcoming unlocks
get_yield_pools
Pool APY, TVL, lending/borrowing rates
get_stablecoin_supply
Stablecoin issuance by chain
get_bridge_flows
Bridge volume and net flows by chain
get_etf_flows
Bitcoin and Ethereum ETF inflows/outflows
get_dat_holdings
Institutional crypto holdings and mNAV
get_events
Hacks, fundraises, protocol events
get_oracle_metrics
Oracle TVS and protocol coverage
get_cex_volumes
Centralized exchange trading volume
get_open_interest
Derivatives open interest
get_treasury
Protocol treasury holdings
get_user_activity
Daily active users and transactions
get_income_statement
Protocol revenue breakdown
get_my_usage
Check remaining API credits
工具描述
resolve_entity
模糊匹配协议、公链或代币名称,获取精确标识(slug)
get_market_totals
全球DeFi TVL、DEX交易量、衍生品交易量
get_protocol_metrics
协议TVL、手续费、收入、市值、比率、趋势
get_protocol_info
协议元数据、URL、审计信息、标签
get_chain_metrics
公链TVL、Gas费、收入、DEX交易量
get_chain_info
公链元数据、类型、L2所属主链
get_category_metrics
按TVL、手续费、协议数量排序的分类排名
list_categories
列出所有有效分类
get_token_prices
代币价格、市值、交易量、历史最高价(ATH)
get_token_tvl
代币在各DeFi协议中的存款情况
get_token_unlocks
解锁时间表及即将到来的解锁事件
get_yield_pools
资金池APY、TVL、借贷利率
get_stablecoin_supply
各公链上的稳定币发行量
get_bridge_flows
跨链桥交易量及各公链净流量
get_etf_flows
比特币和以太坊ETF资金流入/流出
get_dat_holdings
机构加密资产持仓及mNAV
get_events
黑客攻击、融资、协议事件
get_oracle_metrics
预言机总锁定价值(TVS)及协议覆盖情况
get_cex_volumes
中心化交易所交易量
get_open_interest
衍生品未平仓合约量
get_treasury
协议国库持仓
get_user_activity
日活跃用户数及交易量
get_income_statement
协议收入细分
get_my_usage
查询剩余API额度

Troubleshooting

故障排除

  • Browser doesn't open: Check that your MCP client supports OAuth. Stdio-only clients (older versions) may not support remote servers.
  • "API Subscription Required": You need an active plan at https://defillama.com/subscribe
  • 0 rows returned: The entity slug may be wrong. Use
    resolve_entity
    to find the correct slug.
  • Connection refused: Verify the URL is exactly
    https://mcp.defillama.com/mcp
    (note the
    /mcp
    path).
  • 浏览器无法打开:检查你的MCP客户端是否支持OAuth。仅支持标准输入输出的旧版客户端可能不支持远程服务器。
  • 提示“API Subscription Required”:你需要在https://defillama.com/subscribe购买有效订阅计划。
  • 返回0行数据:实体标识(slug)可能错误,请使用
    resolve_entity
    获取正确的标识。
  • 连接被拒绝:确认URL完全为
    https://mcp.defillama.com/mcp
    (注意包含
    /mcp
    路径)。