@missionsquad/mcp-defillama 1.0.0 → 1.2.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/README.md +82 -23
- package/dist/clients/defillama.client.d.ts +120 -29
- package/dist/clients/defillama.client.js +208 -159
- package/dist/clients/defillama.client.js.map +1 -1
- package/dist/clients/defillama.mock.client.d.ts +6 -2
- package/dist/clients/defillama.mock.client.js +6 -2
- package/dist/clients/defillama.mock.client.js.map +1 -1
- package/dist/handlers/datetime.d.ts +18 -0
- package/dist/handlers/datetime.js +92 -0
- package/dist/handlers/datetime.js.map +1 -0
- package/dist/handlers/defillama.d.ts +25 -1
- package/dist/handlers/defillama.js +298 -22
- package/dist/handlers/defillama.js.map +1 -1
- package/dist/handlers/defillama.types.d.ts +113 -6
- package/dist/handlers/defillama.types.js +3 -0
- package/dist/handlers/defillama.types.js.map +1 -1
- package/dist/handlers/transform.d.ts +34 -0
- package/dist/handlers/transform.js +241 -0
- package/dist/handlers/transform.js.map +1 -0
- package/dist/handlers/utils.d.ts +8 -0
- package/dist/handlers/utils.js +16 -0
- package/dist/handlers/utils.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tools.d.ts +475 -7
- package/dist/tools.js +393 -24
- package/dist/tools.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,37 +1,96 @@
|
|
|
1
1
|
# MCP Server for DefiLlama
|
|
2
2
|
|
|
3
|
-
A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that gives MCP-compatible clients (Claude Desktop, etc.) access to DeFi data via the [DefiLlama](https://defillama.com) API. It
|
|
3
|
+
A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that gives MCP-compatible clients (Claude Desktop, etc.) access to DeFi data via the [DefiLlama](https://defillama.com) API. It covers all 31 endpoints of DefiLlama's free, keyless API — protocol and chain TVL, token prices, stablecoins, yield pools, DEX and options volume, perps open interest, and fees/revenue.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Tools
|
|
5
|
+
No API key is required. The server routes each request to DefiLlama's category-specific hosts (`api.llama.fi`, `coins.llama.fi`, `stablecoins.llama.fi`, `yields.llama.fi`) automatically.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Protocol Data
|
|
7
|
+
Published on npm as [`@missionsquad/mcp-defillama`](https://www.npmjs.com/package/@missionsquad/mcp-defillama).
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
- `defillama_get_protocol_tvl` — Get TVL data for a specific protocol.
|
|
15
|
-
- `protocol` (string, required): protocol slug, e.g. `aave`.
|
|
9
|
+
## Conventions
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
These apply to every tool:
|
|
18
12
|
|
|
19
|
-
- `
|
|
20
|
-
|
|
13
|
+
- **Dates are human-readable.** Any datetime parameter accepts a 12-hour string such as `06/15/2024 03:30 PM` (UTC is assumed), `06/15/2024 03:30 PM America/New_York`, or `06/15/2024 03:30 PM +05:30`. A timezone, when supplied, is converted to UTC before the request is made. Raw UNIX seconds are also accepted. Date/timestamp fields in **responses** are likewise rendered as UTC strings (e.g. `01/01/2024 12:00:00 AM UTC`).
|
|
14
|
+
- **Responses are compact by default.** To stay within model context limits, large payloads are trimmed: lists are sorted and capped, time series are downsampled (≈30 points), and noisy/heavy fields (logos, descriptions, token-level histories) are dropped. The output is minified JSON.
|
|
15
|
+
- **Opt into more data** with these optional parameters where applicable:
|
|
16
|
+
- `full` (boolean) — return the complete, untrimmed response.
|
|
17
|
+
- `points` (number) — max time-series data points to keep (default 30).
|
|
18
|
+
- `limit` (number) — max items to keep for list endpoints.
|
|
19
|
+
- `includeTokens` (boolean) — include token-level breakdowns (`protocol_tvl`, `stablecoin_data`).
|
|
20
|
+
- For the DEX/options/fees overview & summary tools, the aggregate charts are excluded by default; set `excludeTotalDataChart: false` (or `full: true`) to include them.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
## Tools
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
- `coins` (string[], required): coin identifiers, e.g. `["ethereum:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"]`.
|
|
26
|
-
- `defillama_get_historical_prices` — Get historical prices of tokens at a point in time.
|
|
27
|
-
- `coins` (string[], required): coin identifiers.
|
|
28
|
-
- `timestamp` (number, required): UNIX timestamp (seconds).
|
|
24
|
+
The server exposes all **31** endpoints of the free (keyless) DefiLlama API as MCP tools. Required parameters are marked accordingly; everything else is optional. Each tool's description includes a ready-to-use example.
|
|
29
25
|
|
|
30
|
-
###
|
|
26
|
+
### TVL
|
|
31
27
|
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
34
|
-
- `
|
|
28
|
+
- `defillama_get_protocols` — List all protocols and their TVL.
|
|
29
|
+
- `defillama_get_protocol_tvl` — Full historical TVL breakdown for a protocol.
|
|
30
|
+
- `protocol` (string, required): protocol slug, e.g. `aave`.
|
|
31
|
+
- `defillama_get_historical_chain_tvl` — Historical TVL across all chains combined.
|
|
32
|
+
- `defillama_get_chain_tvl` — Historical TVL for a specific chain.
|
|
33
|
+
- `chain` (string, required): chain name, e.g. `ethereum`.
|
|
34
|
+
- `defillama_get_current_protocol_tvl` — Current TVL of a protocol as a single number.
|
|
35
|
+
- `protocol` (string, required).
|
|
36
|
+
- `defillama_get_chains` — Current TVL of every chain.
|
|
37
|
+
|
|
38
|
+
### Coins / Prices
|
|
39
|
+
|
|
40
|
+
- `defillama_get_token_prices` — Current prices of tokens.
|
|
41
|
+
- `coins` (string[], required): e.g. `["ethereum:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"]`.
|
|
42
|
+
- `defillama_get_historical_prices` — Token prices at a historical date/time.
|
|
43
|
+
- `coins` (string[], required), `timestamp` (datetime, required).
|
|
44
|
+
- `defillama_get_batch_historical_prices` — Prices for many coins at many dates/times.
|
|
45
|
+
- `coins` (object, required): map of coin id → array of datetime strings. `searchWidth` (string, optional).
|
|
46
|
+
- `defillama_get_price_chart` — Price chart over time for the given coins.
|
|
47
|
+
- `coins` (string[], required); optional `start` (datetime), `end` (datetime), `span`, `period`, `searchWidth`, `points`.
|
|
48
|
+
- `defillama_get_price_percentage_change` — Percentage price change over a period.
|
|
49
|
+
- `coins` (string[], required); optional `timestamp` (datetime), `lookForward`, `period`.
|
|
50
|
+
- `defillama_get_first_prices` — Earliest recorded price for the given coins.
|
|
51
|
+
- `coins` (string[], required).
|
|
52
|
+
- `defillama_get_block` — Block height closest to a date/time on a chain.
|
|
53
|
+
- `chain` (string, required), `timestamp` (datetime, required).
|
|
54
|
+
|
|
55
|
+
### Stablecoins
|
|
56
|
+
|
|
57
|
+
- `defillama_get_stablecoins` — List all stablecoins with circulating amounts.
|
|
58
|
+
- `includePrices` (boolean, optional).
|
|
59
|
+
- `defillama_get_stablecoin_charts_all` — Historical market cap sum of all stablecoins.
|
|
60
|
+
- `stablecoin` (number, optional): filter by stablecoin ID.
|
|
61
|
+
- `defillama_get_stablecoin_charts_chain` — Historical stablecoin market cap on a chain.
|
|
62
|
+
- `chain` (string, required), `stablecoin` (number, optional).
|
|
63
|
+
- `defillama_get_stablecoin_data` — Historical data for a specific stablecoin.
|
|
64
|
+
- `asset` (string, required): stablecoin ID or name.
|
|
65
|
+
- `defillama_get_stablecoin_chains` — Current stablecoin totals per chain.
|
|
66
|
+
- `defillama_get_stablecoin_prices` — Historical stablecoin prices.
|
|
67
|
+
|
|
68
|
+
### Yields / APY
|
|
69
|
+
|
|
70
|
+
- `defillama_get_pools` — Latest TVL and APY for all yield pools.
|
|
71
|
+
- `defillama_get_pool_chart` — Historical APY and TVL for a pool.
|
|
72
|
+
- `pool` (string, required): pool ID (uuid from `defillama_get_pools`).
|
|
73
|
+
|
|
74
|
+
### DEX / Options volume
|
|
75
|
+
|
|
76
|
+
- `defillama_get_dexs_overview` — DEX volume overview across all chains.
|
|
77
|
+
- `defillama_get_dexs_overview_by_chain` — DEX volume overview for a chain. `chain` (string, required).
|
|
78
|
+
- `defillama_get_dex_summary` — DEX volume summary for a protocol. `protocol` (string, required).
|
|
79
|
+
- `defillama_get_options_overview` — Options volume overview across all chains.
|
|
80
|
+
- `defillama_get_options_overview_by_chain` — Options volume overview for a chain. `chain` (string, required).
|
|
81
|
+
- `defillama_get_option_summary` — Options volume summary for a protocol. `protocol` (string, required).
|
|
82
|
+
|
|
83
|
+
The overview/summary tools above (and the fees tools below) also accept optional `excludeTotalDataChart` (boolean), `excludeTotalDataChartBreakdown` (boolean), and `dataType` (string, e.g. `dailyVolume`, `dailyFees`, `dailyRevenue`).
|
|
84
|
+
|
|
85
|
+
### Perps / Open interest
|
|
86
|
+
|
|
87
|
+
- `defillama_get_open_interest_overview` — Perpetuals open interest overview.
|
|
88
|
+
|
|
89
|
+
### Fees / Revenue
|
|
90
|
+
|
|
91
|
+
- `defillama_get_fees_overview` — Fees and revenue overview across all chains.
|
|
92
|
+
- `defillama_get_fees_overview_by_chain` — Fees and revenue overview for a chain. `chain` (string, required).
|
|
93
|
+
- `defillama_get_fee_summary` — Fees and revenue summary for a protocol. `protocol` (string, required).
|
|
35
94
|
|
|
36
95
|
## Requirements
|
|
37
96
|
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DefiLlama API Client
|
|
3
|
-
* Provides methods to interact with the DefiLlama API
|
|
3
|
+
* Provides methods to interact with the free (keyless) DefiLlama API.
|
|
4
|
+
*
|
|
5
|
+
* DefiLlama splits its free API across a few category-specific hosts. The
|
|
6
|
+
* canonical routing is:
|
|
7
|
+
* - TVL, DEX/options volume, fees/revenue, open interest -> api.llama.fi
|
|
8
|
+
* - Coins / prices / blocks -> coins.llama.fi
|
|
9
|
+
* - Stablecoins -> stablecoins.llama.fi
|
|
10
|
+
* - Yields / pools -> yields.llama.fi
|
|
4
11
|
*/
|
|
12
|
+
export declare const DEFILLAMA_HOSTS: {
|
|
13
|
+
readonly api: "https://api.llama.fi";
|
|
14
|
+
readonly coins: "https://coins.llama.fi";
|
|
15
|
+
readonly stablecoins: "https://stablecoins.llama.fi";
|
|
16
|
+
readonly yields: "https://yields.llama.fi";
|
|
17
|
+
};
|
|
18
|
+
export type QueryValue = string | number | boolean | undefined;
|
|
19
|
+
export type QueryParams = Record<string, QueryValue>;
|
|
20
|
+
/** Common query options for the DEX/options/fees overview & summary endpoints. */
|
|
21
|
+
export interface OverviewOptions {
|
|
22
|
+
excludeTotalDataChart?: boolean;
|
|
23
|
+
excludeTotalDataChartBreakdown?: boolean;
|
|
24
|
+
dataType?: string;
|
|
25
|
+
}
|
|
5
26
|
export interface Protocol {
|
|
6
27
|
id: string;
|
|
7
28
|
name: string;
|
|
@@ -39,15 +60,26 @@ export interface ProtocolTvl {
|
|
|
39
60
|
symbol: string;
|
|
40
61
|
url: string;
|
|
41
62
|
description: string;
|
|
42
|
-
|
|
63
|
+
/** Current TVL (number) or an aggregate historical series, depending on the endpoint shape. */
|
|
64
|
+
tvl: number | TvlItem[];
|
|
43
65
|
tokensInUsd?: Array<{
|
|
44
66
|
date: number;
|
|
45
67
|
tokens: Record<string, number>;
|
|
46
68
|
}>;
|
|
47
|
-
tokens?: Record<string, TokenBalance
|
|
48
|
-
|
|
69
|
+
tokens?: Record<string, TokenBalance> | Array<{
|
|
70
|
+
date: number;
|
|
71
|
+
tokens: Record<string, number>;
|
|
72
|
+
}>;
|
|
73
|
+
/** Current TVL per chain (present on the live API). */
|
|
74
|
+
currentChainTvls?: Record<string, number>;
|
|
75
|
+
/** Per-chain TVL: flat current numbers, or historical {tvl,tokens,tokensInUsd} objects. */
|
|
76
|
+
chainTvls: Record<string, number | {
|
|
77
|
+
tvl?: TvlItem[];
|
|
78
|
+
tokens?: unknown;
|
|
79
|
+
tokensInUsd?: unknown;
|
|
80
|
+
}>;
|
|
49
81
|
tvlPriceChange?: Record<string, number>;
|
|
50
|
-
tvlList
|
|
82
|
+
tvlList?: TvlItem[];
|
|
51
83
|
}
|
|
52
84
|
export interface ChainTvlItem {
|
|
53
85
|
date: number;
|
|
@@ -55,11 +87,20 @@ export interface ChainTvlItem {
|
|
|
55
87
|
tvl?: number;
|
|
56
88
|
totalLiquidityETH?: number;
|
|
57
89
|
}
|
|
90
|
+
export interface Chain {
|
|
91
|
+
gecko_id: string | null;
|
|
92
|
+
tvl: number;
|
|
93
|
+
tokenSymbol: string | null;
|
|
94
|
+
cmcId: string | null;
|
|
95
|
+
name: string;
|
|
96
|
+
chainId: number | null;
|
|
97
|
+
}
|
|
58
98
|
export interface TokenPrice {
|
|
59
99
|
price: number;
|
|
60
100
|
symbol: string;
|
|
61
101
|
timestamp: number;
|
|
62
102
|
confidence: number;
|
|
103
|
+
decimals?: number;
|
|
63
104
|
}
|
|
64
105
|
export interface TokenPricesResponse {
|
|
65
106
|
coins: Record<string, TokenPrice>;
|
|
@@ -90,39 +131,89 @@ export interface StablecoinData extends StablecoinAsset {
|
|
|
90
131
|
delisted: boolean;
|
|
91
132
|
}
|
|
92
133
|
export declare class DefiLlamaClient {
|
|
93
|
-
private baseUrl;
|
|
94
|
-
constructor(baseUrl?: string);
|
|
95
|
-
/**
|
|
96
|
-
* Makes a GET request to the DefiLlama API
|
|
97
|
-
*/
|
|
98
|
-
private get;
|
|
99
134
|
/**
|
|
100
|
-
*
|
|
135
|
+
* Makes a GET request to one of the DefiLlama hosts.
|
|
101
136
|
*/
|
|
137
|
+
protected request<T>(host: string, path: string, query?: QueryParams): Promise<T>;
|
|
138
|
+
/** Joins coin identifiers into the comma-separated form DefiLlama expects. */
|
|
139
|
+
private joinCoins;
|
|
140
|
+
/** GET /protocols — list all protocols. */
|
|
102
141
|
getProtocols(): Promise<Protocol[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Get TVL data for a specific protocol
|
|
105
|
-
*/
|
|
142
|
+
/** GET /protocol/{protocol} — full TVL breakdown for a protocol. */
|
|
106
143
|
getProtocolTvl(protocol: string): Promise<ProtocolTvl>;
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
144
|
+
/** GET /v2/historicalChainTvl — historical TVL across all chains. */
|
|
145
|
+
getHistoricalChainTvl(): Promise<ChainTvlItem[]>;
|
|
146
|
+
/** GET /v2/historicalChainTvl/{chain} — historical TVL for one chain. */
|
|
110
147
|
getChainTvl(chain: string): Promise<ChainTvlItem[]>;
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
148
|
+
/** GET /tvl/{protocol} — current TVL of a protocol as a single number. */
|
|
149
|
+
getCurrentProtocolTvl(protocol: string): Promise<number>;
|
|
150
|
+
/** GET /v2/chains — current TVL of all chains. */
|
|
151
|
+
getChains(): Promise<Chain[]>;
|
|
152
|
+
/** GET /prices/current/{coins} — current prices for the given coins. */
|
|
114
153
|
getTokenPrices(coins: string[]): Promise<TokenPricesResponse>;
|
|
115
|
-
/**
|
|
116
|
-
* Get historical prices for specified tokens/coins at a specific timestamp
|
|
117
|
-
*/
|
|
154
|
+
/** GET /prices/historical/{timestamp}/{coins} — prices at a timestamp. */
|
|
118
155
|
getHistoricalPrices(coins: string[], timestamp: number): Promise<TokenPricesResponse>;
|
|
119
156
|
/**
|
|
120
|
-
*
|
|
121
|
-
|
|
122
|
-
getStablecoins(): Promise<StablecoinsResponse>;
|
|
123
|
-
/**
|
|
124
|
-
* Get data for a specific stablecoin
|
|
157
|
+
* GET /batchHistorical — historical prices for many coins at many timestamps.
|
|
158
|
+
* @param coins Map of coin identifier to an array of UNIX timestamps.
|
|
125
159
|
*/
|
|
160
|
+
getBatchHistoricalPrices(coins: Record<string, number[]>, searchWidth?: string): Promise<TokenPricesResponse>;
|
|
161
|
+
/** GET /chart/{coins} — price chart for the given coins. */
|
|
162
|
+
getPriceChart(coins: string[], options?: {
|
|
163
|
+
start?: number;
|
|
164
|
+
end?: number;
|
|
165
|
+
span?: number;
|
|
166
|
+
period?: string;
|
|
167
|
+
searchWidth?: string;
|
|
168
|
+
}): Promise<unknown>;
|
|
169
|
+
/** GET /percentage/{coins} — percentage price change for the given coins. */
|
|
170
|
+
getPricePercentageChange(coins: string[], options?: {
|
|
171
|
+
timestamp?: number;
|
|
172
|
+
lookForward?: boolean;
|
|
173
|
+
period?: string;
|
|
174
|
+
}): Promise<unknown>;
|
|
175
|
+
/** GET /prices/first/{coins} — earliest recorded price for the given coins. */
|
|
176
|
+
getFirstPrices(coins: string[]): Promise<TokenPricesResponse>;
|
|
177
|
+
/** GET /block/{chain}/{timestamp} — closest block to a timestamp on a chain. */
|
|
178
|
+
getBlock(chain: string, timestamp: number): Promise<{
|
|
179
|
+
height: number;
|
|
180
|
+
timestamp: number;
|
|
181
|
+
}>;
|
|
182
|
+
/** GET /stablecoins — list all stablecoins with circulating amounts. */
|
|
183
|
+
getStablecoins(includePrices?: boolean): Promise<StablecoinsResponse>;
|
|
184
|
+
/** GET /stablecoincharts/all — historical mcap sum of all stablecoins. */
|
|
185
|
+
getStablecoinChartsAll(stablecoin?: number | string): Promise<unknown>;
|
|
186
|
+
/** GET /stablecoincharts/{chain} — historical mcap of stablecoins on a chain. */
|
|
187
|
+
getStablecoinChartsChain(chain: string, stablecoin?: number | string): Promise<unknown>;
|
|
188
|
+
/** GET /stablecoin/{asset} — historical data for a single stablecoin. */
|
|
126
189
|
getStablecoinData(asset: string): Promise<StablecoinData>;
|
|
190
|
+
/** GET /stablecoinchains — current stablecoin totals per chain. */
|
|
191
|
+
getStablecoinChains(): Promise<unknown>;
|
|
192
|
+
/** GET /stablecoinprices — historical stablecoin prices. */
|
|
193
|
+
getStablecoinPrices(): Promise<unknown>;
|
|
194
|
+
/** GET /pools — latest data for all yield pools. */
|
|
195
|
+
getPools(): Promise<unknown>;
|
|
196
|
+
/** GET /chart/{pool} — historical APY and TVL for a pool. */
|
|
197
|
+
getPoolChart(pool: string): Promise<unknown>;
|
|
198
|
+
/** GET /overview/dexs — DEX volume overview across all chains. */
|
|
199
|
+
getDexsOverview(options?: OverviewOptions): Promise<unknown>;
|
|
200
|
+
/** GET /overview/dexs/{chain} — DEX volume overview for a chain. */
|
|
201
|
+
getDexsOverviewByChain(chain: string, options?: OverviewOptions): Promise<unknown>;
|
|
202
|
+
/** GET /summary/dexs/{protocol} — DEX volume summary for a protocol. */
|
|
203
|
+
getDexSummary(protocol: string, options?: OverviewOptions): Promise<unknown>;
|
|
204
|
+
/** GET /overview/options — options volume overview across all chains. */
|
|
205
|
+
getOptionsOverview(options?: OverviewOptions): Promise<unknown>;
|
|
206
|
+
/** GET /overview/options/{chain} — options volume overview for a chain. */
|
|
207
|
+
getOptionsOverviewByChain(chain: string, options?: OverviewOptions): Promise<unknown>;
|
|
208
|
+
/** GET /summary/options/{protocol} — options volume summary for a protocol. */
|
|
209
|
+
getOptionSummary(protocol: string, options?: OverviewOptions): Promise<unknown>;
|
|
210
|
+
/** GET /overview/open-interest — perps open interest overview. */
|
|
211
|
+
getOpenInterestOverview(options?: OverviewOptions): Promise<unknown>;
|
|
212
|
+
/** GET /overview/fees — fees/revenue overview across all chains. */
|
|
213
|
+
getFeesOverview(options?: OverviewOptions): Promise<unknown>;
|
|
214
|
+
/** GET /overview/fees/{chain} — fees/revenue overview for a chain. */
|
|
215
|
+
getFeesOverviewByChain(chain: string, options?: OverviewOptions): Promise<unknown>;
|
|
216
|
+
/** GET /summary/fees/{protocol} — fees/revenue summary for a protocol. */
|
|
217
|
+
getFeeSummary(protocol: string, options?: OverviewOptions): Promise<unknown>;
|
|
127
218
|
}
|
|
128
219
|
export declare const defiLlamaClient: DefiLlamaClient;
|