graph-lending-mcp
graph-lending-mcp
The Graph의 Messari 표준화 대출 서브그래프를 통해 AI 친화적인 통합 도구를 제공하는 MCP 서버입니다.
자연어 쿼리 하나로 15개 체인에 걸쳐 40개 이상의 대출 프로토콜에 분산 요청을 보내고, 구조화된 비교 가능한 데이터를 반환받습니다.
기능
19개의 MCP 도구: 프로토콜, 시장, 이자율, 포지션, 이벤트, 스냅샷 및 프로토콜 간 분석 지원
90개의 서브그래프 배포: 15개 체인(Ethereum, Polygon, Arbitrum, Avalanche, BSC, Optimism, Base, Scroll, Fantom, Gnosis, Moonbeam 등)의 40개 이상 대출 프로토콜 지원
프로토콜 간 비교: 한 번의 호출로 여러 프로토콜의 TVL, 수익, 사용자 수 비교
우아한 오류 처리: 서브그래프가 중단되어도 쿼리가 충돌하지 않으며, 성공한 결과와 함께 오류가 보고됨
스키마 버전 인식: v1.x, v2.x, v3.x 서브그래프에 호환되는 쿼리를 자동으로 선택
Related MCP server: Stacks AI MCP Server
도구
도구 | 설명 |
| 실시간 TVL 데이터와 함께 등록된 모든 프로토콜 나열 |
| 상세 프로토콜 통계 (TVL, 수익, 사용자, 풀 개수) |
| 특정 필드로 정렬된 프로토콜의 시장 목록 |
| 이자율, 한도, 포지션을 포함한 단일 시장 상세 데이터 |
| 모든 시장의 이자율 (측면/유형 필터 옵션 포함) |
| 포지션 수와 활동을 포함한 계정 개요 |
| 주소에 대한 오픈 포지션 (측면 필터 옵션 포함) |
| 시장 및 계정별로 필터링 가능한 최근 예치 이벤트 |
| 최근 대출 이벤트 |
| 최근 상환 이벤트 |
| 최근 인출 이벤트 |
| 수익 데이터를 포함한 최근 청산 이벤트 |
| 최근 플래시론 이벤트 |
| 일일 재무 스냅샷 (TVL, 거래량, 수익) |
| 이자율과 활동을 포함한 일일 시장 수준 스냅샷 |
| 일일 사용자 활동 및 거래 횟수 |
| 여러 프로토콜의 나란히 비교 |
| 모든 프로토콜의 상위 시장 (네트워크별 필터링 옵션) |
| 등록된 모든 서브그래프를 위한 원시 GraphQL 탈출구 |
설정
사전 요구 사항
Node.js 18+
The Graph Studio에서 발급받은 Graph API 키
빠른 시작 (npm)
{
"mcpServers": {
"graph-lending": {
"command": "npx",
"args": ["graph-lending-mcp"],
"env": {
"GRAPH_API_KEY": "your-api-key-here"
}
}
}
}소스에서 설치
git clone https://github.com/PaulieB14/graph-lending-mcp.git
cd graph-lending-mcp
npm install
npx tsc그 후 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"
}
}
}
}아키텍처
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_tvl모든 쿼리는 Messari의 표준화 대출 스키마를 사용하며, 모든 프로토콜에서 동일한 엔티티와 필드를 사용합니다.
서브그래프 레지스트리
상태, 네트워크, 스키마 버전 및 참고 사항을 포함한 90개의 등록된 서브그래프 배포 전체 목록은 SUBGRAPHS.md를 참조하세요.
라이선스
MIT
Available Tools
19 toolscompare_protocolsARead-only
Compare multiple protocols side-by-side: TVL, deposits, borrows, revenue, users, pools. Sorted by TVL. Tolerates individual endpoint failures.
Inputs: protocols (required).
get_accountARead-only
Account summary for a wallet address: open/closed position counts, deposit/borrow/liquidation activity, and list of current open positions.
Inputs: address (required), protocol (required), network.
get_borrowsBRead-only
Recent borrow events. Optionally filter by market ID and/or account address.
Inputs: protocol (required), first, account, network, +1 more.
get_daily_financialsARead-only
Protocol-level daily snapshots: TVL, deposit/borrow/liquidation volume, and revenue breakdown (supply-side vs protocol-side). Returns last N days.
Inputs: protocol (required), days, network.
get_depositsARead-only
Recent deposit events. Optionally filter by market ID and/or account address.
Inputs: protocol (required), first, account, network, +1 more.
get_flashloansARead-only
Recent flashloan events including fee amounts. Only available for v3+ schema protocols (e.g. aave-v3, compound-v3, spark-lend).
Inputs: protocol (required), first, network.
get_interest_ratesARead-only
Current supply and borrow APRs across all markets in a protocol. Optionally filter by side (LENDER/BORROWER) or rate type (VARIABLE/STABLE/FIXED).
Inputs: protocol (required), side, type, network.
get_liquidationsARead-only
Recent liquidation events with liquidator, liquidatee, collateral asset, and profit amounts. Optionally filter by market.
Inputs: protocol (required), first, network, market_id.
get_marketARead-only
Deep-dive on a single market by its on-chain contract address. Returns balances, cumulative stats, position counts, risk parameters, rates, and rewards. Get market IDs from get_markets first.
Inputs: protocol (required), market_id (required), network.
get_marketsARead-only
List markets (lending pools) for a protocol, ordered by TVL or borrows. Returns token, rates, caps, LTV thresholds, and reward info.
Inputs: protocol (required), first, network, order_by.
get_market_snapshotsARead-only
Daily snapshots for a specific market: token price, TVL, volume, revenue, rates history, and active user counts.
Inputs: protocol (required), market_id (required), days, network.
get_positionsARead-only
Open positions for a wallet address with balances, market prices, and activity counts. Optionally filter by side.
Inputs: address (required), protocol (required), side, first, +1 more.
get_protocolARead-only
Detailed stats for a single lending protocol: TVL, deposits, borrows, revenue, user counts, transaction counts, pool counts, position counts.
Inputs: protocol (required), network.
get_repaysARead-only
Recent repay events. Optionally filter by market ID and/or account address.
Inputs: protocol (required), first, account, network, +1 more.
get_usage_metricsBRead-only
Daily active user counts and transaction activity breakdown (deposits, borrows, repays, liquidations) for a protocol.
Inputs: protocol (required), days, network.
get_withdrawalsARead-only
Recent withdrawal events. Optionally filter by market ID and/or account address.
Inputs: protocol (required), first, account, network, +1 more.
list_protocolsARead-only
List all supported lending protocols with live TVL, deposit/borrow totals, pool counts, and user counts. Fans out to all registered subgraph endpoints. Optionally filter by network or schema version.
Inputs: network, schema_version.
query_subgraphARead-only
Execute a raw GraphQL query against any registered lending subgraph. Use for custom filters, uncommon fields, or exploratory queries. All subgraphs use the Messari standardized lending schema with entities: lendingProtocols, markets, accounts, positions, deposits, borrows, repays, withdraws, liquidates, flashloans, financialsDailySnapshots, marketDailySnapshots, usageMetricsDailySnapshots.
Inputs: query (required), protocol (required), network, variables.
top_markets_by_tvlARead-only
Global top N markets by TVL across ALL registered lending protocols. Fans out to every endpoint. Optionally filter by network.
Inputs: first, network.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 19 tools
Each tool has a clearly distinct purpose, targeting specific entities (protocols, markets, events, accounts) or actions (list, get, compare, query). There is no ambiguity; even similar-sounding tools like get_market and get_markets are differentiated by singular vs plural and depth of data.
All tools follow a consistent verb_noun pattern using snake_case (e.g., get_markets, list_protocols, query_subgraph). Minor deviations like compare_protocols and top_markets_by_tvl still adhere to the same pattern, ensuring predictability.
19 tools is on the higher end but appropriate for the comprehensive scope of lending protocol data. Each tool covers a specific aspect (protocols, markets, events, analytics) without redundancy, justifying the count.
The tool set provides full coverage for a read-only lending data API: protocol listing and details, market analysis, event history (deposits, borrows, etc.), account positions, aggregated financials, usage metrics, interest rates, comparisons, and raw GraphQL access. No obvious gaps for the intended domain.
Maintenance
Related MCP Connectors
MCP server connecting AI agents to non-custodial staking data across 130+ networks.
Pay-per-call DeFi and macro intel for AI agents. x402 USDC tools via streamable HTTP /api/mcp.
The Graph MCP — indexed blockchain data via subgraph GraphQL queries
DefiLlama MCP — DeFi analytics from DefiLlama (free, no auth)
Related MCP Servers
- AlicenseNot gradedqualityFmaintenanceOfficial MCP server that turns The Graph’s Token API into a plug-and-play web3 data tool. Exposes ERC-20 & NFT metadata, balances, transfers, top-holder stats, prices, and more, allowing LLMs to run SQL queries on structured and indexed blockchain data.2Apache 2.0
- AlicenseNot gradedqualityDmaintenanceA comprehensive MCP server providing unified access to over 144 tools for lending, trading, and staking across six major DeFi protocols on the Stacks Bitcoin Layer 2. It enables AI agents to perform complex blockchain operations and interact with the DeFi ecosystem using natural language commands.3MIT
- AlicenseAqualityDmaintenanceAn MCP server that powers AI agents with indexed blockchain data from The Graph.3MIT
- AlicenseBqualityCmaintenanceAn MCP server that enables querying Polymarket prediction market data through The Graph subgraphs. It provides tools for accessing market stats, trader P\&L, user positions, and orderbook activity using AI agents.35101 npm4MIT