graph-aave-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 PaulieB14
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,265 @@
1
+ # graph-aave-mcp
2
+
3
+ <div align="center">
4
+
5
+ [![npm version](https://img.shields.io/npm/v/graph-aave-mcp)](https://www.npmjs.com/package/graph-aave-mcp)
6
+ [![MCP Registry](https://img.shields.io/badge/MCP%20Registry-published-blue)](https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.PaulieB14/graph-aave-mcp)
7
+ [![smithery badge](https://smithery.ai/badge/paulieb14/graph-aave-mcp)](https://smithery.ai/servers/paulieb14/graph-aave-mcp)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
9
+
10
+ <a href="https://glama.ai/mcp/servers/@PaulieB14/graph-aave-mcp">
11
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/@PaulieB14/graph-aave-mcp/badge" />
12
+ </a>
13
+
14
+ **MCP server for querying [AAVE](https://aave.com/) V2/V3 lending protocol and governance data via [The Graph](https://thegraph.com/) subgraphs.**
15
+
16
+ Exposes 14 tools and 5 guided prompts that any AI agent (Claude, Cursor, Copilot, etc.) can use to query lending markets, user positions, health factors, liquidations, flash loans, rate history, and AAVE governance — across **7 chains** (Ethereum, Base, Arbitrum, Polygon, Optimism, Avalanche, Fantom) via **11 subgraphs** covering both V2 and V3 deployments plus AAVE Governance V3.
17
+
18
+ </div>
19
+
20
+ > Published to the [MCP Registry](https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.PaulieB14/graph-aave-mcp) as `io.github.PaulieB14/graph-aave-mcp`
21
+
22
+ ## Supported Chains & Subgraphs
23
+
24
+ 7 chains, 11 subgraphs — some chains have both V2 (legacy) and V3 deployments tracked separately.
25
+
26
+ | Chain | Version | Subgraph ID | 30-Day Queries |
27
+ |-------|---------|-------------|----------------|
28
+ | Ethereum | V3 | `Cd2gEDVeqnjBn1hSeqFMtw8Q1IiyV9FYUZkLNRcLB7g` | 21,600,000 |
29
+ | Base | V3 | `GQFbb95cE6d8mV989mL5figjqGaKCQB3xqYrr1bRyXqF` | 5,618,153 |
30
+ | Arbitrum | V3 | `DLuE98kEb5pQNXAcKFQGQgfSQ57Xdou4jnVbAEqMfy3B` | 5,600,000 |
31
+ | Polygon | V3 | `Co2URyXjnxaw8WqxKyVHdirq9Ahhmsvcts4dMedAq211` | 2,000,000 |
32
+ | Optimism | V3 | `DSfLz8oQBUeU5atALgUFQKMTSYV9mZAVYp4noLSXAfvb` | 1,800,000 |
33
+ | Ethereum | V3 (alt) | `JCNWRypm7FYwV8fx5HhzZPSFaMxgkPuw4TnR3GpiB1zk` | 1,300,000 |
34
+ | Avalanche | V3 | `2h9woxy8RTjHu1HJsCEnmzpPHFArU33avmUh4f71JpVn` | 1,200,000 |
35
+ | **Ethereum** | **Governance V3** | `A7QMszgomC9cnnfpAcqZVLr2DffvkGNfimD8iUSMiurK` | 486,000 |
36
+ | Polygon | V2 | `H1Et77RZh3XEf27vkAmJyzgCME2RSFLtDS2f4PPW6CGp` | 215,830 |
37
+ | Avalanche | V2 | `EZvK18pMhwlCjxwesRLTg81fP33WnR6BnZe5Cvma3H1C` | 133,000 |
38
+ | Fantom | V3 | `6L1vPqyE3xvkzkWJh6wUKc1ABWYYps5HJahoxhnv2PJn` | 13,240 |
39
+
40
+ ## Prerequisites
41
+
42
+ You need a **free** Graph API key (takes ~2 minutes):
43
+
44
+ 1. Go to [The Graph Studio](https://thegraph.com/studio/)
45
+ 2. Connect your wallet (MetaMask, WalletConnect, etc.)
46
+ 3. Click **"API Keys"** in the sidebar and create one
47
+ 4. Free tier includes 100,000 queries/month
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ npm install -g graph-aave-mcp
53
+ ```
54
+
55
+ Or use directly with npx (no install needed):
56
+
57
+ ```bash
58
+ GRAPH_API_KEY=your-key npx graph-aave-mcp
59
+ ```
60
+
61
+ ## Configuration
62
+
63
+ ### Claude Desktop
64
+
65
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
66
+
67
+ ```json
68
+ {
69
+ "mcpServers": {
70
+ "graph-aave": {
71
+ "command": "npx",
72
+ "args": ["-y", "graph-aave-mcp"],
73
+ "env": {
74
+ "GRAPH_API_KEY": "your-api-key-here"
75
+ }
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### Claude Code (CLI)
82
+
83
+ ```bash
84
+ claude mcp add graph-aave -- npx -y graph-aave-mcp
85
+ ```
86
+
87
+ Then set the environment variable:
88
+ ```bash
89
+ export GRAPH_API_KEY=your-api-key-here
90
+ ```
91
+
92
+ ### Cursor
93
+
94
+ Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global):
95
+
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "graph-aave": {
100
+ "command": "npx",
101
+ "args": ["-y", "graph-aave-mcp"],
102
+ "env": {
103
+ "GRAPH_API_KEY": "your-api-key-here"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Other MCP Clients
111
+
112
+ Use stdio transport with `npx graph-aave-mcp` as the command and `GRAPH_API_KEY` as an environment variable.
113
+
114
+ ## Available Tools
115
+
116
+ ### Discovery
117
+
118
+ | Tool | Description |
119
+ |------|-------------|
120
+ | `list_aave_chains` | List all supported AAVE chains with subgraph IDs, versions, and 30-day query volumes |
121
+ | `get_aave_schema` | Full GraphQL schema introspection for any chain's subgraph |
122
+
123
+ ### Lending Markets
124
+
125
+ | Tool | Description |
126
+ |------|-------------|
127
+ | `get_aave_reserves` | All active lending markets on a chain — TVL, supply APY, borrow APY, LTV, liquidation thresholds |
128
+ | `get_aave_reserve` | Deep detail on one asset: lifetime stats, full config, token addresses |
129
+ | `get_reserve_rate_history` | Historical snapshots of APY, utilization rate, and TVL over time |
130
+
131
+ ### User Positions
132
+
133
+ | Tool | Description |
134
+ |------|-------------|
135
+ | `get_aave_user_position` | Wallet's supplied assets, borrowed assets, collateral flags, and e-mode category |
136
+ | `simulate_health_factor` | Simulate how a price change affects a user's health factor — e.g. "ETH drops 20%" |
137
+
138
+ ### Protocol Events
139
+
140
+ | Tool | Description |
141
+ |------|-------------|
142
+ | `get_recent_borrows` | Recent borrow events — filterable by user address or asset symbol |
143
+ | `get_recent_supplies` | Recent supply/deposit events (handles V2 `deposit` vs V3 `supply` automatically) |
144
+ | `get_aave_liquidations` | Recent liquidations — filterable by liquidated user or liquidator address |
145
+ | `get_aave_flash_loans` | Recent flash loans with amounts and fees paid |
146
+
147
+ ### Governance
148
+
149
+ | Tool | Description |
150
+ |------|-------------|
151
+ | `get_governance_proposals` | AAVE Governance V3 proposals with titles, states, for/against vote counts |
152
+ | `get_proposal_votes` | Individual voter breakdown for a specific proposal by voting power |
153
+
154
+ ### Advanced
155
+
156
+ | Tool | Description |
157
+ |------|-------------|
158
+ | `query_aave_subgraph` | Raw GraphQL escape hatch — execute any query against any chain |
159
+
160
+ ## Guided Prompts
161
+
162
+ Prompts are pre-built multi-step workflows that guide any AI agent through common AAVE analysis tasks:
163
+
164
+ | Prompt | Description |
165
+ |--------|-------------|
166
+ | `analyze_aave_user` | Full wallet analysis: supplied/borrowed assets, health factor, liquidation risk |
167
+ | `aave_chain_overview` | Protocol overview for a chain: top markets, rates, recent activity |
168
+ | `compare_aave_rates` | Compare supply/borrow APY for one asset across all supported chains |
169
+ | `aave_liquidation_analysis` | Analyze liquidation patterns, top liquidators, and at-risk markets |
170
+ | `aave_governance_overview` | Recent governance proposals, voting results, and active decisions |
171
+
172
+ ## Rate Conversion
173
+
174
+ AAVE stores interest rates in **RAY units** (27 decimal precision). To convert to human-readable APY:
175
+
176
+ ```
177
+ Supply APY % = liquidityRate / 1e27 * 100
178
+ Borrow APY % = variableBorrowRate / 1e27 * 100
179
+ ```
180
+
181
+ Token amounts are stored in **native token units**. To convert:
182
+ ```
183
+ Human amount = rawAmount / 10^decimals
184
+ ```
185
+
186
+ ## Health Factor
187
+
188
+ A user's health factor determines liquidation risk:
189
+
190
+ ```
191
+ HF = Σ(collateral_i × price_i × liquidationThreshold_i) / Σ(debt_i × price_i)
192
+ ```
193
+
194
+ - **HF > 1.0** — position is safe
195
+ - **HF = 1.0** — liquidation threshold reached
196
+ - **HF < 1.0** — position is liquidatable
197
+
198
+ Use `simulate_health_factor` to test how price movements affect a specific wallet's HF.
199
+
200
+ ## Example Prompts for AI Agents
201
+
202
+ Once connected, an AI agent can answer questions like:
203
+
204
+ **Markets & Rates**
205
+ - *"What are the top AAVE markets on Ethereum by TVL?"*
206
+ - *"What is the current USDC supply APY on Base?"*
207
+ - *"Compare WETH borrow rates across all AAVE V3 chains"*
208
+ - *"Which chain has the cheapest stablecoin borrowing right now?"*
209
+
210
+ **User Positions**
211
+ - *"Analyze the AAVE position for wallet 0x..."*
212
+ - *"What is the health factor for address 0x... on Arbitrum?"*
213
+ - *"Show me what 0x... has supplied and borrowed on Polygon"*
214
+ - *"If ETH drops 30%, will address 0x... get liquidated?"*
215
+
216
+ **Protocol Activity**
217
+ - *"Show me the last 20 liquidations on Ethereum AAVE"*
218
+ - *"Who are the most active liquidators on Arbitrum this week?"*
219
+ - *"What are the biggest flash loans on Base recently?"*
220
+ - *"Show me recent USDC borrows on Optimism"*
221
+
222
+ **Governance**
223
+ - *"What are the latest AAVE governance proposals?"*
224
+ - *"Is there anything currently up for a vote in AAVE governance?"*
225
+ - *"Show me who voted on proposal #185 and how"*
226
+ - *"What governance proposals have passed recently?"*
227
+
228
+ ## Development
229
+
230
+ ```bash
231
+ git clone https://github.com/PaulieB14/graph-aave-mcp.git
232
+ cd graph-aave-mcp
233
+ npm install
234
+ npm run build
235
+ GRAPH_API_KEY=your-key node build/index.js
236
+ ```
237
+
238
+ To test with a specific chain:
239
+ ```bash
240
+ # Start the server and query it with a GraphQL client or MCP inspector
241
+ GRAPH_API_KEY=your-key npx @modelcontextprotocol/inspector node build/index.js
242
+ ```
243
+
244
+ ## Schema Notes
245
+
246
+ **Lending subgraphs (V3)** use AAVE-native schema:
247
+ - `reserves` — individual asset markets
248
+ - `userReserves` — user positions per asset
249
+ - `borrows`, `supplies`, `repays` — transaction events
250
+ - `liquidationCalls` — liquidation events
251
+ - `flashLoans` — flash loan events
252
+ - `reserveParamsHistoryItems` — historical rate snapshots
253
+
254
+ **Lending subgraphs (V2)** use the same schema but with `deposits` instead of `supplies`.
255
+
256
+ **Governance subgraph** uses a separate schema:
257
+ - `proposals` — governance proposals with votes and payloads
258
+ - `proposalVotes_collection` — individual voter records
259
+ - `proposalMetadata_collection` — proposal titles and content
260
+ - `payloads` — on-chain execution payloads
261
+ - `votingPortals`, `votingConfigs` — governance configuration
262
+
263
+ ## License
264
+
265
+ MIT
@@ -0,0 +1,7 @@
1
+ export declare class GraphClientError extends Error {
2
+ readonly statusCode?: number | undefined;
3
+ readonly graphErrors?: unknown[] | undefined;
4
+ constructor(message: string, statusCode?: number | undefined, graphErrors?: unknown[] | undefined);
5
+ }
6
+ export declare function queryChain(subgraphId: string, query: string, variables?: Record<string, unknown>): Promise<unknown>;
7
+ //# sourceMappingURL=graphClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphClient.d.ts","sourceRoot":"","sources":["../src/graphClient.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;aAGvB,UAAU,CAAC,EAAE,MAAM;aACnB,WAAW,CAAC,EAAE,OAAO,EAAE;gBAFvC,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,WAAW,CAAC,EAAE,OAAO,EAAE,YAAA;CAK1C;AAID,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,OAAO,CAAC,CA2ClB"}
@@ -0,0 +1,38 @@
1
+ export class GraphClientError extends Error {
2
+ statusCode;
3
+ graphErrors;
4
+ constructor(message, statusCode, graphErrors) {
5
+ super(message);
6
+ this.statusCode = statusCode;
7
+ this.graphErrors = graphErrors;
8
+ this.name = "GraphClientError";
9
+ }
10
+ }
11
+ // Uses The Graph's subgraphs/id/ endpoint — always resolves to the latest deployment
12
+ // for the given subgraph ID, so no IPFS hash pinning is needed.
13
+ export async function queryChain(subgraphId, query, variables) {
14
+ const apiKey = process.env.GRAPH_API_KEY;
15
+ if (!apiKey) {
16
+ throw new GraphClientError("GRAPH_API_KEY environment variable is required. " +
17
+ "Get one free at https://thegraph.com/studio/apikeys/");
18
+ }
19
+ const url = `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/${subgraphId}`;
20
+ const body = { query };
21
+ if (variables && Object.keys(variables).length > 0) {
22
+ body.variables = variables;
23
+ }
24
+ const response = await fetch(url, {
25
+ method: "POST",
26
+ headers: { "Content-Type": "application/json" },
27
+ body: JSON.stringify(body),
28
+ });
29
+ if (!response.ok) {
30
+ throw new GraphClientError(`Graph API returned HTTP ${response.status}: ${response.statusText}`, response.status);
31
+ }
32
+ const json = (await response.json());
33
+ if (json.errors && json.errors.length > 0) {
34
+ throw new GraphClientError(`GraphQL errors: ${JSON.stringify(json.errors)}`, undefined, json.errors);
35
+ }
36
+ return json.data;
37
+ }
38
+ //# sourceMappingURL=graphClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphClient.js","sourceRoot":"","sources":["../src/graphClient.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAGvB;IACA;IAHlB,YACE,OAAe,EACC,UAAmB,EACnB,WAAuB;QAEvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,eAAU,GAAV,UAAU,CAAS;QACnB,gBAAW,GAAX,WAAW,CAAY;QAGvC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,qFAAqF;AACrF,gEAAgE;AAChE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,UAAkB,EAClB,KAAa,EACb,SAAmC;IAEnC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IACzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,gBAAgB,CACxB,kDAAkD;YAChD,sDAAsD,CACzD,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,oCAAoC,MAAM,iBAAiB,UAAU,EAAE,CAAC;IAEpF,MAAM,IAAI,GAA4B,EAAE,KAAK,EAAE,CAAC;IAChD,IAAI,SAAS,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,gBAAgB,CACxB,2BAA2B,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,EACpE,QAAQ,CAAC,MAAM,CAChB,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAGlC,CAAC;IAEF,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,gBAAgB,CACxB,mBAAmB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EAChD,SAAS,EACT,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}