@tongateway/mcp 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +20 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -109,12 +109,20 @@ server.tool('get_auth_token', 'Complete authentication after the user opened the
109
109
  authId: z.string().describe('The authId returned by request_auth'),
110
110
  }, async ({ authId }) => {
111
111
  try {
112
- const result = await fetch(`${API_URL}/v1/auth/check/${authId}`, {
113
- headers: { 'Content-Type': 'application/json' },
114
- });
115
- const data = await result.json();
116
- if (!result.ok)
117
- throw new Error(data.error ?? 'Failed');
112
+ // Retry up to 3 times with 2s delay (KV eventual consistency)
113
+ let data = null;
114
+ for (let attempt = 0; attempt < 3; attempt++) {
115
+ const result = await fetch(`${API_URL}/v1/auth/check/${authId}`, {
116
+ headers: { 'Content-Type': 'application/json' },
117
+ });
118
+ data = await result.json();
119
+ if (!result.ok)
120
+ throw new Error(data.error ?? 'Failed');
121
+ if (data.status === 'completed')
122
+ break;
123
+ if (attempt < 2)
124
+ await new Promise(r => setTimeout(r, 2000));
125
+ }
118
126
  if (data.status === 'pending') {
119
127
  return {
120
128
  content: [
@@ -124,7 +132,7 @@ server.tool('get_auth_token', 'Complete authentication after the user opened the
124
132
  `Authentication still pending.`,
125
133
  `The user has not connected their wallet yet.`,
126
134
  ``,
127
- `Wait a moment and try again.`,
135
+ `Wait a moment and call get_auth_token again.`,
128
136
  ].join('\n'),
129
137
  },
130
138
  ],
@@ -403,7 +411,7 @@ server.tool('get_ton_price', 'Get the current TON price in USD, EUR, or other cu
403
411
  return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
404
412
  }
405
413
  });
406
- server.tool('create_swap_order', 'Swap tokens on the open4dev DEX. Provide the token pair (e.g. NOT→TON), amount, and price. The order is created as a safe transfer — the user approves it in their wallet. Use get_ton_price or get_jetton_balances to determine current rates before swapping.', {
414
+ server.tool('create_dex_order', 'Place a limit order on the open4dev DEX order book. Provide the token pair (e.g. NOT→TON), amount, and price. The order is created as a safe transfer — the user approves it in their wallet. Use get_ton_price or get_jetton_balances to determine current rates before swapping.', {
407
415
  fromToken: z.string().describe('Token to sell, e.g. "NOT", "TON", "USDT"'),
408
416
  toToken: z.string().describe('Token to buy, e.g. "TON", "NOT"'),
409
417
  amount: z.string().describe('Amount to sell in smallest unit (nanoTON for TON, or raw jetton amount based on decimals)'),
@@ -413,7 +421,7 @@ server.tool('create_swap_order', 'Swap tokens on the open4dev DEX. Provide the t
413
421
  return { content: [{ type: 'text', text: 'No token configured. Use request_auth first.' }], isError: true };
414
422
  }
415
423
  try {
416
- const result = await apiCall('/v1/dex/swap', {
424
+ const result = await apiCall('/v1/dex/order', {
417
425
  method: 'POST',
418
426
  body: JSON.stringify({ fromToken, toToken, amount, priceRateNano }),
419
427
  });
@@ -421,7 +429,7 @@ server.tool('create_swap_order', 'Swap tokens on the open4dev DEX. Provide the t
421
429
  content: [{
422
430
  type: 'text',
423
431
  text: [
424
- `Swap order created!`,
432
+ `Order placed on open4dev DEX!`,
425
433
  ``,
426
434
  `${fromToken} → ${toToken}`,
427
435
  `Amount: ${amount}`,
@@ -429,7 +437,7 @@ server.tool('create_swap_order', 'Swap tokens on the open4dev DEX. Provide the t
429
437
  `Pool: ${result.swap?.pool || 'unknown'}`,
430
438
  `Request ID: ${result.id}`,
431
439
  ``,
432
- `Approve the swap in your wallet app.`,
440
+ `Approve the order in your wallet app.`,
433
441
  ].join('\n'),
434
442
  }],
435
443
  };
@@ -438,7 +446,7 @@ server.tool('create_swap_order', 'Swap tokens on the open4dev DEX. Provide the t
438
446
  return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
439
447
  }
440
448
  });
441
- server.tool('list_dex_pools', 'List available trading pairs on the DEX. Shows which token swaps are configured and available.', {}, async () => {
449
+ server.tool('list_dex_pairs', 'List available trading pairs on the DEX. Shows which token swaps are configured and available.', {}, async () => {
442
450
  try {
443
451
  const result = await fetch(`${API_URL}/v1/dex/pools`);
444
452
  const data = await result.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tongateway/mcp",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "MCP server for Agent Gateway — lets AI agents request TON blockchain transfers",
5
5
  "license": "MIT",
6
6
  "repository": {