@guiie/buda-mcp 1.4.2 → 1.5.1
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/.cursor/rules/marketplace-docs-sync.mdc +32 -0
- package/CHANGELOG.md +79 -0
- package/PUBLISH_CHECKLIST.md +40 -88
- package/README.md +446 -78
- package/dist/cache.d.ts +1 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +18 -1
- package/dist/http.js +97 -6
- package/dist/index.js +42 -3
- package/dist/tools/account.d.ts +19 -0
- package/dist/tools/account.d.ts.map +1 -0
- package/dist/tools/account.js +49 -0
- package/dist/tools/balance.d.ts +29 -0
- package/dist/tools/balance.d.ts.map +1 -0
- package/dist/tools/balance.js +72 -0
- package/dist/tools/banks.d.ts +28 -0
- package/dist/tools/banks.d.ts.map +1 -0
- package/dist/tools/banks.js +68 -0
- package/dist/tools/batch_orders.d.ts +82 -0
- package/dist/tools/batch_orders.d.ts.map +1 -0
- package/dist/tools/batch_orders.js +188 -0
- package/dist/tools/cancel_all_orders.d.ts +34 -0
- package/dist/tools/cancel_all_orders.d.ts.map +1 -0
- package/dist/tools/cancel_all_orders.js +89 -0
- package/dist/tools/cancel_order.js +1 -1
- package/dist/tools/cancel_order_by_client_id.d.ts +34 -0
- package/dist/tools/cancel_order_by_client_id.d.ts.map +1 -0
- package/dist/tools/cancel_order_by_client_id.js +102 -0
- package/dist/tools/dead_mans_switch.d.ts +1 -1
- package/dist/tools/dead_mans_switch.d.ts.map +1 -1
- package/dist/tools/dead_mans_switch.js +33 -3
- package/dist/tools/deposits.d.ts +83 -0
- package/dist/tools/deposits.d.ts.map +1 -0
- package/dist/tools/deposits.js +174 -0
- package/dist/tools/fees.d.ts +34 -0
- package/dist/tools/fees.d.ts.map +1 -0
- package/dist/tools/fees.js +72 -0
- package/dist/tools/lightning.d.ts +68 -0
- package/dist/tools/lightning.d.ts.map +1 -0
- package/dist/tools/lightning.js +185 -0
- package/dist/tools/order_lookup.d.ts +50 -0
- package/dist/tools/order_lookup.d.ts.map +1 -0
- package/dist/tools/order_lookup.js +112 -0
- package/dist/tools/place_order.d.ts +30 -0
- package/dist/tools/place_order.d.ts.map +1 -1
- package/dist/tools/place_order.js +131 -2
- package/dist/tools/quotation.d.ts +44 -0
- package/dist/tools/quotation.d.ts.map +1 -0
- package/dist/tools/quotation.js +99 -0
- package/dist/tools/receive_addresses.d.ts +83 -0
- package/dist/tools/receive_addresses.d.ts.map +1 -0
- package/dist/tools/receive_addresses.js +185 -0
- package/dist/tools/remittance_recipients.d.ts +54 -0
- package/dist/tools/remittance_recipients.d.ts.map +1 -0
- package/dist/tools/remittance_recipients.js +106 -0
- package/dist/tools/remittances.d.ts +120 -0
- package/dist/tools/remittances.d.ts.map +1 -0
- package/dist/tools/remittances.js +261 -0
- package/dist/tools/simulate_order.d.ts.map +1 -1
- package/dist/tools/simulate_order.js +2 -1
- package/dist/tools/technical_indicators.d.ts.map +1 -1
- package/dist/tools/technical_indicators.js +2 -1
- package/dist/tools/withdrawals.d.ts +93 -0
- package/dist/tools/withdrawals.d.ts.map +1 -0
- package/dist/tools/withdrawals.js +225 -0
- package/dist/types.d.ts +155 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +4 -1
- package/dist/validation.d.ts +11 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/validation.js +38 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +8 -1
- package/marketplace/README.md +1 -1
- package/marketplace/claude-listing.md +101 -2
- package/marketplace/gemini-tools.json +478 -1
- package/marketplace/openapi.yaml +160 -1
- package/package.json +2 -1
- package/server.json +2 -2
- package/src/cache.ts +1 -0
- package/src/client.ts +23 -1
- package/src/http.ts +105 -6
- package/src/index.ts +40 -3
- package/src/tools/account.ts +66 -0
- package/src/tools/balance.ts +94 -0
- package/src/tools/banks.ts +94 -0
- package/src/tools/batch_orders.ts +238 -0
- package/src/tools/cancel_all_orders.ts +117 -0
- package/src/tools/cancel_order.ts +1 -1
- package/src/tools/cancel_order_by_client_id.ts +132 -0
- package/src/tools/dead_mans_switch.ts +39 -3
- package/src/tools/deposits.ts +230 -0
- package/src/tools/fees.ts +91 -0
- package/src/tools/lightning.ts +247 -0
- package/src/tools/order_lookup.ts +139 -0
- package/src/tools/place_order.ts +151 -2
- package/src/tools/quotation.ts +124 -0
- package/src/tools/receive_addresses.ts +242 -0
- package/src/tools/remittance_recipients.ts +139 -0
- package/src/tools/remittances.ts +325 -0
- package/src/tools/simulate_order.ts +1 -0
- package/src/tools/technical_indicators.ts +2 -1
- package/src/tools/withdrawals.ts +287 -0
- package/src/types.ts +210 -0
- package/src/utils.ts +3 -1
- package/src/validation.ts +45 -0
- package/src/version.ts +11 -3
- package/test/run-all.ts +16 -0
- package/test/unit.ts +2149 -1
package/src/types.ts
CHANGED
|
@@ -145,3 +145,213 @@ export interface OhlcvCandle {
|
|
|
145
145
|
volume: number;
|
|
146
146
|
trade_count: number;
|
|
147
147
|
}
|
|
148
|
+
|
|
149
|
+
// ----- Pagination -----
|
|
150
|
+
|
|
151
|
+
export interface PaginationMeta {
|
|
152
|
+
current_page: number;
|
|
153
|
+
total_count: number;
|
|
154
|
+
total_pages: number;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ----- Account (private) -----
|
|
158
|
+
|
|
159
|
+
export interface MeResponse {
|
|
160
|
+
me: {
|
|
161
|
+
id: number;
|
|
162
|
+
email: string;
|
|
163
|
+
name: string | null;
|
|
164
|
+
monthly_transacted: Amount;
|
|
165
|
+
pubsub_key: string | null;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// ----- Single Balance (private) -----
|
|
170
|
+
|
|
171
|
+
export interface SingleBalanceResponse {
|
|
172
|
+
balance: Balance;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ----- Network Fees (private) -----
|
|
176
|
+
|
|
177
|
+
export interface Fee {
|
|
178
|
+
name: string;
|
|
179
|
+
fee_type: string;
|
|
180
|
+
base_fee: Amount;
|
|
181
|
+
percent: string | null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface FeesResponse {
|
|
185
|
+
fees: Fee[];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ----- Deposits (private) -----
|
|
189
|
+
|
|
190
|
+
export interface Deposit {
|
|
191
|
+
id: number;
|
|
192
|
+
state: string;
|
|
193
|
+
currency: string;
|
|
194
|
+
amount: Amount;
|
|
195
|
+
fee: Amount;
|
|
196
|
+
created_at: string;
|
|
197
|
+
updated_at: string;
|
|
198
|
+
transfer_account_id: number | null;
|
|
199
|
+
transaction_hash: string | null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface DepositsResponse {
|
|
203
|
+
deposits: Deposit[];
|
|
204
|
+
meta: PaginationMeta;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface SingleDepositResponse {
|
|
208
|
+
deposit: Deposit;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// ----- Withdrawals (private) -----
|
|
212
|
+
|
|
213
|
+
export interface Withdrawal {
|
|
214
|
+
id: number;
|
|
215
|
+
state: string;
|
|
216
|
+
currency: string;
|
|
217
|
+
amount: Amount;
|
|
218
|
+
fee: Amount;
|
|
219
|
+
address: string | null;
|
|
220
|
+
tx_hash: string | null;
|
|
221
|
+
bank_account_id: number | null;
|
|
222
|
+
created_at: string;
|
|
223
|
+
updated_at: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface WithdrawalsResponse {
|
|
227
|
+
withdrawals: Withdrawal[];
|
|
228
|
+
meta: PaginationMeta;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export interface SingleWithdrawalResponse {
|
|
232
|
+
withdrawal: Withdrawal;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ----- Receive Addresses (private) -----
|
|
236
|
+
|
|
237
|
+
export interface ReceiveAddress {
|
|
238
|
+
id: number;
|
|
239
|
+
address: string;
|
|
240
|
+
currency: string;
|
|
241
|
+
created_at: string;
|
|
242
|
+
label: string | null;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface ReceiveAddressesResponse {
|
|
246
|
+
receive_addresses: ReceiveAddress[];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface SingleReceiveAddressResponse {
|
|
250
|
+
receive_address: ReceiveAddress;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ----- Remittances (private) -----
|
|
254
|
+
|
|
255
|
+
export interface Remittance {
|
|
256
|
+
id: number;
|
|
257
|
+
state: string;
|
|
258
|
+
currency: string;
|
|
259
|
+
amount: Amount;
|
|
260
|
+
recipient_id: number | null;
|
|
261
|
+
created_at: string;
|
|
262
|
+
expires_at: string | null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export interface RemittancesResponse {
|
|
266
|
+
remittances: Remittance[];
|
|
267
|
+
meta: PaginationMeta;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface SingleRemittanceResponse {
|
|
271
|
+
remittance: Remittance;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ----- Remittance Recipients (private) -----
|
|
275
|
+
|
|
276
|
+
export interface RemittanceRecipient {
|
|
277
|
+
id: number;
|
|
278
|
+
name: string;
|
|
279
|
+
bank: string;
|
|
280
|
+
account_number: string;
|
|
281
|
+
currency: string;
|
|
282
|
+
country: string | null;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface RemittanceRecipientsResponse {
|
|
286
|
+
remittance_recipients: RemittanceRecipient[];
|
|
287
|
+
meta: PaginationMeta;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface SingleRemittanceRecipientResponse {
|
|
291
|
+
remittance_recipient: RemittanceRecipient;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// ----- Quotations (public) -----
|
|
295
|
+
|
|
296
|
+
export interface Quotation {
|
|
297
|
+
id: number | null;
|
|
298
|
+
type: string;
|
|
299
|
+
market_id: string;
|
|
300
|
+
amount: Amount;
|
|
301
|
+
limit: Amount | null;
|
|
302
|
+
base_balance_change: Amount;
|
|
303
|
+
quote_balance_change: Amount;
|
|
304
|
+
fee_amount: Amount;
|
|
305
|
+
order_amount: Amount;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export interface QuotationResponse {
|
|
309
|
+
quotation: Quotation;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// ----- Banks (public) -----
|
|
313
|
+
|
|
314
|
+
export interface Bank {
|
|
315
|
+
id: string;
|
|
316
|
+
name: string;
|
|
317
|
+
country: string | null;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export interface BanksResponse {
|
|
321
|
+
banks: Bank[];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ----- Cancel All Orders (private) -----
|
|
325
|
+
|
|
326
|
+
export interface CancelAllOrdersResponse {
|
|
327
|
+
canceled_count: number;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// ----- Lightning (private) -----
|
|
331
|
+
|
|
332
|
+
export interface LightningWithdrawal {
|
|
333
|
+
id: number;
|
|
334
|
+
state: string;
|
|
335
|
+
amount: Amount;
|
|
336
|
+
fee: Amount;
|
|
337
|
+
payment_hash: string;
|
|
338
|
+
created_at: string;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export interface LightningWithdrawalResponse {
|
|
342
|
+
lightning_withdrawal: LightningWithdrawal;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export interface LightningInvoice {
|
|
346
|
+
id: number;
|
|
347
|
+
payment_request: string;
|
|
348
|
+
amount: Amount;
|
|
349
|
+
description: string | null;
|
|
350
|
+
expires_at: string;
|
|
351
|
+
state: string;
|
|
352
|
+
created_at: string;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export interface LightningInvoiceResponse {
|
|
356
|
+
lightning_network_invoice: LightningInvoice;
|
|
357
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -5,7 +5,9 @@ import type { Amount, OhlcvCandle } from "./types.js";
|
|
|
5
5
|
* All numeric strings are cast to float via parseFloat.
|
|
6
6
|
*/
|
|
7
7
|
export function flattenAmount(amount: Amount): { value: number; currency: string } {
|
|
8
|
-
|
|
8
|
+
const value = parseFloat(amount[0]);
|
|
9
|
+
if (isNaN(value)) throw new Error(`Invalid amount value: "${amount[0]}"`);
|
|
10
|
+
return { value, currency: amount[1] };
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
/**
|
package/src/validation.ts
CHANGED
|
@@ -14,3 +14,48 @@ export function validateMarketId(id: string): string | null {
|
|
|
14
14
|
}
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
const CURRENCY_RE = /^[A-Z0-9]{2,10}$/i;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Validates a currency code (e.g. "BTC", "CLP", "USDC").
|
|
22
|
+
* Returns an error message string if invalid, or null if valid.
|
|
23
|
+
*/
|
|
24
|
+
export function validateCurrency(id: string): string | null {
|
|
25
|
+
if (!CURRENCY_RE.test(id)) {
|
|
26
|
+
return (
|
|
27
|
+
`Invalid currency "${id}". ` +
|
|
28
|
+
`Expected 2–10 alphanumeric characters (e.g. "BTC", "CLP", "USDC").`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Per-currency address format rules.
|
|
35
|
+
// Unknown currencies pass through (undefined rule) — the exchange validates those.
|
|
36
|
+
const ADDRESS_RULES: Record<string, RegExp> = {
|
|
37
|
+
BTC: /^(bc1[a-z0-9]{6,87}|[13][a-zA-HJ-NP-Z0-9]{25,34})$/,
|
|
38
|
+
ETH: /^0x[0-9a-fA-F]{40}$/,
|
|
39
|
+
USDC: /^0x[0-9a-fA-F]{40}$/,
|
|
40
|
+
USDT: /^0x[0-9a-fA-F]{40}$/,
|
|
41
|
+
LTC: /^(ltc1[a-z0-9]{6,87}|[LM3][a-zA-HJ-NP-Z0-9]{25,34})$/,
|
|
42
|
+
BCH: /^(bitcoincash:)?[qp][a-z0-9]{41}$/,
|
|
43
|
+
XRP: /^r[1-9A-HJ-NP-Za-km-z]{24,33}$/,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Validates a crypto withdrawal address against known per-currency formats.
|
|
48
|
+
* Returns an error message string if the address is invalid, or null if valid
|
|
49
|
+
* (including null for unknown currencies, where the exchange is the last line of defence).
|
|
50
|
+
*/
|
|
51
|
+
export function validateCryptoAddress(address: string, currency: string): string | null {
|
|
52
|
+
const rule = ADDRESS_RULES[currency.toUpperCase()];
|
|
53
|
+
if (!rule) return null;
|
|
54
|
+
if (!rule.test(address)) {
|
|
55
|
+
return (
|
|
56
|
+
`Invalid ${currency.toUpperCase()} address format. ` +
|
|
57
|
+
`Double-check the destination address — crypto withdrawals are irreversible.`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -3,6 +3,14 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
import { dirname, join } from "path";
|
|
4
4
|
|
|
5
5
|
const _dir = dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
|
|
7
|
+
let _version = "unknown";
|
|
8
|
+
try {
|
|
9
|
+
_version = (
|
|
10
|
+
JSON.parse(readFileSync(join(_dir, "../package.json"), "utf8")) as { version: string }
|
|
11
|
+
).version;
|
|
12
|
+
} catch {
|
|
13
|
+
// package.json not found in deployment — use fallback
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const VERSION: string = _version;
|
package/test/run-all.ts
CHANGED
|
@@ -3,9 +3,25 @@
|
|
|
3
3
|
* and prints a summary of the results.
|
|
4
4
|
*
|
|
5
5
|
* Run with: npm run test:integration
|
|
6
|
+
* Auth tools (balances, orders, DMS) are tested automatically if a .env file with
|
|
7
|
+
* BUDA_API_KEY and BUDA_API_SECRET exists in the project root (already in .gitignore).
|
|
6
8
|
* Skipped automatically when the Buda API is unreachable (CI without network).
|
|
7
9
|
*/
|
|
8
10
|
|
|
11
|
+
// Load .env if present (never committed — see .gitignore)
|
|
12
|
+
import { existsSync, readFileSync } from "fs";
|
|
13
|
+
if (existsSync(".env")) {
|
|
14
|
+
for (const line of readFileSync(".env", "utf8").split("\n")) {
|
|
15
|
+
const trimmed = line.trim();
|
|
16
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
17
|
+
const eqIdx = trimmed.indexOf("=");
|
|
18
|
+
if (eqIdx === -1) continue;
|
|
19
|
+
const key = trimmed.slice(0, eqIdx).trim();
|
|
20
|
+
const val = trimmed.slice(eqIdx + 1).trim().replace(/^["']|["']$/g, "");
|
|
21
|
+
if (key && !(key in process.env)) process.env[key] = val;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
9
25
|
// Connectivity pre-check — skip gracefully instead of failing CI when the API is unreachable.
|
|
10
26
|
try {
|
|
11
27
|
await fetch("https://www.buda.com/api/v2/markets.json", {
|