DeFi Rates MCP Server: Cross-Chain Lending Comparison
Compare real-time DeFi lending rates across 13+ protocols and chains with the MCP server to find best opportunities and calculate looping strategies.
npx -y @qingfeng/defi-rates-mcpOverview
The DeFi Rates MCP Server is a lightweight backend that collects, normalizes, and serves real-time lending and borrowing rates from multiple DeFi protocols and blockchains. It implements the Model Context Protocol (MCP) pattern to make normalized market data available to downstream models, agents, dashboards, or automated strategies. By aggregating rates from 13+ protocols and chains, it simplifies cross-protocol comparisons and enables programmatic calculation of looping (borrow-to-lend) strategies.
This server is useful when you need a single canonical view of supply/borrow APYs, utilization, and collateral parameters across heterogeneous lending markets. Typical consumers include trading bots, portfolio analytics, front-end rate explorers, and research workflows that require up-to-date, comparable rate data and simple strategy calculations.
Features
- Aggregates live lending/borrowing rates across 13+ DeFi protocols and multiple chains
- Normalizes disparate provider formats into a consistent JSON schema
- On-demand comparison API for best-supply / best-borrow opportunities
- Looping strategy calculator to estimate effective APY for repeated borrow→lend cycles
- Simple REST API and model-friendly outputs (MCP-compatible context)
- Configurable adapters for adding new protocols or chains
- Docker-ready for easy deployment and CI integration
Installation / Configuration
Clone the repo and install dependencies:
# If Node.js project
# Or if Python-based, use pip:
# pip install -r requirements.txt
Environment-driven configuration (example):
# Example environment variables
# seconds
Run locally:
# npm start
# or
Run with Docker:
Adapter configuration (example JSON snippet):
Place adapter config in config/adapters.json or set the path via CONFIG_PATH env var.
Available Resources
- GitHub repository: https://github.com/qingfeng/defi-rates-mcp (source, adapters, and tests)
- API base (local): http://localhost:3000
- Typical endpoints (see repo for exact routes and OpenAPI spec):
- GET /health — server status
- GET /rates — current normalized rates for all markets
- POST /compare — compare supplied asset across protocols
- POST /loop — estimates for looping strategies
- Adapter templates: add support for new protocols by implementing an adapter module (see adapters/README)
- Example clients: simple Python and TypeScript examples in examples/ folder
Response Schema (example)
The server normalizes provider outputs; a typical market object looks like:
| Field | Type | Description |
|---|---|---|
| asset | string | Token symbol (e.g., USDC) |
| chain | string | Chain identifier (ethereum, bsc, polygon) |
| protocol | string | Protocol name (Aave, Compound, etc.) |
| supplyApy | number | Current supply APY (percentage) |
| borrowApy | number | Current borrow APY (percentage) |
| utilization | number | Utilization ratio (0-1) |
| collateralFactor | number | Loan-to-value or borrow factor |
| timestamp | string | ISO timestamp of the source reading |
Use Cases
Find the best place to lend USDC right now
- Request: POST /compare with body { “asset”: “USDC”, “side”: “supply” }
- Result: server returns a ranked list of markets with supplyApy, chain, and protocol so you can pick the highest APY.
Compare borrowing cost across chains for a leveraged position
- Request: POST /compare with { “asset”: “ETH”, “side”: “borrow”, “amount”: 10 }
- Result: ranked borrow rates across protocols; feed the best borrow into a leverage simulator or execution agent.
Estimate a looping strategy (borrow → lend multiple times)
- Request: POST /loop with { “asset”: “DAI”, “initialAmount”: 1000, “loops”: 3, “collateralFactor”: 0.75, “supplyProtocol”: “aave”, “borrowProtocol”: “compound” }
- Result: estimated effective APY,