@missionsquad/mcp-defillama 1.0.0 → 1.1.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 +69 -23
- package/dist/clients/defillama.client.d.ts +105 -25
- package/dist/clients/defillama.client.js +213 -156
- 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/defillama.d.ts +26 -2
- package/dist/handlers/defillama.js +268 -22
- package/dist/handlers/defillama.js.map +1 -1
- package/dist/handlers/defillama.types.d.ts +81 -0
- package/dist/handlers/defillama.types.js +3 -0
- package/dist/handlers/defillama.types.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tools.d.ts +424 -0
- package/dist/tools.js +291 -32
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,37 +1,83 @@
|
|
|
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
|
+
|
|
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.
|
|
4
6
|
|
|
5
7
|
Published on npm as [`@missionsquad/mcp-defillama`](https://www.npmjs.com/package/@missionsquad/mcp-defillama).
|
|
6
8
|
|
|
7
9
|
## Tools
|
|
8
10
|
|
|
9
|
-
The server exposes the
|
|
11
|
+
The server exposes all **31** endpoints of the free (keyless) DefiLlama API as MCP tools. Required parameters are marked accordingly; everything else is optional.
|
|
10
12
|
|
|
11
|
-
###
|
|
13
|
+
### TVL
|
|
12
14
|
|
|
13
|
-
- `defillama_get_protocols` — List all protocols
|
|
14
|
-
- `defillama_get_protocol_tvl` —
|
|
15
|
+
- `defillama_get_protocols` — List all protocols and their TVL.
|
|
16
|
+
- `defillama_get_protocol_tvl` — Full historical TVL breakdown for a protocol.
|
|
15
17
|
- `protocol` (string, required): protocol slug, e.g. `aave`.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- `defillama_get_chain_tvl` — Get historical TVL data for a specific chain.
|
|
18
|
+
- `defillama_get_historical_chain_tvl` — Historical TVL across all chains combined.
|
|
19
|
+
- `defillama_get_chain_tvl` — Historical TVL for a specific chain.
|
|
20
20
|
- `chain` (string, required): chain name, e.g. `ethereum`.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- `
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
34
|
-
- `
|
|
21
|
+
- `defillama_get_current_protocol_tvl` — Current TVL of a protocol as a single number.
|
|
22
|
+
- `protocol` (string, required).
|
|
23
|
+
- `defillama_get_chains` — Current TVL of every chain.
|
|
24
|
+
|
|
25
|
+
### Coins / Prices
|
|
26
|
+
|
|
27
|
+
- `defillama_get_token_prices` — Current prices of tokens.
|
|
28
|
+
- `coins` (string[], required): e.g. `["ethereum:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"]`.
|
|
29
|
+
- `defillama_get_historical_prices` — Token prices at a historical timestamp.
|
|
30
|
+
- `coins` (string[], required), `timestamp` (number, required): UNIX seconds.
|
|
31
|
+
- `defillama_get_batch_historical_prices` — Prices for many coins at many timestamps.
|
|
32
|
+
- `coins` (object, required): map of coin id → array of timestamps. `searchWidth` (string, optional).
|
|
33
|
+
- `defillama_get_price_chart` — Price chart over time for the given coins.
|
|
34
|
+
- `coins` (string[], required); optional `start`, `end`, `span`, `period`, `searchWidth`.
|
|
35
|
+
- `defillama_get_price_percentage_change` — Percentage price change over a period.
|
|
36
|
+
- `coins` (string[], required); optional `timestamp`, `lookForward`, `period`.
|
|
37
|
+
- `defillama_get_first_prices` — Earliest recorded price for the given coins.
|
|
38
|
+
- `coins` (string[], required).
|
|
39
|
+
- `defillama_get_block` — Block height closest to a timestamp on a chain.
|
|
40
|
+
- `chain` (string, required), `timestamp` (number, required).
|
|
41
|
+
|
|
42
|
+
### Stablecoins
|
|
43
|
+
|
|
44
|
+
- `defillama_get_stablecoins` — List all stablecoins with circulating amounts.
|
|
45
|
+
- `includePrices` (boolean, optional).
|
|
46
|
+
- `defillama_get_stablecoin_charts_all` — Historical market cap sum of all stablecoins.
|
|
47
|
+
- `stablecoin` (number, optional): filter by stablecoin ID.
|
|
48
|
+
- `defillama_get_stablecoin_charts_chain` — Historical stablecoin market cap on a chain.
|
|
49
|
+
- `chain` (string, required), `stablecoin` (number, optional).
|
|
50
|
+
- `defillama_get_stablecoin_data` — Historical data for a specific stablecoin.
|
|
51
|
+
- `asset` (string, required): stablecoin ID or name.
|
|
52
|
+
- `defillama_get_stablecoin_chains` — Current stablecoin totals per chain.
|
|
53
|
+
- `defillama_get_stablecoin_prices` — Historical stablecoin prices.
|
|
54
|
+
|
|
55
|
+
### Yields / APY
|
|
56
|
+
|
|
57
|
+
- `defillama_get_pools` — Latest TVL and APY for all yield pools.
|
|
58
|
+
- `defillama_get_pool_chart` — Historical APY and TVL for a pool.
|
|
59
|
+
- `pool` (string, required): pool ID (uuid from `defillama_get_pools`).
|
|
60
|
+
|
|
61
|
+
### DEX / Options volume
|
|
62
|
+
|
|
63
|
+
- `defillama_get_dexs_overview` — DEX volume overview across all chains.
|
|
64
|
+
- `defillama_get_dexs_overview_by_chain` — DEX volume overview for a chain. `chain` (string, required).
|
|
65
|
+
- `defillama_get_dex_summary` — DEX volume summary for a protocol. `protocol` (string, required).
|
|
66
|
+
- `defillama_get_options_overview` — Options volume overview across all chains.
|
|
67
|
+
- `defillama_get_options_overview_by_chain` — Options volume overview for a chain. `chain` (string, required).
|
|
68
|
+
- `defillama_get_option_summary` — Options volume summary for a protocol. `protocol` (string, required).
|
|
69
|
+
|
|
70
|
+
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`).
|
|
71
|
+
|
|
72
|
+
### Perps / Open interest
|
|
73
|
+
|
|
74
|
+
- `defillama_get_open_interest_overview` — Perpetuals open interest overview.
|
|
75
|
+
|
|
76
|
+
### Fees / Revenue
|
|
77
|
+
|
|
78
|
+
- `defillama_get_fees_overview` — Fees and revenue overview across all chains.
|
|
79
|
+
- `defillama_get_fees_overview_by_chain` — Fees and revenue overview for a chain. `chain` (string, required).
|
|
80
|
+
- `defillama_get_fee_summary` — Fees and revenue summary for a protocol. `protocol` (string, required).
|
|
35
81
|
|
|
36
82
|
## Requirements
|
|
37
83
|
|
|
@@ -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;
|
|
@@ -55,11 +76,20 @@ export interface ChainTvlItem {
|
|
|
55
76
|
tvl?: number;
|
|
56
77
|
totalLiquidityETH?: number;
|
|
57
78
|
}
|
|
79
|
+
export interface Chain {
|
|
80
|
+
gecko_id: string | null;
|
|
81
|
+
tvl: number;
|
|
82
|
+
tokenSymbol: string | null;
|
|
83
|
+
cmcId: string | null;
|
|
84
|
+
name: string;
|
|
85
|
+
chainId: number | null;
|
|
86
|
+
}
|
|
58
87
|
export interface TokenPrice {
|
|
59
88
|
price: number;
|
|
60
89
|
symbol: string;
|
|
61
90
|
timestamp: number;
|
|
62
91
|
confidence: number;
|
|
92
|
+
decimals?: number;
|
|
63
93
|
}
|
|
64
94
|
export interface TokenPricesResponse {
|
|
65
95
|
coins: Record<string, TokenPrice>;
|
|
@@ -90,39 +120,89 @@ export interface StablecoinData extends StablecoinAsset {
|
|
|
90
120
|
delisted: boolean;
|
|
91
121
|
}
|
|
92
122
|
export declare class DefiLlamaClient {
|
|
93
|
-
private baseUrl;
|
|
94
|
-
constructor(baseUrl?: string);
|
|
95
123
|
/**
|
|
96
|
-
* Makes a GET request to the DefiLlama
|
|
97
|
-
*/
|
|
98
|
-
private get;
|
|
99
|
-
/**
|
|
100
|
-
* Get all protocols
|
|
124
|
+
* Makes a GET request to one of the DefiLlama hosts.
|
|
101
125
|
*/
|
|
126
|
+
protected request<T>(host: string, path: string, query?: QueryParams): Promise<T>;
|
|
127
|
+
/** Joins coin identifiers into the comma-separated form DefiLlama expects. */
|
|
128
|
+
private joinCoins;
|
|
129
|
+
/** GET /protocols — list all protocols. */
|
|
102
130
|
getProtocols(): Promise<Protocol[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Get TVL data for a specific protocol
|
|
105
|
-
*/
|
|
131
|
+
/** GET /protocol/{protocol} — full TVL breakdown for a protocol. */
|
|
106
132
|
getProtocolTvl(protocol: string): Promise<ProtocolTvl>;
|
|
107
|
-
/**
|
|
108
|
-
|
|
109
|
-
|
|
133
|
+
/** GET /v2/historicalChainTvl — historical TVL across all chains. */
|
|
134
|
+
getHistoricalChainTvl(): Promise<ChainTvlItem[]>;
|
|
135
|
+
/** GET /v2/historicalChainTvl/{chain} — historical TVL for one chain. */
|
|
110
136
|
getChainTvl(chain: string): Promise<ChainTvlItem[]>;
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
137
|
+
/** GET /tvl/{protocol} — current TVL of a protocol as a single number. */
|
|
138
|
+
getCurrentProtocolTvl(protocol: string): Promise<number>;
|
|
139
|
+
/** GET /v2/chains — current TVL of all chains. */
|
|
140
|
+
getChains(): Promise<Chain[]>;
|
|
141
|
+
/** GET /prices/current/{coins} — current prices for the given coins. */
|
|
114
142
|
getTokenPrices(coins: string[]): Promise<TokenPricesResponse>;
|
|
115
|
-
/**
|
|
116
|
-
* Get historical prices for specified tokens/coins at a specific timestamp
|
|
117
|
-
*/
|
|
143
|
+
/** GET /prices/historical/{timestamp}/{coins} — prices at a timestamp. */
|
|
118
144
|
getHistoricalPrices(coins: string[], timestamp: number): Promise<TokenPricesResponse>;
|
|
119
145
|
/**
|
|
120
|
-
*
|
|
121
|
-
|
|
122
|
-
getStablecoins(): Promise<StablecoinsResponse>;
|
|
123
|
-
/**
|
|
124
|
-
* Get data for a specific stablecoin
|
|
146
|
+
* GET /batchHistorical — historical prices for many coins at many timestamps.
|
|
147
|
+
* @param coins Map of coin identifier to an array of UNIX timestamps.
|
|
125
148
|
*/
|
|
149
|
+
getBatchHistoricalPrices(coins: Record<string, number[]>, searchWidth?: string): Promise<TokenPricesResponse>;
|
|
150
|
+
/** GET /chart/{coins} — price chart for the given coins. */
|
|
151
|
+
getPriceChart(coins: string[], options?: {
|
|
152
|
+
start?: number;
|
|
153
|
+
end?: number;
|
|
154
|
+
span?: number;
|
|
155
|
+
period?: string;
|
|
156
|
+
searchWidth?: string;
|
|
157
|
+
}): Promise<unknown>;
|
|
158
|
+
/** GET /percentage/{coins} — percentage price change for the given coins. */
|
|
159
|
+
getPricePercentageChange(coins: string[], options?: {
|
|
160
|
+
timestamp?: number;
|
|
161
|
+
lookForward?: boolean;
|
|
162
|
+
period?: string;
|
|
163
|
+
}): Promise<unknown>;
|
|
164
|
+
/** GET /prices/first/{coins} — earliest recorded price for the given coins. */
|
|
165
|
+
getFirstPrices(coins: string[]): Promise<TokenPricesResponse>;
|
|
166
|
+
/** GET /block/{chain}/{timestamp} — closest block to a timestamp on a chain. */
|
|
167
|
+
getBlock(chain: string, timestamp: number): Promise<{
|
|
168
|
+
height: number;
|
|
169
|
+
timestamp: number;
|
|
170
|
+
}>;
|
|
171
|
+
/** GET /stablecoins — list all stablecoins with circulating amounts. */
|
|
172
|
+
getStablecoins(includePrices?: boolean): Promise<StablecoinsResponse>;
|
|
173
|
+
/** GET /stablecoincharts/all — historical mcap sum of all stablecoins. */
|
|
174
|
+
getStablecoinChartsAll(stablecoin?: number | string): Promise<unknown>;
|
|
175
|
+
/** GET /stablecoincharts/{chain} — historical mcap of stablecoins on a chain. */
|
|
176
|
+
getStablecoinChartsChain(chain: string, stablecoin?: number | string): Promise<unknown>;
|
|
177
|
+
/** GET /stablecoin/{asset} — historical data for a single stablecoin. */
|
|
126
178
|
getStablecoinData(asset: string): Promise<StablecoinData>;
|
|
179
|
+
/** GET /stablecoinchains — current stablecoin totals per chain. */
|
|
180
|
+
getStablecoinChains(): Promise<unknown>;
|
|
181
|
+
/** GET /stablecoinprices — historical stablecoin prices. */
|
|
182
|
+
getStablecoinPrices(): Promise<unknown>;
|
|
183
|
+
/** GET /pools — latest data for all yield pools. */
|
|
184
|
+
getPools(): Promise<unknown>;
|
|
185
|
+
/** GET /chart/{pool} — historical APY and TVL for a pool. */
|
|
186
|
+
getPoolChart(pool: string): Promise<unknown>;
|
|
187
|
+
/** GET /overview/dexs — DEX volume overview across all chains. */
|
|
188
|
+
getDexsOverview(options?: OverviewOptions): Promise<unknown>;
|
|
189
|
+
/** GET /overview/dexs/{chain} — DEX volume overview for a chain. */
|
|
190
|
+
getDexsOverviewByChain(chain: string, options?: OverviewOptions): Promise<unknown>;
|
|
191
|
+
/** GET /summary/dexs/{protocol} — DEX volume summary for a protocol. */
|
|
192
|
+
getDexSummary(protocol: string, options?: OverviewOptions): Promise<unknown>;
|
|
193
|
+
/** GET /overview/options — options volume overview across all chains. */
|
|
194
|
+
getOptionsOverview(options?: OverviewOptions): Promise<unknown>;
|
|
195
|
+
/** GET /overview/options/{chain} — options volume overview for a chain. */
|
|
196
|
+
getOptionsOverviewByChain(chain: string, options?: OverviewOptions): Promise<unknown>;
|
|
197
|
+
/** GET /summary/options/{protocol} — options volume summary for a protocol. */
|
|
198
|
+
getOptionSummary(protocol: string, options?: OverviewOptions): Promise<unknown>;
|
|
199
|
+
/** GET /overview/open-interest — perps open interest overview. */
|
|
200
|
+
getOpenInterestOverview(options?: OverviewOptions): Promise<unknown>;
|
|
201
|
+
/** GET /overview/fees — fees/revenue overview across all chains. */
|
|
202
|
+
getFeesOverview(options?: OverviewOptions): Promise<unknown>;
|
|
203
|
+
/** GET /overview/fees/{chain} — fees/revenue overview for a chain. */
|
|
204
|
+
getFeesOverviewByChain(chain: string, options?: OverviewOptions): Promise<unknown>;
|
|
205
|
+
/** GET /summary/fees/{protocol} — fees/revenue summary for a protocol. */
|
|
206
|
+
getFeeSummary(protocol: string, options?: OverviewOptions): Promise<unknown>;
|
|
127
207
|
}
|
|
128
208
|
export declare const defiLlamaClient: DefiLlamaClient;
|