@guiie/buda-mcp 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/CHANGELOG.md +87 -0
- package/PUBLISH_CHECKLIST.md +192 -0
- package/README.md +308 -70
- package/dist/cache.d.ts +13 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +25 -0
- package/dist/client.d.ts +9 -8
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +95 -12
- package/dist/http.d.ts +2 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +262 -0
- package/dist/index.js +53 -9
- package/dist/tools/balances.d.ts +4 -0
- package/dist/tools/balances.d.ts.map +1 -0
- package/dist/tools/balances.js +23 -0
- package/dist/tools/cancel_order.d.ts +4 -0
- package/dist/tools/cancel_order.d.ts.map +1 -0
- package/dist/tools/cancel_order.js +53 -0
- package/dist/tools/compare_markets.d.ts +5 -0
- package/dist/tools/compare_markets.d.ts.map +1 -0
- package/dist/tools/compare_markets.js +65 -0
- package/dist/tools/markets.d.ts +2 -1
- package/dist/tools/markets.d.ts.map +1 -1
- package/dist/tools/markets.js +22 -8
- package/dist/tools/orderbook.d.ts +2 -1
- package/dist/tools/orderbook.d.ts.map +1 -1
- package/dist/tools/orderbook.js +27 -13
- package/dist/tools/orders.d.ts +4 -0
- package/dist/tools/orders.d.ts.map +1 -0
- package/dist/tools/orders.js +57 -0
- package/dist/tools/place_order.d.ts +4 -0
- package/dist/tools/place_order.d.ts.map +1 -0
- package/dist/tools/place_order.js +88 -0
- package/dist/tools/price_history.d.ts +5 -0
- package/dist/tools/price_history.d.ts.map +1 -0
- package/dist/tools/price_history.js +97 -0
- package/dist/tools/spread.d.ts +5 -0
- package/dist/tools/spread.d.ts.map +1 -0
- package/dist/tools/spread.js +55 -0
- package/dist/tools/ticker.d.ts +2 -1
- package/dist/tools/ticker.d.ts.map +1 -1
- package/dist/tools/ticker.js +19 -5
- package/dist/tools/trades.d.ts +2 -1
- package/dist/tools/trades.d.ts.map +1 -1
- package/dist/tools/trades.js +22 -10
- package/dist/tools/volume.d.ts +2 -1
- package/dist/tools/volume.d.ts.map +1 -1
- package/dist/tools/volume.js +17 -5
- package/dist/types.d.ts +42 -1
- package/dist/types.d.ts.map +1 -1
- package/marketplace/claude-listing.md +76 -8
- package/marketplace/cursor-mcp.json +2 -2
- package/marketplace/gemini-tools.json +51 -1
- package/marketplace/openapi.yaml +204 -4
- package/package.json +6 -2
- package/railway.json +12 -0
- package/server.json +1 -1
- package/src/cache.ts +34 -0
- package/src/client.ts +107 -12
- package/src/http.ts +305 -0
- package/src/index.ts +77 -9
- package/src/tools/balances.ts +30 -0
- package/src/tools/cancel_order.ts +65 -0
- package/src/tools/compare_markets.ts +82 -0
- package/src/tools/markets.ts +30 -11
- package/src/tools/orderbook.ts +31 -16
- package/src/tools/orders.ts +68 -0
- package/src/tools/place_order.ts +107 -0
- package/src/tools/price_history.ts +124 -0
- package/src/tools/spread.ts +71 -0
- package/src/tools/ticker.ts +23 -8
- package/src/tools/trades.ts +24 -12
- package/src/tools/volume.ts +20 -8
- package/src/types.ts +52 -1
- package/test/run-all.ts +122 -1
- package/tsconfig.json +1 -1
package/test/run-all.ts
CHANGED
|
@@ -12,9 +12,16 @@ import type {
|
|
|
12
12
|
OrderBookResponse,
|
|
13
13
|
TradesResponse,
|
|
14
14
|
VolumeResponse,
|
|
15
|
+
AllTickersResponse,
|
|
16
|
+
BalancesResponse,
|
|
17
|
+
OrdersResponse,
|
|
15
18
|
} from "../src/types.js";
|
|
16
19
|
|
|
17
|
-
const client = new BudaClient(
|
|
20
|
+
const client = new BudaClient(
|
|
21
|
+
undefined,
|
|
22
|
+
process.env.BUDA_API_KEY,
|
|
23
|
+
process.env.BUDA_API_SECRET,
|
|
24
|
+
);
|
|
18
25
|
const TEST_MARKET = "BTC-CLP";
|
|
19
26
|
|
|
20
27
|
function section(title: string): void {
|
|
@@ -132,6 +139,120 @@ try {
|
|
|
132
139
|
failures++;
|
|
133
140
|
}
|
|
134
141
|
|
|
142
|
+
// ----------------------------------------------------------------
|
|
143
|
+
// 6. get_spread
|
|
144
|
+
// ----------------------------------------------------------------
|
|
145
|
+
section(`get_spread — ${TEST_MARKET}`);
|
|
146
|
+
try {
|
|
147
|
+
const data = await client.get<TickerResponse>(`/markets/${TEST_MARKET.toLowerCase()}/ticker`);
|
|
148
|
+
const ticker = data.ticker;
|
|
149
|
+
const bid = parseFloat(ticker.max_bid[0]);
|
|
150
|
+
const ask = parseFloat(ticker.min_ask[0]);
|
|
151
|
+
const spreadAbs = ask - bid;
|
|
152
|
+
const spreadPct = (spreadAbs / ask) * 100;
|
|
153
|
+
pass("best_bid", ticker.max_bid[0]);
|
|
154
|
+
pass("best_ask", ticker.min_ask[0]);
|
|
155
|
+
pass("spread_absolute", spreadAbs.toFixed(2));
|
|
156
|
+
pass("spread_percentage", spreadPct.toFixed(4) + "%");
|
|
157
|
+
} catch (err) {
|
|
158
|
+
fail("get_spread", err);
|
|
159
|
+
failures++;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// ----------------------------------------------------------------
|
|
163
|
+
// 7. compare_markets
|
|
164
|
+
// ----------------------------------------------------------------
|
|
165
|
+
section("compare_markets — BTC");
|
|
166
|
+
try {
|
|
167
|
+
const data = await client.get<AllTickersResponse>("/tickers");
|
|
168
|
+
const btcMarkets = data.tickers.filter((t) => t.market_id.startsWith("BTC-"));
|
|
169
|
+
pass("BTC markets found", `${btcMarkets.length}`);
|
|
170
|
+
for (const t of btcMarkets) {
|
|
171
|
+
pass(t.market_id, `last price: ${t.last_price[0]} ${t.last_price[1]}`);
|
|
172
|
+
}
|
|
173
|
+
} catch (err) {
|
|
174
|
+
fail("compare_markets", err);
|
|
175
|
+
failures++;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ----------------------------------------------------------------
|
|
179
|
+
// 8. get_price_history (OHLCV from trades)
|
|
180
|
+
// ----------------------------------------------------------------
|
|
181
|
+
section(`get_price_history — ${TEST_MARKET} (period: 1h)`);
|
|
182
|
+
try {
|
|
183
|
+
const data = await client.get<TradesResponse>(
|
|
184
|
+
`/markets/${TEST_MARKET.toLowerCase()}/trades`,
|
|
185
|
+
{ limit: 100 },
|
|
186
|
+
);
|
|
187
|
+
const entries = data.trades.entries;
|
|
188
|
+
pass("trades fetched", `${entries.length}`);
|
|
189
|
+
|
|
190
|
+
if (entries.length > 0) {
|
|
191
|
+
const periodMs = 60 * 60 * 1000;
|
|
192
|
+
const buckets = new Map<number, { open: string; high: string; low: string; close: string; count: number }>();
|
|
193
|
+
for (const [tsMs, , price] of entries) {
|
|
194
|
+
const ts = parseInt(tsMs, 10);
|
|
195
|
+
const bucket = Math.floor(ts / periodMs) * periodMs;
|
|
196
|
+
const p = parseFloat(price);
|
|
197
|
+
if (!buckets.has(bucket)) {
|
|
198
|
+
buckets.set(bucket, { open: price, high: price, low: price, close: price, count: 1 });
|
|
199
|
+
} else {
|
|
200
|
+
const c = buckets.get(bucket)!;
|
|
201
|
+
if (p > parseFloat(c.high)) c.high = price;
|
|
202
|
+
if (p < parseFloat(c.low)) c.low = price;
|
|
203
|
+
c.close = price;
|
|
204
|
+
c.count++;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
pass("candles generated (1h)", `${buckets.size}`);
|
|
208
|
+
const firstCandle = Array.from(buckets.values())[0];
|
|
209
|
+
pass("first candle OHLC", `O:${firstCandle.open} H:${firstCandle.high} L:${firstCandle.low} C:${firstCandle.close}`);
|
|
210
|
+
}
|
|
211
|
+
} catch (err) {
|
|
212
|
+
fail("get_price_history", err);
|
|
213
|
+
failures++;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// ----------------------------------------------------------------
|
|
217
|
+
// Auth tools: get_balances, get_orders, place_order, cancel_order
|
|
218
|
+
// ----------------------------------------------------------------
|
|
219
|
+
section("Auth tools — get_balances, get_orders, place_order, cancel_order");
|
|
220
|
+
|
|
221
|
+
if (!client.hasAuth()) {
|
|
222
|
+
console.log(" Skipping: BUDA_API_KEY not set");
|
|
223
|
+
console.log(" (Set BUDA_API_KEY + BUDA_API_SECRET env vars to run auth tests)");
|
|
224
|
+
} else {
|
|
225
|
+
// get_balances
|
|
226
|
+
try {
|
|
227
|
+
const data = await client.get<BalancesResponse>("/balances");
|
|
228
|
+
const nonZero = data.balances.filter((b) => parseFloat(b.amount[0]) > 0);
|
|
229
|
+
pass("get_balances", `${data.balances.length} currencies, ${nonZero.length} with balance`);
|
|
230
|
+
} catch (err) {
|
|
231
|
+
fail("get_balances", err);
|
|
232
|
+
failures++;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// get_orders
|
|
236
|
+
try {
|
|
237
|
+
const data = await client.get<OrdersResponse>(
|
|
238
|
+
`/markets/${TEST_MARKET.toLowerCase()}/orders`,
|
|
239
|
+
{ state: "pending", per: 10 },
|
|
240
|
+
);
|
|
241
|
+
pass("get_orders (pending)", `${data.orders.length} orders, page ${data.meta.current_page}/${data.meta.total_pages}`);
|
|
242
|
+
} catch (err) {
|
|
243
|
+
fail("get_orders", err);
|
|
244
|
+
failures++;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// place_order — confirmation guard test (must reject without CONFIRM)
|
|
248
|
+
console.log(" Skipping: place_order live execution (destructive — requires confirmation_token=CONFIRM)");
|
|
249
|
+
pass("place_order guard", "confirmation_token check enforced at tool layer (code-audited)");
|
|
250
|
+
|
|
251
|
+
// cancel_order — confirmation guard test (must reject without CONFIRM)
|
|
252
|
+
console.log(" Skipping: cancel_order live execution (destructive — requires confirmation_token=CONFIRM)");
|
|
253
|
+
pass("cancel_order guard", "confirmation_token check enforced at tool layer (code-audited)");
|
|
254
|
+
}
|
|
255
|
+
|
|
135
256
|
// ----------------------------------------------------------------
|
|
136
257
|
// Summary
|
|
137
258
|
// ----------------------------------------------------------------
|