gate-mcp 0.4.1 → 0.4.3

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.
@@ -4,7 +4,7 @@ import { createClient, requireAuth } from '../client.js';
4
4
  import { textContent, errorContent } from '../utils.js';
5
5
  export function registerSpotTools(server) {
6
6
  // ── Public tools ──────────────────────────────────────────────────────────
7
- server.tool('cex.spot.list_currencies', 'List all currencies supported on Gate.com', {}, async () => {
7
+ server.tool('cex_spot_list_currencies', 'List all currencies supported on Gate.com', {}, async () => {
8
8
  try {
9
9
  const { body } = await new SpotApi(createClient()).listCurrencies();
10
10
  return textContent(body);
@@ -13,7 +13,7 @@ export function registerSpotTools(server) {
13
13
  return errorContent(e);
14
14
  }
15
15
  });
16
- server.tool('cex.spot.get_currency', 'Get details of a single currency', { currency: z.string().describe('Currency symbol e.g. BTC') }, async ({ currency }) => {
16
+ server.tool('cex_spot_get_currency', 'Get details of a single currency', { currency: z.string().describe('Currency symbol e.g. BTC') }, async ({ currency }) => {
17
17
  try {
18
18
  const { body } = await new SpotApi(createClient()).getCurrency(currency);
19
19
  return textContent(body);
@@ -22,7 +22,7 @@ export function registerSpotTools(server) {
22
22
  return errorContent(e);
23
23
  }
24
24
  });
25
- server.tool('cex.spot.list_currency_pairs', 'List all available spot trading pairs', {}, async () => {
25
+ server.tool('cex_spot_list_currency_pairs', 'List all available spot trading pairs', {}, async () => {
26
26
  try {
27
27
  const { body } = await new SpotApi(createClient()).listCurrencyPairs();
28
28
  return textContent(body);
@@ -31,7 +31,7 @@ export function registerSpotTools(server) {
31
31
  return errorContent(e);
32
32
  }
33
33
  });
34
- server.tool('cex.spot.get_currency_pair', 'Get details of a single currency pair', { currency_pair: z.string().describe('Currency pair e.g. BTC_USDT') }, async ({ currency_pair }) => {
34
+ server.tool('cex_spot_get_currency_pair', 'Get details of a single currency pair', { currency_pair: z.string().describe('Currency pair e.g. BTC_USDT') }, async ({ currency_pair }) => {
35
35
  try {
36
36
  const { body } = await new SpotApi(createClient()).getCurrencyPair(currency_pair);
37
37
  return textContent(body);
@@ -40,7 +40,7 @@ export function registerSpotTools(server) {
40
40
  return errorContent(e);
41
41
  }
42
42
  });
43
- server.tool('cex.spot.get_spot_tickers', 'Get ticker information for one or all currency pairs', {
43
+ server.tool('cex_spot_get_spot_tickers', 'Get ticker information for one or all currency pairs', {
44
44
  currency_pair: z.string().optional().describe('Limit to this pair e.g. BTC_USDT; omit for all'),
45
45
  timezone: z.enum(['utc0', 'utc8', 'all']).optional(),
46
46
  }, async ({ currency_pair, timezone }) => {
@@ -57,7 +57,7 @@ export function registerSpotTools(server) {
57
57
  return errorContent(e);
58
58
  }
59
59
  });
60
- server.tool('cex.spot.get_spot_order_book', 'Get the order book for a currency pair', {
60
+ server.tool('cex_spot_get_spot_order_book', 'Get the order book for a currency pair', {
61
61
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
62
62
  limit: z.number().int().min(1).max(5000).optional().describe('Number of price levels (default 10)'),
63
63
  with_id: z.boolean().optional().describe('Include order book ID'),
@@ -75,7 +75,7 @@ export function registerSpotTools(server) {
75
75
  return errorContent(e);
76
76
  }
77
77
  });
78
- server.tool('cex.spot.get_spot_trades', 'Get recent trades for a currency pair', {
78
+ server.tool('cex_spot_get_spot_trades', 'Get recent trades for a currency pair', {
79
79
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
80
80
  limit: z.number().int().min(1).max(1000).optional(),
81
81
  }, async ({ currency_pair, limit }) => {
@@ -90,7 +90,7 @@ export function registerSpotTools(server) {
90
90
  return errorContent(e);
91
91
  }
92
92
  });
93
- server.tool('cex.spot.get_spot_candlesticks', 'Get candlestick/OHLCV data for a currency pair', {
93
+ server.tool('cex_spot_get_spot_candlesticks', 'Get candlestick/OHLCV data for a currency pair', {
94
94
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
95
95
  interval: z.enum(['10s', '1m', '5m', '15m', '30m', '1h', '4h', '8h', '1d', '7d', '30d']).optional().describe('Candlestick interval (default 30m)'),
96
96
  limit: z.number().int().min(1).max(1000).optional(),
@@ -114,7 +114,7 @@ export function registerSpotTools(server) {
114
114
  return errorContent(e);
115
115
  }
116
116
  });
117
- server.tool('cex.spot.get_spot_fee', 'Query user trading fee rates (requires authentication)', { currency_pair: z.string().optional().describe('Currency pair to query fee for') }, async ({ currency_pair }) => {
117
+ server.tool('cex_spot_get_spot_fee', 'Query user trading fee rates (requires authentication)', { currency_pair: z.string().optional().describe('Currency pair to query fee for') }, async ({ currency_pair }) => {
118
118
  try {
119
119
  requireAuth();
120
120
  const opts = {};
@@ -128,7 +128,7 @@ export function registerSpotTools(server) {
128
128
  }
129
129
  });
130
130
  // ── Private tools ─────────────────────────────────────────────────────────
131
- server.tool('cex.spot.get_spot_accounts', 'List spot account balances (requires authentication)', { currency: z.string().optional().describe('Filter by currency symbol') }, async ({ currency }) => {
131
+ server.tool('cex_spot_get_spot_accounts', 'List spot account balances (requires authentication)', { currency: z.string().optional().describe('Filter by currency symbol') }, async ({ currency }) => {
132
132
  try {
133
133
  requireAuth();
134
134
  const opts = {};
@@ -141,7 +141,7 @@ export function registerSpotTools(server) {
141
141
  return errorContent(e);
142
142
  }
143
143
  });
144
- server.tool('cex.spot.list_spot_orders', 'List spot orders (requires authentication)', {
144
+ server.tool('cex_spot_list_spot_orders', 'List spot orders (requires authentication)', {
145
145
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
146
146
  status: z.enum(['open', 'finished']).optional().describe('Order status (default: open)'),
147
147
  page: z.number().int().min(1).optional(),
@@ -161,7 +161,7 @@ export function registerSpotTools(server) {
161
161
  return errorContent(e);
162
162
  }
163
163
  });
164
- server.tool('cex.spot.create_spot_order', 'Create a spot order (requires authentication) — always confirm the details with the user before calling this tool', {
164
+ server.tool('cex_spot_create_spot_order', 'Create a spot order (requires authentication) — always confirm the details with the user before calling this tool', {
165
165
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
166
166
  side: z.enum(['buy', 'sell']),
167
167
  amount: z.string().describe('Order amount'),
@@ -190,7 +190,7 @@ export function registerSpotTools(server) {
190
190
  return errorContent(e);
191
191
  }
192
192
  });
193
- server.tool('cex.spot.get_spot_order', 'Get details of a spot order (requires authentication)', {
193
+ server.tool('cex_spot_get_spot_order', 'Get details of a spot order (requires authentication)', {
194
194
  order_id: z.string().describe('Order ID'),
195
195
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
196
196
  }, async ({ order_id, currency_pair }) => {
@@ -203,7 +203,7 @@ export function registerSpotTools(server) {
203
203
  return errorContent(e);
204
204
  }
205
205
  });
206
- server.tool('cex.spot.cancel_spot_order', 'Cancel a single spot order (requires authentication) — always confirm with the user before calling this tool', {
206
+ server.tool('cex_spot_cancel_spot_order', 'Cancel a single spot order (requires authentication) — always confirm with the user before calling this tool', {
207
207
  order_id: z.string().describe('Order ID'),
208
208
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
209
209
  }, async ({ order_id, currency_pair }) => {
@@ -216,7 +216,7 @@ export function registerSpotTools(server) {
216
216
  return errorContent(e);
217
217
  }
218
218
  });
219
- server.tool('cex.spot.amend_spot_order', 'Amend (modify) an open spot order (requires authentication) — always confirm the new values with the user before calling this tool', {
219
+ server.tool('cex_spot_amend_spot_order', 'Amend (modify) an open spot order (requires authentication) — always confirm the new values with the user before calling this tool', {
220
220
  order_id: z.string().describe('Order ID'),
221
221
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
222
222
  amount: z.string().optional().describe('New order amount'),
@@ -236,7 +236,7 @@ export function registerSpotTools(server) {
236
236
  return errorContent(e);
237
237
  }
238
238
  });
239
- server.tool('cex.spot.cancel_all_spot_orders', 'Cancel all open orders for a currency pair (requires authentication) — always confirm with the user before calling this tool', {
239
+ server.tool('cex_spot_cancel_all_spot_orders', 'Cancel all open orders for a currency pair (requires authentication) — always confirm with the user before calling this tool', {
240
240
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
241
241
  side: z.enum(['buy', 'sell']).optional().describe('Cancel only buy or sell orders'),
242
242
  }, async ({ currency_pair, side }) => {
@@ -252,7 +252,7 @@ export function registerSpotTools(server) {
252
252
  return errorContent(e);
253
253
  }
254
254
  });
255
- server.tool('cex.spot.list_spot_my_trades', 'List personal trading history (requires authentication)', {
255
+ server.tool('cex_spot_list_spot_my_trades', 'List personal trading history (requires authentication)', {
256
256
  currency_pair: z.string().optional().describe('Filter by currency pair'),
257
257
  limit: z.number().int().min(1).max(1000).optional(),
258
258
  page: z.number().int().min(1).optional(),
@@ -273,7 +273,7 @@ export function registerSpotTools(server) {
273
273
  return errorContent(e);
274
274
  }
275
275
  });
276
- server.tool('cex.spot.list_all_open_orders', 'List all open orders across all pairs (requires authentication)', { page: z.number().int().min(1).optional(), limit: z.number().int().min(1).max(100).optional() }, async ({ page, limit }) => {
276
+ server.tool('cex_spot_list_all_open_orders', 'List all open orders across all pairs (requires authentication)', { page: z.number().int().min(1).optional(), limit: z.number().int().min(1).max(100).optional() }, async ({ page, limit }) => {
277
277
  try {
278
278
  requireAuth();
279
279
  const opts = {};
@@ -288,7 +288,7 @@ export function registerSpotTools(server) {
288
288
  return errorContent(e);
289
289
  }
290
290
  });
291
- server.tool('cex.spot.list_spot_price_triggered_orders', 'List price-triggered (stop) orders (requires authentication)', {
291
+ server.tool('cex_spot_list_spot_price_triggered_orders', 'List price-triggered (stop) orders (requires authentication)', {
292
292
  status: z.enum(['open', 'finished']).describe('Order status'),
293
293
  currency_pair: z.string().optional(),
294
294
  limit: z.number().int().optional(),
@@ -307,7 +307,7 @@ export function registerSpotTools(server) {
307
307
  return errorContent(e);
308
308
  }
309
309
  });
310
- server.tool('cex.spot.list_spot_account_book', 'Query spot account transaction history (requires authentication)', {
310
+ server.tool('cex_spot_list_spot_account_book', 'Query spot account transaction history (requires authentication)', {
311
311
  currency: z.string().optional().describe('Filter by currency'),
312
312
  from: z.number().optional().describe('Start time (Unix timestamp)'),
313
313
  to: z.number().optional().describe('End time (Unix timestamp)'),
@@ -334,7 +334,7 @@ export function registerSpotTools(server) {
334
334
  return errorContent(e);
335
335
  }
336
336
  });
337
- server.tool('cex.spot.get_spot_batch_fee', 'Get fee rates for multiple currency pairs at once (requires authentication)', { currency_pairs: z.string().describe('Comma-separated currency pairs e.g. BTC_USDT,ETH_USDT') }, async ({ currency_pairs }) => {
337
+ server.tool('cex_spot_get_spot_batch_fee', 'Get fee rates for multiple currency pairs at once (requires authentication)', { currency_pairs: z.string().describe('Comma-separated currency pairs e.g. BTC_USDT,ETH_USDT') }, async ({ currency_pairs }) => {
338
338
  try {
339
339
  requireAuth();
340
340
  const { body } = await new SpotApi(createClient()).getBatchSpotFee(currency_pairs);
@@ -344,7 +344,7 @@ export function registerSpotTools(server) {
344
344
  return errorContent(e);
345
345
  }
346
346
  });
347
- server.tool('cex.spot.create_spot_batch_orders', 'Create multiple spot orders in a single request (requires authentication) — always confirm the details with the user before calling this tool', {
347
+ server.tool('cex_spot_create_spot_batch_orders', 'Create multiple spot orders in a single request (requires authentication) — always confirm the details with the user before calling this tool', {
348
348
  orders: z.array(z.object({
349
349
  currency_pair: z.string(),
350
350
  side: z.enum(['buy', 'sell']),
@@ -378,7 +378,7 @@ export function registerSpotTools(server) {
378
378
  return errorContent(e);
379
379
  }
380
380
  });
381
- server.tool('cex.spot.cancel_spot_batch_orders', 'Cancel multiple spot orders in a single request (requires authentication) — always confirm with the user before calling this tool', {
381
+ server.tool('cex_spot_cancel_spot_batch_orders', 'Cancel multiple spot orders in a single request (requires authentication) — always confirm with the user before calling this tool', {
382
382
  orders: z.array(z.object({
383
383
  currency_pair: z.string(),
384
384
  id: z.string().describe('Order ID'),
@@ -400,7 +400,7 @@ export function registerSpotTools(server) {
400
400
  return errorContent(e);
401
401
  }
402
402
  });
403
- server.tool('cex.spot.create_spot_price_triggered_order', 'Create a price-triggered (stop) spot order (requires authentication) — always confirm the details with the user before calling this tool', {
403
+ server.tool('cex_spot_create_spot_price_triggered_order', 'Create a price-triggered (stop) spot order (requires authentication) — always confirm the details with the user before calling this tool', {
404
404
  currency_pair: z.string().describe('Currency pair e.g. BTC_USDT'),
405
405
  trigger_price: z.string().describe('Price that activates the order'),
406
406
  trigger_rule: z.enum(['>=', '<=']).describe('>= fires when price rises to trigger_price; <= fires when price drops'),
@@ -433,7 +433,7 @@ export function registerSpotTools(server) {
433
433
  return errorContent(e);
434
434
  }
435
435
  });
436
- server.tool('cex.spot.get_spot_price_triggered_order', 'Get details of a price-triggered spot order (requires authentication)', { order_id: z.string().describe('Order ID') }, async ({ order_id }) => {
436
+ server.tool('cex_spot_get_spot_price_triggered_order', 'Get details of a price-triggered spot order (requires authentication)', { order_id: z.string().describe('Order ID') }, async ({ order_id }) => {
437
437
  try {
438
438
  requireAuth();
439
439
  const { body } = await new SpotApi(createClient()).getSpotPriceTriggeredOrder(order_id);
@@ -443,7 +443,7 @@ export function registerSpotTools(server) {
443
443
  return errorContent(e);
444
444
  }
445
445
  });
446
- server.tool('cex.spot.cancel_spot_price_triggered_order', 'Cancel a single price-triggered spot order (requires authentication) — always confirm with the user before calling this tool', { order_id: z.string().describe('Order ID') }, async ({ order_id }) => {
446
+ server.tool('cex_spot_cancel_spot_price_triggered_order', 'Cancel a single price-triggered spot order (requires authentication) — always confirm with the user before calling this tool', { order_id: z.string().describe('Order ID') }, async ({ order_id }) => {
447
447
  try {
448
448
  requireAuth();
449
449
  const { body } = await new SpotApi(createClient()).cancelSpotPriceTriggeredOrder(order_id);
@@ -453,7 +453,7 @@ export function registerSpotTools(server) {
453
453
  return errorContent(e);
454
454
  }
455
455
  });
456
- server.tool('cex.spot.cancel_spot_price_triggered_order_list', 'Cancel all price-triggered spot orders (requires authentication) — always confirm with the user before calling this tool', {
456
+ server.tool('cex_spot_cancel_spot_price_triggered_order_list', 'Cancel all price-triggered spot orders (requires authentication) — always confirm with the user before calling this tool', {
457
457
  currency_pair: z.string().optional().describe('Only cancel orders for this pair'),
458
458
  account: z.enum(['normal', 'margin', 'unified']).optional(),
459
459
  }, async ({ currency_pair, account }) => {
@@ -471,7 +471,7 @@ export function registerSpotTools(server) {
471
471
  return errorContent(e);
472
472
  }
473
473
  });
474
- server.tool('cex.spot.countdown_cancel_all_spot', 'Set a countdown timer to cancel all spot orders (safety kill-switch, requires authentication)', {
474
+ server.tool('cex_spot_countdown_cancel_all_spot', 'Set a countdown timer to cancel all spot orders (safety kill-switch, requires authentication)', {
475
475
  timeout: z.number().int().describe('Countdown in seconds; 0 disables the timer'),
476
476
  currency_pair: z.string().optional().describe('Limit cancellation to this pair'),
477
477
  }, async ({ timeout, currency_pair }) => {
@@ -3,7 +3,7 @@ import { SubAccountApi } from 'gate-api';
3
3
  import { createClient, requireAuth } from '../client.js';
4
4
  import { textContent, errorContent } from '../utils.js';
5
5
  export function registerSubAccountTools(server) {
6
- server.tool('cex.sub_account.list_sub_accounts', 'List all sub-accounts (requires authentication)', { type: z.string().optional().describe('Filter by type: 0=normal, 1=pool') }, async ({ type }) => {
6
+ server.tool('cex_sub_account_list_sub_accounts', 'List all sub-accounts (requires authentication)', { type: z.string().optional().describe('Filter by type: 0=normal, 1=pool') }, async ({ type }) => {
7
7
  try {
8
8
  requireAuth();
9
9
  const opts = {};
@@ -16,7 +16,7 @@ export function registerSubAccountTools(server) {
16
16
  return errorContent(e);
17
17
  }
18
18
  });
19
- server.tool('cex.sub_account.create_sub_account', 'Create a new sub-account (requires authentication) — always confirm the details with the user before calling this tool', {
19
+ server.tool('cex_sub_account_create_sub_account', 'Create a new sub-account (requires authentication) — always confirm the details with the user before calling this tool', {
20
20
  login_name: z.string().describe('Sub-account login name'),
21
21
  password: z.string().optional().describe('Sub-account password'),
22
22
  email: z.string().optional().describe('Sub-account email'),
@@ -38,7 +38,7 @@ export function registerSubAccountTools(server) {
38
38
  return errorContent(e);
39
39
  }
40
40
  });
41
- server.tool('cex.sub_account.get_sub_account', 'Get details of a sub-account (requires authentication)', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
41
+ server.tool('cex_sub_account_get_sub_account', 'Get details of a sub-account (requires authentication)', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
42
42
  try {
43
43
  requireAuth();
44
44
  const { body } = await new SubAccountApi(createClient()).getSubAccount(user_id);
@@ -48,7 +48,7 @@ export function registerSubAccountTools(server) {
48
48
  return errorContent(e);
49
49
  }
50
50
  });
51
- server.tool('cex.sub_account.lock_sub_account', 'Lock a sub-account to disable login and trading (requires authentication) — always confirm with the user before calling this tool', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
51
+ server.tool('cex_sub_account_lock_sub_account', 'Lock a sub-account to disable login and trading (requires authentication) — always confirm with the user before calling this tool', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
52
52
  try {
53
53
  requireAuth();
54
54
  const { body } = await new SubAccountApi(createClient()).lockSubAccount(user_id);
@@ -58,7 +58,7 @@ export function registerSubAccountTools(server) {
58
58
  return errorContent(e);
59
59
  }
60
60
  });
61
- server.tool('cex.sub_account.unlock_sub_account', 'Unlock a previously locked sub-account (requires authentication) — always confirm with the user before calling this tool', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
61
+ server.tool('cex_sub_account_unlock_sub_account', 'Unlock a previously locked sub-account (requires authentication) — always confirm with the user before calling this tool', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
62
62
  try {
63
63
  requireAuth();
64
64
  const { body } = await new SubAccountApi(createClient()).unlockSubAccount(user_id);
@@ -68,7 +68,7 @@ export function registerSubAccountTools(server) {
68
68
  return errorContent(e);
69
69
  }
70
70
  });
71
- server.tool('cex.sub_account.list_sub_account_keys', 'List API keys for a sub-account (requires authentication)', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
71
+ server.tool('cex_sub_account_list_sub_account_keys', 'List API keys for a sub-account (requires authentication)', { user_id: z.number().int().describe('Sub-account user ID') }, async ({ user_id }) => {
72
72
  try {
73
73
  requireAuth();
74
74
  const { body } = await new SubAccountApi(createClient()).listSubAccountKeys(user_id);
@@ -78,7 +78,7 @@ export function registerSubAccountTools(server) {
78
78
  return errorContent(e);
79
79
  }
80
80
  });
81
- server.tool('cex.sub_account.get_sub_account_key', 'Get details of a specific API key for a sub-account (requires authentication)', {
81
+ server.tool('cex_sub_account_get_sub_account_key', 'Get details of a specific API key for a sub-account (requires authentication)', {
82
82
  user_id: z.number().int().describe('Sub-account user ID'),
83
83
  key: z.string().describe('API key'),
84
84
  }, async ({ user_id, key }) => {
@@ -91,7 +91,7 @@ export function registerSubAccountTools(server) {
91
91
  return errorContent(e);
92
92
  }
93
93
  });
94
- server.tool('cex.sub_account.create_sub_account_key', 'Create API keys for a sub-account (requires authentication) — always confirm the permissions with the user before calling this tool', {
94
+ server.tool('cex_sub_account_create_sub_account_key', 'Create API keys for a sub-account (requires authentication) — always confirm the permissions with the user before calling this tool', {
95
95
  user_id: z.number().int().describe('Sub-account user ID'),
96
96
  name: z.string().optional().describe('API key name/label'),
97
97
  ip_whitelist: z.array(z.string()).optional().describe('Allowed IP addresses'),
@@ -110,7 +110,7 @@ export function registerSubAccountTools(server) {
110
110
  return errorContent(e);
111
111
  }
112
112
  });
113
- server.tool('cex.sub_account.update_sub_account_key', 'Update an API key for a sub-account (requires authentication) — always confirm changes with the user before calling this tool', {
113
+ server.tool('cex_sub_account_update_sub_account_key', 'Update an API key for a sub-account (requires authentication) — always confirm changes with the user before calling this tool', {
114
114
  user_id: z.number().int().describe('Sub-account user ID'),
115
115
  key: z.string().describe('API key to update'),
116
116
  name: z.string().optional().describe('New API key name'),
@@ -138,7 +138,7 @@ export function registerSubAccountTools(server) {
138
138
  return errorContent(e);
139
139
  }
140
140
  });
141
- server.tool('cex.sub_account.get_sub_account_unified_mode', 'Get the unified account mode for all sub-accounts (requires authentication)', {}, async () => {
141
+ server.tool('cex_sub_account_get_sub_account_unified_mode', 'Get the unified account mode for all sub-accounts (requires authentication)', {}, async () => {
142
142
  try {
143
143
  requireAuth();
144
144
  const { body } = await new SubAccountApi(createClient()).listUnifiedMode();
@@ -148,7 +148,7 @@ export function registerSubAccountTools(server) {
148
148
  return errorContent(e);
149
149
  }
150
150
  });
151
- server.tool('cex.sub_account.delete_sub_account_key', 'Delete an API key from a sub-account (requires authentication) — always confirm with the user before calling this tool', {
151
+ server.tool('cex_sub_account_delete_sub_account_key', 'Delete an API key from a sub-account (requires authentication) — always confirm with the user before calling this tool', {
152
152
  user_id: z.number().int().describe('Sub-account user ID'),
153
153
  key: z.string().describe('API key to delete'),
154
154
  }, async ({ user_id, key }) => {
@@ -3,7 +3,7 @@ import { UnifiedApi } from 'gate-api';
3
3
  import { createClient, requireAuth } from '../client.js';
4
4
  import { textContent, errorContent } from '../utils.js';
5
5
  export function registerUnifiedTools(server) {
6
- server.tool('cex.unified.get_unified_accounts', 'Get unified account balances and info (requires authentication)', {
6
+ server.tool('cex_unified_get_unified_accounts', 'Get unified account balances and info (requires authentication)', {
7
7
  currency: z.string().optional().describe('Filter by currency'),
8
8
  sub_uid: z.string().optional().describe('Sub-account UID'),
9
9
  }, async ({ currency, sub_uid }) => {
@@ -21,7 +21,7 @@ export function registerUnifiedTools(server) {
21
21
  return errorContent(e);
22
22
  }
23
23
  });
24
- server.tool('cex.unified.list_unified_currencies', 'List currencies supported in unified account (requires authentication)', { currency: z.string().optional().describe('Filter by currency') }, async ({ currency }) => {
24
+ server.tool('cex_unified_list_unified_currencies', 'List currencies supported in unified account (requires authentication)', { currency: z.string().optional().describe('Filter by currency') }, async ({ currency }) => {
25
25
  try {
26
26
  requireAuth();
27
27
  const opts = {};
@@ -34,7 +34,7 @@ export function registerUnifiedTools(server) {
34
34
  return errorContent(e);
35
35
  }
36
36
  });
37
- server.tool('cex.unified.get_unified_mode', 'Get current unified account mode (requires authentication)', {}, async () => {
37
+ server.tool('cex_unified_get_unified_mode', 'Get current unified account mode (requires authentication)', {}, async () => {
38
38
  try {
39
39
  requireAuth();
40
40
  const { body } = await new UnifiedApi(createClient()).getUnifiedMode();
@@ -44,7 +44,7 @@ export function registerUnifiedTools(server) {
44
44
  return errorContent(e);
45
45
  }
46
46
  });
47
- server.tool('cex.unified.set_unified_mode', 'Switch unified account mode (requires authentication) — always confirm with the user before calling this tool', {
47
+ server.tool('cex_unified_set_unified_mode', 'Switch unified account mode (requires authentication) — always confirm with the user before calling this tool', {
48
48
  mode: z.string().describe('Mode: classic, multi_currency, or portfolio'),
49
49
  }, async ({ mode }) => {
50
50
  try {
@@ -56,7 +56,7 @@ export function registerUnifiedTools(server) {
56
56
  return errorContent(e);
57
57
  }
58
58
  });
59
- server.tool('cex.unified.get_unified_risk_units', 'Get risk unit details for portfolio margin mode (requires authentication)', {}, async () => {
59
+ server.tool('cex_unified_get_unified_risk_units', 'Get risk unit details for portfolio margin mode (requires authentication)', {}, async () => {
60
60
  try {
61
61
  requireAuth();
62
62
  const { body } = await new UnifiedApi(createClient()).getUnifiedRiskUnits();
@@ -66,7 +66,7 @@ export function registerUnifiedTools(server) {
66
66
  return errorContent(e);
67
67
  }
68
68
  });
69
- server.tool('cex.unified.get_unified_borrowable', 'Get maximum borrowable amount for a currency in unified account (requires authentication)', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
69
+ server.tool('cex_unified_get_unified_borrowable', 'Get maximum borrowable amount for a currency in unified account (requires authentication)', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
70
70
  try {
71
71
  requireAuth();
72
72
  const { body } = await new UnifiedApi(createClient()).getUnifiedBorrowable(currency);
@@ -76,7 +76,7 @@ export function registerUnifiedTools(server) {
76
76
  return errorContent(e);
77
77
  }
78
78
  });
79
- server.tool('cex.unified.get_unified_transferable', 'Get maximum transferable amount for a currency in unified account (requires authentication)', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
79
+ server.tool('cex_unified_get_unified_transferable', 'Get maximum transferable amount for a currency in unified account (requires authentication)', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
80
80
  try {
81
81
  requireAuth();
82
82
  const { body } = await new UnifiedApi(createClient()).getUnifiedTransferable(currency);
@@ -86,7 +86,7 @@ export function registerUnifiedTools(server) {
86
86
  return errorContent(e);
87
87
  }
88
88
  });
89
- server.tool('cex.unified.get_unified_estimate_rate', 'Get estimated borrow interest rates for currencies (requires authentication)', { currencies: z.array(z.string()).describe('List of currency symbols e.g. ["BTC","USDT"]') }, async ({ currencies }) => {
89
+ server.tool('cex_unified_get_unified_estimate_rate', 'Get estimated borrow interest rates for currencies (requires authentication)', { currencies: z.array(z.string()).describe('List of currency symbols e.g. ["BTC","USDT"]') }, async ({ currencies }) => {
90
90
  try {
91
91
  requireAuth();
92
92
  const { body } = await new UnifiedApi(createClient()).getUnifiedEstimateRate(currencies);
@@ -96,7 +96,7 @@ export function registerUnifiedTools(server) {
96
96
  return errorContent(e);
97
97
  }
98
98
  });
99
- server.tool('cex.unified.list_unified_loans', 'List active loans in unified account (requires authentication)', {
99
+ server.tool('cex_unified_list_unified_loans', 'List active loans in unified account (requires authentication)', {
100
100
  currency: z.string().optional().describe('Filter by currency'),
101
101
  type: z.string().optional().describe('Loan type: platform or margin'),
102
102
  page: z.number().int().min(1).optional(),
@@ -120,7 +120,7 @@ export function registerUnifiedTools(server) {
120
120
  return errorContent(e);
121
121
  }
122
122
  });
123
- server.tool('cex.unified.create_unified_loan', 'Borrow or repay in unified account (requires authentication) — always confirm the details with the user before calling this tool', {
123
+ server.tool('cex_unified_create_unified_loan', 'Borrow or repay in unified account (requires authentication) — always confirm the details with the user before calling this tool', {
124
124
  currency: z.string().describe('Currency to borrow/repay'),
125
125
  type: z.enum(['borrow', 'repay']),
126
126
  amount: z.string().describe('Amount to borrow or repay'),
@@ -141,7 +141,7 @@ export function registerUnifiedTools(server) {
141
141
  return errorContent(e);
142
142
  }
143
143
  });
144
- server.tool('cex.unified.list_unified_loan_records', 'Get borrow/repay history in unified account (requires authentication)', {
144
+ server.tool('cex_unified_list_unified_loan_records', 'Get borrow/repay history in unified account (requires authentication)', {
145
145
  currency: z.string().optional(),
146
146
  type: z.string().optional().describe('borrow or repay'),
147
147
  page: z.number().int().min(1).optional(),
@@ -165,7 +165,7 @@ export function registerUnifiedTools(server) {
165
165
  return errorContent(e);
166
166
  }
167
167
  });
168
- server.tool('cex.unified.list_unified_loan_interest_records', 'Get interest charge history in unified account (requires authentication)', {
168
+ server.tool('cex_unified_list_unified_loan_interest_records', 'Get interest charge history in unified account (requires authentication)', {
169
169
  currency: z.string().optional(),
170
170
  type: z.string().optional().describe('Loan type'),
171
171
  from: z.number().optional().describe('Start time (Unix timestamp)'),
@@ -195,7 +195,7 @@ export function registerUnifiedTools(server) {
195
195
  return errorContent(e);
196
196
  }
197
197
  });
198
- server.tool('cex.unified.list_currency_discount_tiers', 'List currency discount tiers for unified account collateral', {}, async () => {
198
+ server.tool('cex_unified_list_currency_discount_tiers', 'List currency discount tiers for unified account collateral', {}, async () => {
199
199
  try {
200
200
  const { body } = await new UnifiedApi(createClient()).listCurrencyDiscountTiers();
201
201
  return textContent(body);
@@ -204,7 +204,7 @@ export function registerUnifiedTools(server) {
204
204
  return errorContent(e);
205
205
  }
206
206
  });
207
- server.tool('cex.unified.get_user_leverage_currency_setting', 'Get leverage settings for currencies in unified account (requires authentication)', { currency: z.string().optional().describe('Filter by currency') }, async ({ currency }) => {
207
+ server.tool('cex_unified_get_user_leverage_currency_setting', 'Get leverage settings for currencies in unified account (requires authentication)', { currency: z.string().optional().describe('Filter by currency') }, async ({ currency }) => {
208
208
  try {
209
209
  requireAuth();
210
210
  const opts = {};
@@ -217,7 +217,7 @@ export function registerUnifiedTools(server) {
217
217
  return errorContent(e);
218
218
  }
219
219
  });
220
- server.tool('cex.unified.set_user_leverage_currency_setting', 'Set leverage for a currency in unified account (requires authentication) — always confirm with the user before calling this tool', {
220
+ server.tool('cex_unified_set_user_leverage_currency_setting', 'Set leverage for a currency in unified account (requires authentication) — always confirm with the user before calling this tool', {
221
221
  currency: z.string().describe('Currency symbol e.g. BTC'),
222
222
  leverage: z.string().describe('Leverage value'),
223
223
  }, async ({ currency, leverage }) => {
@@ -230,7 +230,7 @@ export function registerUnifiedTools(server) {
230
230
  return errorContent(e);
231
231
  }
232
232
  });
233
- server.tool('cex.unified.set_unified_collateral', 'Enable or disable currencies as collateral in unified account (requires authentication)', {
233
+ server.tool('cex_unified_set_unified_collateral', 'Enable or disable currencies as collateral in unified account (requires authentication)', {
234
234
  enable_list: z.array(z.string()).optional().describe('Currencies to enable as collateral'),
235
235
  disable_list: z.array(z.string()).optional().describe('Currencies to disable as collateral'),
236
236
  }, async ({ enable_list, disable_list }) => {
@@ -3,7 +3,7 @@ import { WalletApi, SubAccountTransfer, SubAccountToSubAccount } from 'gate-api'
3
3
  import { createClient, requireAuth } from '../client.js';
4
4
  import { textContent, errorContent } from '../utils.js';
5
5
  export function registerWalletTools(server) {
6
- server.tool('cex.wallet.get_total_balance', 'Get total account balance across all wallets (requires authentication)', {
6
+ server.tool('cex_wallet_get_total_balance', 'Get total account balance across all wallets (requires authentication)', {
7
7
  currency: z.string().optional().describe('Quote currency for conversion (default: USDT)'),
8
8
  }, async ({ currency }) => {
9
9
  try {
@@ -18,7 +18,7 @@ export function registerWalletTools(server) {
18
18
  return errorContent(e);
19
19
  }
20
20
  });
21
- server.tool('cex.wallet.list_withdrawals', 'List withdrawal history (requires authentication)', {
21
+ server.tool('cex_wallet_list_withdrawals', 'List withdrawal history (requires authentication)', {
22
22
  currency: z.string().optional().describe('Filter by currency'),
23
23
  limit: z.number().int().optional(),
24
24
  offset: z.number().int().optional(),
@@ -39,7 +39,7 @@ export function registerWalletTools(server) {
39
39
  return errorContent(e);
40
40
  }
41
41
  });
42
- server.tool('cex.wallet.list_deposits', 'List deposit history (requires authentication)', {
42
+ server.tool('cex_wallet_list_deposits', 'List deposit history (requires authentication)', {
43
43
  currency: z.string().optional().describe('Filter by currency'),
44
44
  limit: z.number().int().optional(),
45
45
  offset: z.number().int().optional(),
@@ -60,7 +60,7 @@ export function registerWalletTools(server) {
60
60
  return errorContent(e);
61
61
  }
62
62
  });
63
- server.tool('cex.wallet.get_deposit_address', 'Get deposit address for a currency (requires authentication)', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
63
+ server.tool('cex_wallet_get_deposit_address', 'Get deposit address for a currency (requires authentication)', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
64
64
  try {
65
65
  requireAuth();
66
66
  const { body } = await new WalletApi(createClient()).getDepositAddress(currency);
@@ -70,7 +70,7 @@ export function registerWalletTools(server) {
70
70
  return errorContent(e);
71
71
  }
72
72
  });
73
- server.tool('cex.wallet.create_transfer', 'Transfer funds between accounts (requires authentication) — always confirm the amount, source, and destination with the user before calling this tool', {
73
+ server.tool('cex_wallet_create_transfer', 'Transfer funds between accounts (requires authentication) — always confirm the amount, source, and destination with the user before calling this tool', {
74
74
  currency: z.string().describe('Currency to transfer'),
75
75
  from: z.enum(['spot', 'margin', 'futures', 'delivery', 'options']).describe('Source account'),
76
76
  to: z.enum(['spot', 'margin', 'futures', 'delivery', 'options']).describe('Destination account'),
@@ -92,7 +92,7 @@ export function registerWalletTools(server) {
92
92
  return errorContent(e);
93
93
  }
94
94
  });
95
- server.tool('cex.wallet.list_sub_account_balances', 'List sub-account balances (requires authentication)', { sub_uid: z.string().optional().describe('Filter by sub-account UID') }, async ({ sub_uid }) => {
95
+ server.tool('cex_wallet_list_sub_account_balances', 'List sub-account balances (requires authentication)', { sub_uid: z.string().optional().describe('Filter by sub-account UID') }, async ({ sub_uid }) => {
96
96
  try {
97
97
  requireAuth();
98
98
  const opts = {};
@@ -105,7 +105,7 @@ export function registerWalletTools(server) {
105
105
  return errorContent(e);
106
106
  }
107
107
  });
108
- server.tool('cex.wallet.get_wallet_fee', 'Get trading fee rates (requires authentication)', {
108
+ server.tool('cex_wallet_get_wallet_fee', 'Get trading fee rates (requires authentication)', {
109
109
  currency_pair: z.string().optional().describe('Filter by currency pair'),
110
110
  settle: z.enum(['BTC', 'USDT', 'USD']).optional().describe('Futures settlement currency'),
111
111
  }, async ({ currency_pair, settle }) => {
@@ -123,7 +123,7 @@ export function registerWalletTools(server) {
123
123
  return errorContent(e);
124
124
  }
125
125
  });
126
- server.tool('cex.wallet.create_sub_account_transfer', 'Transfer between main account and sub-account (requires authentication) — always confirm the amount with the user before calling this tool', {
126
+ server.tool('cex_wallet_create_sub_account_transfer', 'Transfer between main account and sub-account (requires authentication) — always confirm the amount with the user before calling this tool', {
127
127
  sub_account: z.string().describe('Sub-account user ID'),
128
128
  currency: z.string().describe('Currency name e.g. USDT'),
129
129
  amount: z.string().describe('Transfer amount'),
@@ -149,7 +149,7 @@ export function registerWalletTools(server) {
149
149
  return errorContent(e);
150
150
  }
151
151
  });
152
- server.tool('cex.wallet.create_sub_account_to_sub_account_transfer', 'Transfer between two sub-accounts under the same main account (requires authentication) — always confirm the amount with the user before calling this tool', {
152
+ server.tool('cex_wallet_create_sub_account_to_sub_account_transfer', 'Transfer between two sub-accounts under the same main account (requires authentication) — always confirm the amount with the user before calling this tool', {
153
153
  currency: z.string().describe('Currency name e.g. USDT'),
154
154
  sub_account_from: z.string().describe('Source sub-account user ID'),
155
155
  sub_account_from_type: z.string().describe('Source sub-account type: spot/futures/delivery'),
@@ -173,7 +173,7 @@ export function registerWalletTools(server) {
173
173
  return errorContent(e);
174
174
  }
175
175
  });
176
- server.tool('cex.wallet.get_transfer_order_status', 'Query main-sub account transfer status (requires authentication)', {
176
+ server.tool('cex_wallet_get_transfer_order_status', 'Query main-sub account transfer status (requires authentication)', {
177
177
  client_order_id: z.string().optional().describe('Client specified custom ID'),
178
178
  tx_id: z.string().optional().describe('Transaction ID returned by the transfer API'),
179
179
  }, async ({ client_order_id, tx_id }) => {
@@ -191,7 +191,7 @@ export function registerWalletTools(server) {
191
191
  return errorContent(e);
192
192
  }
193
193
  });
194
- server.tool('cex.wallet.list_currency_chains', 'List chains supported for a currency', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
194
+ server.tool('cex_wallet_list_currency_chains', 'List chains supported for a currency', { currency: z.string().describe('Currency symbol e.g. USDT') }, async ({ currency }) => {
195
195
  try {
196
196
  const { body } = await new WalletApi(createClient()).listCurrencyChains(currency);
197
197
  return textContent(body);
@@ -200,7 +200,7 @@ export function registerWalletTools(server) {
200
200
  return errorContent(e);
201
201
  }
202
202
  });
203
- server.tool('cex.wallet.list_withdraw_status', 'Get withdrawal status for all currencies (requires authentication)', { currency: z.string().optional().describe('Filter by currency') }, async ({ currency }) => {
203
+ server.tool('cex_wallet_list_withdraw_status', 'Get withdrawal status for all currencies (requires authentication)', { currency: z.string().optional().describe('Filter by currency') }, async ({ currency }) => {
204
204
  try {
205
205
  requireAuth();
206
206
  const opts = {};
package/dist/utils.d.ts CHANGED
@@ -32,4 +32,10 @@ export declare function errorContent(err: unknown): {
32
32
  }[];
33
33
  isError: boolean;
34
34
  };
35
+ /**
36
+ * Returns true if the tool name refers to a state-mutating (write) operation.
37
+ * Tool names follow the pattern cex_{module}_{verb}_{rest}, so the verb is always
38
+ * the third underscore-separated segment (index 2).
39
+ */
40
+ export declare function isWriteTool(name: string): boolean;
35
41
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMrD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO;;;;;EAEzC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO;;;;;;EAGxC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMrD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO;;;;;EAEzC;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO;;;;;;EAGxC;AAOD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEjD"}
package/dist/utils.js CHANGED
@@ -36,4 +36,16 @@ export function errorContent(err) {
36
36
  const message = err instanceof Error ? err.message : String(err);
37
37
  return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
38
38
  }
39
+ const WRITE_VERBS = new Set([
40
+ 'create', 'cancel', 'amend', 'update', 'set',
41
+ 'delete', 'lock', 'unlock', 'add', 'countdown',
42
+ ]);
43
+ /**
44
+ * Returns true if the tool name refers to a state-mutating (write) operation.
45
+ * Tool names follow the pattern cex_{module}_{verb}_{rest}, so the verb is always
46
+ * the third underscore-separated segment (index 2).
47
+ */
48
+ export function isWriteTool(name) {
49
+ return WRITE_VERBS.has(name.split('_')[2] ?? '');
50
+ }
39
51
  //# sourceMappingURL=utils.js.map