graph-lending-mcp
This server provides unified AI-friendly access to 40+ DeFi lending protocols across multiple blockchains via Messari's standardized subgraphs on The Graph.
Protocol & Market Data
List protocols — Browse all supported protocols with TVL, borrow totals, and network info; filter by network or schema version
Get protocol details — Full stats including revenue, user counts, transaction counts, and TVL
Get markets — Top markets for a protocol ordered by TVL or borrow balance, with rates, caps, and LTV thresholds
Get single market — Deep-dive into a specific market by contract address
Interest Rates
Get interest rates — Current supply and borrow APRs across all markets, filterable by side (LENDER/BORROWER) or rate type (VARIABLE/STABLE/FIXED)
Account & Positions
Get account summary — Open/closed position counts, deposit/borrow/liquidation history for a wallet
Get positions — Open positions for a wallet, filterable by side (COLLATERAL or BORROWER)
Transaction Events
Deposits, borrows, repays, withdrawals — filterable by market or account
Liquidations — with liquidator, liquidatee, collateral asset, and profit data
Flashloans — including fee amounts
Historical Snapshots & Metrics
Daily financials — Protocol-level daily snapshots of TVL, volume, and revenue (up to 365 days)
Market snapshots — Daily snapshots for a specific market including price, TVL, volume, and rates history
Usage metrics — Daily active user counts and transaction activity for a protocol
Cross-Protocol Analytics
Compare protocols — Side-by-side comparison of 2–20 protocols sorted by TVL, with graceful handling of individual endpoint failures
Top markets by TVL — Global top N markets across all registered protocols, optionally filtered by network
Advanced
Raw GraphQL queries — Execute custom GraphQL queries against any registered lending subgraph for exploratory or advanced use cases
Supports Ethereum, Polygon, Arbitrum, Avalanche, BSC, Optimism, Base, and more, with automatic handling of subgraph schema versions (v1.x, v2.x, v3.x).
Provides access to standardized lending protocol data on the Ethereum network, enabling the retrieval of TVL, revenue, interest rates, and account positions.
Offers a raw GraphQL interface to query Messari's standardized lending subgraphs on The Graph for advanced protocol and market analytics.
Enables querying of lending protocol data on the Optimism network, including cross-protocol comparisons of TVL, revenue, and usage metrics.
Allows interaction with lending protocols on the Polygon network to fetch detailed market data, snapshots, and transaction events.
graph-lending-mcp
MCP server that exposes unified AI-friendly tools over Messari's standardized lending subgraphs on The Graph.
One natural-language query → fan out across 40+ lending protocols on multiple chains → get back structured, comparable data.
Features
19 MCP tools covering protocols, markets, rates, positions, events, snapshots, and cross-protocol analytics
40+ lending protocols across Ethereum, Polygon, Arbitrum, Avalanche, BSC, Optimism, Base, and more
Cross-protocol comparison — compare TVL, revenue, users across any set of protocols in one call
Graceful failure handling — dead subgraphs don't crash queries; failures are reported alongside successes
Schema-version aware — automatically selects compatible queries for v1.x, v2.x, and v3.x subgraphs
Related MCP server: graph-polymarket-mcp
Tools
Tool | Description |
| List all registered protocols with live TVL data |
| Detailed protocol stats (TVL, revenue, users, pool counts) |
| List markets for a protocol, sorted by any field |
| Detailed single market data including rates, caps, and positions |
| Interest rates across all markets, with optional side/type filters |
| Account overview with position counts and activity |
| Open positions for an address, with optional side filter |
| Recent deposit events, filterable by market and account |
| Recent borrow events |
| Recent repay events |
| Recent withdrawal events |
| Recent liquidation events with profit data |
| Recent flashloan events |
| Daily financial snapshots (TVL, volume, revenue) |
| Daily market-level snapshots with rates and activity |
| Daily user activity and transaction counts |
| Side-by-side comparison of multiple protocols |
| Top markets across all protocols, optionally filtered by network |
| Raw GraphQL escape hatch for any registered subgraph |
Setup
Prerequisites
Node.js 18+
A Graph API key from The Graph Studio
Install & Build
git clone https://github.com/PaulieB14/graph-lending-mcp.git
cd graph-lending-mcp
npm install
npx tscConfigure in Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"graph-lending": {
"command": "node",
"args": ["/path/to/graph-lending-mcp/dist/index.js"],
"env": {
"GRAPH_API_KEY": "your-api-key-here"
}
}
}
}Architecture
src/
├── index.ts # MCP server entry — registers all 19 tools
├── registry.ts # Protocol → subgraph ID mapping (see SUBGRAPHS.md)
├── client.ts # GraphQL fetch with retry, timeout, fan-out
├── queries.ts # All GraphQL query constants
└── tools/
├── protocol.ts # list_protocols, get_protocol
├── markets.ts # get_markets, get_market
├── rates.ts # get_interest_rates
├── positions.ts # get_account, get_positions
├── events.ts # deposits, borrows, repays, withdrawals, liquidations, flashloans
├── snapshots.ts # daily_financials, market_snapshots, usage_metrics
└── cross.ts # compare_protocols, top_markets_by_tvlAll queries use Messari's standardized lending schema — same entities and fields across every protocol.
Subgraph Registry
See SUBGRAPHS.md for the full list of registered subgraphs with their status, network, schema version, and notes.
License
MIT
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/PaulieB14/graph-lending-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server