gate-mcp 0.1.4 → 0.2.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/README.md CHANGED
@@ -8,7 +8,7 @@ A local (stdio) MCP server that exposes the full [Gate.com](https://www.gate.com
8
8
 
9
9
  ## Features
10
10
 
11
- - **86 tools** covering Spot, Futures, Delivery, Margin, Wallet, Account, Options, Earn, and Flash Swap APIs
11
+ - **148 tools** covering Spot, Futures, Delivery, Margin, Wallet, Account, Options, Earn, Flash Swap, Unified, and Sub-Account APIs
12
12
  - **Zero config for public endpoints** — market data, tickers, order books work without any credentials
13
13
  - **Authenticated endpoints** — trading, wallet, and account tools activate automatically when `GATE_API_KEY` + `GATE_API_SECRET` env vars are set
14
14
  - **Testnet support** — set `GATE_BASE_URL` to use the testnet endpoint
@@ -73,11 +73,11 @@ A local (stdio) MCP server that exposes the full [Gate.com](https://www.gate.com
73
73
 
74
74
  ## Available Tools
75
75
 
76
- ### Spot (19 tools)
77
- `list_currencies`, `get_currency`, `list_currency_pairs`, `get_currency_pair`, `list_tickers`, `list_order_book`, `list_trades`, `list_candlesticks`, `get_fee`*, `list_spot_accounts`*, `list_orders`*, `create_order`*, `get_order`*, `cancel_order`*, `amend_order`*, `cancel_orders`*, `list_my_trades`*, `list_all_open_orders`*, `list_spot_price_triggered_orders`*
76
+ ### Spot (28 tools)
77
+ `list_currencies`, `get_currency`, `list_currency_pairs`, `get_currency_pair`, `list_tickers`, `list_order_book`, `list_trades`, `list_candlesticks`, `get_fee`*, `list_spot_accounts`*, `list_spot_account_book`*, `list_orders`*, `create_order`*, `get_order`*, `cancel_order`*, `amend_order`*, `cancel_orders`*, `create_batch_orders`*, `cancel_batch_orders`*, `get_batch_spot_fee`*, `list_my_trades`*, `list_all_open_orders`*, `list_spot_price_triggered_orders`*, `create_spot_price_triggered_order`*, `get_spot_price_triggered_order`*, `cancel_spot_price_triggered_order`*, `cancel_spot_price_triggered_order_list`*, `countdown_cancel_all_spot`*
78
78
 
79
- ### Futures (16 tools)
80
- `list_futures_contracts`, `get_futures_contract`, `list_futures_order_book`, `list_futures_candlesticks`, `list_futures_tickers`, `list_futures_funding_rate_history`, `list_futures_accounts`*, `list_positions`*, `get_position`*, `list_futures_orders`*, `create_futures_order`*, `get_futures_order`*, `cancel_futures_order`*, `amend_futures_order`*, `get_my_futures_trades`*, `list_position_close`*, `list_price_triggered_orders`*
79
+ ### Futures (37 tools)
80
+ `list_futures_contracts`, `get_futures_contract`, `list_futures_order_book`, `list_futures_candlesticks`, `list_futures_tickers`, `list_futures_funding_rate_history`, `list_futures_trades`, `list_contract_stats`, `list_futures_premium_index`, `list_futures_accounts`*, `list_futures_account_book`*, `get_futures_fee`*, `list_positions`*, `get_position`*, `get_leverage`*, `update_position_leverage`*, `update_position_margin`*, `update_position_risk_limit`*, `list_futures_orders`*, `create_futures_order`*, `get_futures_order`*, `cancel_futures_order`*, `cancel_futures_orders`*, `amend_futures_order`*, `create_batch_futures_orders`*, `cancel_batch_futures_orders`*, `get_futures_orders_with_time_range`*, `get_my_futures_trades`*, `get_my_futures_trades_with_time_range`*, `list_position_close`*, `list_liquidates`*, `list_price_triggered_orders`*, `create_futures_price_triggered_order`*, `get_futures_price_triggered_order`*, `cancel_futures_price_triggered_order`*, `cancel_futures_price_triggered_order_list`*, `countdown_cancel_all_futures`*
81
81
 
82
82
  ### Delivery (11 tools)
83
83
  `list_delivery_contracts`, `get_delivery_contract`, `list_delivery_order_book`, `list_delivery_candlesticks`, `list_delivery_tickers`, `list_delivery_accounts`*, `list_delivery_positions`*, `list_delivery_orders`*, `create_delivery_order`*, `cancel_delivery_order`*, `get_my_delivery_trades`*
@@ -88,11 +88,11 @@ A local (stdio) MCP server that exposes the full [Gate.com](https://www.gate.com
88
88
  ### Wallet (9 tools)
89
89
  `get_total_balance`*, `list_withdrawals`*, `list_deposits`*, `get_deposit_address`*, `transfer`*, `list_sub_account_balances`*, `get_trade_fee`*, `list_currency_chains`, `list_withdraw_status`*
90
90
 
91
- ### Account (3 tools)
92
- `get_account_detail`*, `get_account_rate_limit`*, `get_debit_fee`*
91
+ ### Account (10 tools)
92
+ `get_account_detail`*, `get_account_rate_limit`*, `get_debit_fee`*, `set_debit_fee`*, `get_account_main_keys`*, `list_stp_groups`*, `create_stp_group`*, `list_stp_group_users`*, `add_stp_group_users`*, `delete_stp_group_user`*
93
93
 
94
94
  ### Options (13 tools)
95
- `list_options_underlyings`, `list_options_expirations`, `list_options_contracts`, `list_options_order_book`, `list_options_tickers`, `list_options_candlesticks`, `list_options_account`*, `list_options_positions`*, `list_options_orders`*, `create_options_order`*, `cancel_options_order`*, `list_my_options_trades`*
95
+ `list_options_underlyings`, `list_options_expirations`, `list_options_contracts`, `get_options_contract`, `list_options_order_book`, `list_options_tickers`, `list_options_candlesticks`, `list_options_account`*, `list_options_positions`*, `list_options_orders`*, `create_options_order`*, `cancel_options_order`*, `list_my_options_trades`*
96
96
 
97
97
  ### Earn (5 tools)
98
98
  `list_dual_investment_plans`, `list_dual_orders`*, `list_dual_balance`*, `list_structured_products`, `list_structured_orders`*
@@ -100,6 +100,12 @@ A local (stdio) MCP server that exposes the full [Gate.com](https://www.gate.com
100
100
  ### Flash Swap (5 tools)
101
101
  `list_flash_swap_currency_pairs`, `preview_flash_swap_order`*, `create_flash_swap_order`*, `list_flash_swap_orders`*, `get_flash_swap_order`*
102
102
 
103
+ ### Unified Account (16 tools)
104
+ `list_unified_accounts`*, `list_unified_currencies`*, `get_unified_mode`*, `set_unified_mode`*, `get_unified_risk_units`*, `get_unified_borrowable`*, `get_unified_transferable`*, `get_unified_estimate_rate`*, `list_unified_loans`*, `create_unified_loan`*, `list_unified_loan_records`*, `list_unified_loan_interest_records`*, `list_currency_discount_tiers`, `get_user_leverage_currency_setting`*, `set_user_leverage_currency_setting`*, `set_unified_collateral`*
105
+
106
+ ### Sub-Account (9 tools)
107
+ `list_sub_accounts`*, `create_sub_account`*, `get_sub_account`*, `lock_sub_account`*, `unlock_sub_account`*, `list_sub_account_keys`*, `get_sub_account_key`*, `create_sub_account_keys`*, `delete_sub_account_key`*
108
+
103
109
  *\* Requires authentication (`GATE_API_KEY` + `GATE_API_SECRET`)*
104
110
 
105
111
  ## Development
package/dist/index.js CHANGED
@@ -10,6 +10,8 @@ import { registerAccountTools } from './tools/account.js';
10
10
  import { registerOptionsTools } from './tools/options.js';
11
11
  import { registerEarnTools } from './tools/earn.js';
12
12
  import { registerFlashSwapTools } from './tools/flash_swap.js';
13
+ import { registerUnifiedTools } from './tools/unified.js';
14
+ import { registerSubAccountTools } from './tools/sub_account.js';
13
15
  const server = new McpServer({
14
16
  name: 'gate',
15
17
  version: '0.1.0',
@@ -23,6 +25,8 @@ registerAccountTools(server);
23
25
  registerOptionsTools(server);
24
26
  registerEarnTools(server);
25
27
  registerFlashSwapTools(server);
28
+ registerUnifiedTools(server);
29
+ registerSubAccountTools(server);
26
30
  const transport = new StdioServerTransport();
27
31
  await server.connect(transport);
28
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,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,iBAAiB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC1B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7B,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC9B,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC5B,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAC5B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7B,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC1B,sBAAsB,CAAC,MAAM,CAAC,CAAC;AAC/B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7B,uBAAuB,CAAC,MAAM,CAAC,CAAC;AAEhC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAuC5D"}
1
+ {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAMpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA0I5D"}
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  import { AccountApi } from 'gate-api';
2
3
  import { createClient, requireAuth } from '../client.js';
3
4
  import { textContent, errorContent } from '../utils.js';
@@ -32,5 +33,84 @@ export function registerAccountTools(server) {
32
33
  return errorContent(e);
33
34
  }
34
35
  });
36
+ server.tool('set_debit_fee', 'Enable or disable GT debit fee (requires authentication)', { enabled: z.boolean().describe('true to pay fees with GT, false to disable') }, async ({ enabled }) => {
37
+ try {
38
+ requireAuth();
39
+ const { body } = await new AccountApi(createClient()).setDebitFee({ enabled });
40
+ return textContent(body ?? { success: true });
41
+ }
42
+ catch (e) {
43
+ return errorContent(e);
44
+ }
45
+ });
46
+ server.tool('get_account_main_keys', 'Get main account API key info (requires authentication)', {}, async () => {
47
+ try {
48
+ requireAuth();
49
+ const { body } = await new AccountApi(createClient()).getAccountMainKeys();
50
+ return textContent(body);
51
+ }
52
+ catch (e) {
53
+ return errorContent(e);
54
+ }
55
+ });
56
+ server.tool('list_stp_groups', 'List Self-Trade Prevention (STP) groups (requires authentication)', { name: z.string().optional().describe('Filter by group name') }, async ({ name }) => {
57
+ try {
58
+ requireAuth();
59
+ const opts = {};
60
+ if (name)
61
+ opts.name = name;
62
+ const { body } = await new AccountApi(createClient()).listSTPGroups(opts);
63
+ return textContent(body);
64
+ }
65
+ catch (e) {
66
+ return errorContent(e);
67
+ }
68
+ });
69
+ server.tool('create_stp_group', 'Create a Self-Trade Prevention (STP) group (requires authentication)', { name: z.string().describe('STP group name') }, async ({ name }) => {
70
+ try {
71
+ requireAuth();
72
+ const { body } = await new AccountApi(createClient()).createSTPGroup({ name });
73
+ return textContent(body);
74
+ }
75
+ catch (e) {
76
+ return errorContent(e);
77
+ }
78
+ });
79
+ server.tool('list_stp_group_users', 'List users in an STP group (requires authentication)', { stp_id: z.number().int().describe('STP group ID') }, async ({ stp_id }) => {
80
+ try {
81
+ requireAuth();
82
+ const { body } = await new AccountApi(createClient()).listSTPGroupsUsers(stp_id);
83
+ return textContent(body);
84
+ }
85
+ catch (e) {
86
+ return errorContent(e);
87
+ }
88
+ });
89
+ server.tool('add_stp_group_users', 'Add users to an STP group (requires authentication)', {
90
+ stp_id: z.number().int().describe('STP group ID'),
91
+ user_ids: z.array(z.number().int()).describe('List of user IDs to add'),
92
+ }, async ({ stp_id, user_ids }) => {
93
+ try {
94
+ requireAuth();
95
+ const { body } = await new AccountApi(createClient()).addSTPGroupUsers(stp_id, user_ids);
96
+ return textContent(body);
97
+ }
98
+ catch (e) {
99
+ return errorContent(e);
100
+ }
101
+ });
102
+ server.tool('delete_stp_group_user', 'Remove a user from an STP group (requires authentication)', {
103
+ stp_id: z.number().int().describe('STP group ID'),
104
+ user_id: z.number().int().describe('User ID to remove'),
105
+ }, async ({ stp_id, user_id }) => {
106
+ try {
107
+ requireAuth();
108
+ const { body } = await new AccountApi(createClient()).deleteSTPGroupUsers(stp_id, user_id);
109
+ return textContent(body);
110
+ }
111
+ catch (e) {
112
+ return errorContent(e);
113
+ }
114
+ });
35
115
  }
36
116
  //# sourceMappingURL=account.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/tools/account.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,UAAU,oBAAoB,CAAC,MAAiB;IACpD,MAAM,CAAC,IAAI,CACT,oBAAoB,EACpB,iEAAiE,EACjE,EAAE,EACF,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,WAAW,EAAE,CAAC;YACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC;YACzE,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;QAC3B,CA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F,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC;IACzC,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"futures.d.ts","sourceRoot":"","sources":["../../src/tools/futures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAqU5D"}
1
+ {"version":3,"file":"futures.d.ts","sourceRoot":"","sources":["../../src/tools/futures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2vB5D"}
@@ -302,5 +302,427 @@ export function registerFuturesTools(server) {
302
302
  return errorContent(e);
303
303
  }
304
304
  });
305
+ // ── Additional public tools ────────────────────────────────────────────────
306
+ server.tool('list_futures_trades', 'Get recent public trades for a futures contract', {
307
+ settle: settleSchema,
308
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
309
+ limit: z.number().int().optional(),
310
+ from: z.number().optional().describe('Start time (Unix timestamp)'),
311
+ to: z.number().optional().describe('End time (Unix timestamp)'),
312
+ }, async ({ settle, contract, limit, from, to }) => {
313
+ try {
314
+ const opts = {};
315
+ if (limit !== undefined)
316
+ opts.limit = limit;
317
+ if (from !== undefined)
318
+ opts.from = from;
319
+ if (to !== undefined)
320
+ opts.to = to;
321
+ const { body } = await new FuturesApi(createClient()).listFuturesTrades(settle, contract, opts);
322
+ return textContent(body);
323
+ }
324
+ catch (e) {
325
+ return errorContent(e);
326
+ }
327
+ });
328
+ server.tool('list_contract_stats', 'Get contract statistics (open interest, long/short ratio, etc.)', {
329
+ settle: settleSchema,
330
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
331
+ from: z.number().optional().describe('Start time (Unix timestamp)'),
332
+ interval: z.enum(['5m', '15m', '30m', '1h', '4h', '1d']).optional(),
333
+ limit: z.number().int().optional(),
334
+ }, async ({ settle, contract, from, interval, limit }) => {
335
+ try {
336
+ const opts = {};
337
+ if (from !== undefined)
338
+ opts.from = from;
339
+ if (interval)
340
+ opts.interval = interval;
341
+ if (limit !== undefined)
342
+ opts.limit = limit;
343
+ const { body } = await new FuturesApi(createClient()).listContractStats(settle, contract, opts);
344
+ return textContent(body);
345
+ }
346
+ catch (e) {
347
+ return errorContent(e);
348
+ }
349
+ });
350
+ server.tool('list_futures_premium_index', 'Get premium index (mark price minus index price) history for a contract', {
351
+ settle: settleSchema,
352
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
353
+ from: z.number().optional().describe('Start time (Unix timestamp)'),
354
+ to: z.number().optional().describe('End time (Unix timestamp)'),
355
+ interval: z.enum(['1m', '5m', '15m', '30m', '1h', '4h', '8h', '1d', '7d']).optional(),
356
+ limit: z.number().int().optional(),
357
+ }, async ({ settle, contract, from, to, interval, limit }) => {
358
+ try {
359
+ const opts = {};
360
+ if (from !== undefined)
361
+ opts.from = from;
362
+ if (to !== undefined)
363
+ opts.to = to;
364
+ if (interval)
365
+ opts.interval = interval;
366
+ if (limit !== undefined)
367
+ opts.limit = limit;
368
+ const { body } = await new FuturesApi(createClient()).listFuturesPremiumIndex(settle, contract, opts);
369
+ return textContent(body);
370
+ }
371
+ catch (e) {
372
+ return errorContent(e);
373
+ }
374
+ });
375
+ // ── Additional private tools ───────────────────────────────────────────────
376
+ server.tool('list_futures_account_book', 'Get futures account transaction/ledger history (requires authentication)', {
377
+ settle: settleSchema,
378
+ contract: z.string().optional().describe('Filter by contract'),
379
+ from: z.number().optional().describe('Start time (Unix timestamp)'),
380
+ to: z.number().optional().describe('End time (Unix timestamp)'),
381
+ limit: z.number().int().optional(),
382
+ offset: z.number().int().optional(),
383
+ type: z.string().optional().describe('Entry type filter e.g. dnw, pnl, fee, refr, fund'),
384
+ }, async ({ settle, contract, from, to, limit, offset, type }) => {
385
+ try {
386
+ requireAuth();
387
+ const opts = {};
388
+ if (contract)
389
+ opts.contract = contract;
390
+ if (from !== undefined)
391
+ opts.from = from;
392
+ if (to !== undefined)
393
+ opts.to = to;
394
+ if (limit !== undefined)
395
+ opts.limit = limit;
396
+ if (offset !== undefined)
397
+ opts.offset = offset;
398
+ if (type)
399
+ opts.type = type;
400
+ const { body } = await new FuturesApi(createClient()).listFuturesAccountBook(settle, opts);
401
+ return textContent(body);
402
+ }
403
+ catch (e) {
404
+ return errorContent(e);
405
+ }
406
+ });
407
+ server.tool('get_futures_fee', 'Get futures trading fee rates (requires authentication)', {
408
+ settle: settleSchema,
409
+ contract: z.string().optional().describe('Filter by contract'),
410
+ }, async ({ settle, contract }) => {
411
+ try {
412
+ requireAuth();
413
+ const opts = {};
414
+ if (contract)
415
+ opts.contract = contract;
416
+ const { body } = await new FuturesApi(createClient()).getFuturesFee(settle, opts);
417
+ return textContent(body);
418
+ }
419
+ catch (e) {
420
+ return errorContent(e);
421
+ }
422
+ });
423
+ server.tool('get_leverage', 'Get current leverage for a futures position (requires authentication)', {
424
+ settle: settleSchema,
425
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
426
+ }, async ({ settle, contract }) => {
427
+ try {
428
+ requireAuth();
429
+ const { body } = await new FuturesApi(createClient()).getLeverage(settle, contract, {});
430
+ return textContent(body);
431
+ }
432
+ catch (e) {
433
+ return errorContent(e);
434
+ }
435
+ });
436
+ server.tool('update_position_leverage', 'Update leverage for a futures position (requires authentication) — always confirm the new leverage with the user before calling this tool', {
437
+ settle: settleSchema,
438
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
439
+ leverage: z.string().describe('New leverage value; 0 for cross-margin mode'),
440
+ cross_leverage_limit: z.string().optional().describe('Cross-margin leverage limit (only when leverage=0)'),
441
+ }, async ({ settle, contract, leverage, cross_leverage_limit }) => {
442
+ try {
443
+ requireAuth();
444
+ const opts = {};
445
+ if (cross_leverage_limit)
446
+ opts.crossLeverageLimit = cross_leverage_limit;
447
+ const { body } = await new FuturesApi(createClient()).updatePositionLeverage(settle, contract, leverage, opts);
448
+ return textContent(body);
449
+ }
450
+ catch (e) {
451
+ return errorContent(e);
452
+ }
453
+ });
454
+ server.tool('update_position_margin', 'Add or reduce margin for a futures position (requires authentication) — always confirm the amount with the user before calling this tool', {
455
+ settle: settleSchema,
456
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
457
+ change: z.string().describe('Margin change amount; positive to add, negative to reduce'),
458
+ }, async ({ settle, contract, change }) => {
459
+ try {
460
+ requireAuth();
461
+ const { body } = await new FuturesApi(createClient()).updatePositionMargin(settle, contract, change);
462
+ return textContent(body);
463
+ }
464
+ catch (e) {
465
+ return errorContent(e);
466
+ }
467
+ });
468
+ server.tool('update_position_risk_limit', 'Update the risk limit for a futures position (requires authentication)', {
469
+ settle: settleSchema,
470
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
471
+ risk_limit: z.string().describe('New risk limit value'),
472
+ }, async ({ settle, contract, risk_limit }) => {
473
+ try {
474
+ requireAuth();
475
+ const { body } = await new FuturesApi(createClient()).updatePositionRiskLimit(settle, contract, risk_limit);
476
+ return textContent(body);
477
+ }
478
+ catch (e) {
479
+ return errorContent(e);
480
+ }
481
+ });
482
+ server.tool('cancel_futures_orders', 'Cancel all open futures orders (requires authentication) — always confirm with the user before calling this tool', {
483
+ settle: settleSchema,
484
+ contract: z.string().optional().describe('Only cancel orders for this contract'),
485
+ side: z.enum(['ask', 'bid']).optional().describe('Only cancel ask (sell) or bid (buy) orders'),
486
+ }, async ({ settle, contract, side }) => {
487
+ try {
488
+ requireAuth();
489
+ const opts = {};
490
+ if (contract)
491
+ opts.contract = contract;
492
+ if (side)
493
+ opts.side = side;
494
+ const { body } = await new FuturesApi(createClient()).cancelFuturesOrders(settle, opts);
495
+ return textContent(body);
496
+ }
497
+ catch (e) {
498
+ return errorContent(e);
499
+ }
500
+ });
501
+ server.tool('create_batch_futures_orders', 'Create multiple futures orders in a single request (requires authentication) — always confirm the details with the user before calling this tool', {
502
+ settle: settleSchema,
503
+ orders: z.array(z.object({
504
+ contract: z.string(),
505
+ size: z.string().describe('Order size in contracts (negative = short)'),
506
+ price: z.string().describe('Order price; "0" for market'),
507
+ tif: z.enum(['gtc', 'ioc', 'poc', 'fok']).optional(),
508
+ reduce_only: z.boolean().optional(),
509
+ close: z.boolean().optional(),
510
+ text: z.string().optional(),
511
+ })).describe('Array of futures orders to create'),
512
+ }, async ({ settle, orders }) => {
513
+ try {
514
+ requireAuth();
515
+ const mapped = orders.map(o => {
516
+ const order = { contract: o.contract, size: o.size, price: o.price };
517
+ if (o.tif)
518
+ order.tif = o.tif;
519
+ if (o.reduce_only !== undefined)
520
+ order.reduceOnly = o.reduce_only;
521
+ if (o.close !== undefined)
522
+ order.close = o.close;
523
+ if (o.text)
524
+ order.text = o.text;
525
+ return order;
526
+ });
527
+ const { body } = await new FuturesApi(createClient()).createBatchFuturesOrder(settle, mapped, {});
528
+ return textContent(body);
529
+ }
530
+ catch (e) {
531
+ return errorContent(e);
532
+ }
533
+ });
534
+ server.tool('cancel_batch_futures_orders', 'Cancel multiple futures orders by ID in a single request (requires authentication) — always confirm with the user before calling this tool', {
535
+ settle: settleSchema,
536
+ order_ids: z.array(z.string()).describe('Array of order IDs to cancel'),
537
+ }, async ({ settle, order_ids }) => {
538
+ try {
539
+ requireAuth();
540
+ const { body } = await new FuturesApi(createClient()).cancelBatchFutureOrders(settle, order_ids, {});
541
+ return textContent(body);
542
+ }
543
+ catch (e) {
544
+ return errorContent(e);
545
+ }
546
+ });
547
+ server.tool('get_futures_orders_with_time_range', 'Get futures orders filtered by time range (requires authentication)', {
548
+ settle: settleSchema,
549
+ contract: z.string().optional().describe('Filter by contract'),
550
+ from: z.number().optional().describe('Start time (Unix timestamp)'),
551
+ to: z.number().optional().describe('End time (Unix timestamp)'),
552
+ limit: z.number().int().optional(),
553
+ offset: z.number().int().optional(),
554
+ }, async ({ settle, contract, from, to, limit, offset }) => {
555
+ try {
556
+ requireAuth();
557
+ const opts = {};
558
+ if (contract)
559
+ opts.contract = contract;
560
+ if (from !== undefined)
561
+ opts.from = from;
562
+ if (to !== undefined)
563
+ opts.to = to;
564
+ if (limit !== undefined)
565
+ opts.limit = limit;
566
+ if (offset !== undefined)
567
+ opts.offset = offset;
568
+ const { body } = await new FuturesApi(createClient()).getOrdersWithTimeRange(settle, opts);
569
+ return textContent(body);
570
+ }
571
+ catch (e) {
572
+ return errorContent(e);
573
+ }
574
+ });
575
+ server.tool('get_my_futures_trades_with_time_range', 'Get personal futures trade history filtered by time range (requires authentication)', {
576
+ settle: settleSchema,
577
+ contract: z.string().optional().describe('Filter by contract'),
578
+ from: z.number().optional().describe('Start time (Unix timestamp)'),
579
+ to: z.number().optional().describe('End time (Unix timestamp)'),
580
+ limit: z.number().int().optional(),
581
+ offset: z.number().int().optional(),
582
+ role: z.enum(['maker', 'taker']).optional(),
583
+ }, async ({ settle, contract, from, to, limit, offset, role }) => {
584
+ try {
585
+ requireAuth();
586
+ const opts = {};
587
+ if (contract)
588
+ opts.contract = contract;
589
+ if (from !== undefined)
590
+ opts.from = from;
591
+ if (to !== undefined)
592
+ opts.to = to;
593
+ if (limit !== undefined)
594
+ opts.limit = limit;
595
+ if (offset !== undefined)
596
+ opts.offset = offset;
597
+ if (role)
598
+ opts.role = role;
599
+ const { body } = await new FuturesApi(createClient()).getMyTradesWithTimeRange(settle, opts);
600
+ return textContent(body);
601
+ }
602
+ catch (e) {
603
+ return errorContent(e);
604
+ }
605
+ });
606
+ server.tool('list_liquidates', 'Get personal futures liquidation history (requires authentication)', {
607
+ settle: settleSchema,
608
+ contract: z.string().optional(),
609
+ from: z.number().optional().describe('Start time (Unix timestamp)'),
610
+ to: z.number().optional().describe('End time (Unix timestamp)'),
611
+ limit: z.number().int().optional(),
612
+ offset: z.number().int().optional(),
613
+ }, async ({ settle, contract, from, to, limit, offset }) => {
614
+ try {
615
+ requireAuth();
616
+ const opts = {};
617
+ if (contract)
618
+ opts.contract = contract;
619
+ if (from !== undefined)
620
+ opts.from = from;
621
+ if (to !== undefined)
622
+ opts.to = to;
623
+ if (limit !== undefined)
624
+ opts.limit = limit;
625
+ if (offset !== undefined)
626
+ opts.offset = offset;
627
+ const { body } = await new FuturesApi(createClient()).listLiquidates(settle, opts);
628
+ return textContent(body);
629
+ }
630
+ catch (e) {
631
+ return errorContent(e);
632
+ }
633
+ });
634
+ server.tool('get_futures_price_triggered_order', 'Get details of a futures price-triggered order (requires authentication)', {
635
+ settle: settleSchema,
636
+ order_id: z.string().describe('Order ID'),
637
+ }, async ({ settle, order_id }) => {
638
+ try {
639
+ requireAuth();
640
+ const { body } = await new FuturesApi(createClient()).getPriceTriggeredOrder(settle, order_id);
641
+ return textContent(body);
642
+ }
643
+ catch (e) {
644
+ return errorContent(e);
645
+ }
646
+ });
647
+ server.tool('create_futures_price_triggered_order', 'Create a futures price-triggered order (requires authentication) — always confirm the details with the user before calling this tool', {
648
+ settle: settleSchema,
649
+ contract: z.string().describe('Contract name e.g. BTC_USDT'),
650
+ trigger_price: z.string().describe('Price that activates the order'),
651
+ trigger_rule: z.enum(['>=', '<=']).describe('>= fires when price rises to trigger_price; <= fires when it drops'),
652
+ trigger_expiration: z.number().int().optional().describe('Trigger expiration in seconds'),
653
+ order_size: z.number().describe('Order size (negative = short)'),
654
+ order_price: z.string().describe('Execution price; "0" for market'),
655
+ order_tif: z.enum(['gtc', 'ioc']).optional(),
656
+ order_reduce_only: z.boolean().optional(),
657
+ order_close: z.boolean().optional(),
658
+ order_text: z.string().optional(),
659
+ }, async ({ settle, contract, trigger_price, trigger_rule, trigger_expiration, order_size, order_price, order_tif, order_reduce_only, order_close, order_text }) => {
660
+ try {
661
+ requireAuth();
662
+ const trigger = { price: trigger_price, rule: trigger_rule === '>=' ? 1 : 2 };
663
+ if (trigger_expiration !== undefined)
664
+ trigger.expiration = trigger_expiration;
665
+ const initial = { contract, size: order_size, price: order_price };
666
+ if (order_tif)
667
+ initial.tif = order_tif;
668
+ if (order_reduce_only !== undefined)
669
+ initial.reduceOnly = order_reduce_only;
670
+ if (order_close !== undefined)
671
+ initial.close = order_close;
672
+ if (order_text)
673
+ initial.text = order_text;
674
+ const { body } = await new FuturesApi(createClient()).createPriceTriggeredOrder(settle, { initial, trigger });
675
+ return textContent(body);
676
+ }
677
+ catch (e) {
678
+ return errorContent(e);
679
+ }
680
+ });
681
+ server.tool('cancel_futures_price_triggered_order', 'Cancel a single futures price-triggered order (requires authentication) — always confirm with the user before calling this tool', {
682
+ settle: settleSchema,
683
+ order_id: z.string().describe('Order ID'),
684
+ }, async ({ settle, order_id }) => {
685
+ try {
686
+ requireAuth();
687
+ const { body } = await new FuturesApi(createClient()).cancelPriceTriggeredOrder(settle, order_id);
688
+ return textContent(body);
689
+ }
690
+ catch (e) {
691
+ return errorContent(e);
692
+ }
693
+ });
694
+ server.tool('cancel_futures_price_triggered_order_list', 'Cancel all futures price-triggered orders (requires authentication) — always confirm with the user before calling this tool', {
695
+ settle: settleSchema,
696
+ contract: z.string().optional().describe('Only cancel orders for this contract'),
697
+ }, async ({ settle, contract }) => {
698
+ try {
699
+ requireAuth();
700
+ const opts = {};
701
+ if (contract)
702
+ opts.contract = contract;
703
+ const { body } = await new FuturesApi(createClient()).cancelPriceTriggeredOrderList(settle, opts);
704
+ return textContent(body);
705
+ }
706
+ catch (e) {
707
+ return errorContent(e);
708
+ }
709
+ });
710
+ server.tool('countdown_cancel_all_futures', 'Set a countdown timer to cancel all futures orders (safety kill-switch, requires authentication)', {
711
+ settle: settleSchema,
712
+ timeout: z.number().int().describe('Countdown in seconds; 0 disables the timer'),
713
+ contract: z.string().optional().describe('Limit cancellation to this contract'),
714
+ }, async ({ settle, timeout, contract }) => {
715
+ try {
716
+ requireAuth();
717
+ const task = { timeout };
718
+ if (contract)
719
+ task.contract = contract;
720
+ const { body } = await new FuturesApi(createClient()).countdownCancelAllFutures(settle, task);
721
+ return textContent(body);
722
+ }
723
+ catch (e) {
724
+ return errorContent(e);
725
+ }
726
+ });
305
727
  }
306
728
  //# sourceMappingURL=futures.js.map