@tongateway/mcp 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -403,6 +403,57 @@ server.tool('get_ton_price', 'Get the current TON price in USD, EUR, or other cu
|
|
|
403
403
|
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
404
404
|
}
|
|
405
405
|
});
|
|
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.', {
|
|
407
|
+
fromToken: z.string().describe('Token to sell, e.g. "NOT", "TON", "USDT"'),
|
|
408
|
+
toToken: z.string().describe('Token to buy, e.g. "TON", "NOT"'),
|
|
409
|
+
amount: z.string().describe('Amount to sell in smallest unit (nanoTON for TON, or raw jetton amount based on decimals)'),
|
|
410
|
+
priceRateNano: z.string().describe('Price rate in nanoTON per unit'),
|
|
411
|
+
}, async ({ fromToken, toToken, amount, priceRateNano }) => {
|
|
412
|
+
if (!TOKEN) {
|
|
413
|
+
return { content: [{ type: 'text', text: 'No token configured. Use request_auth first.' }], isError: true };
|
|
414
|
+
}
|
|
415
|
+
try {
|
|
416
|
+
const result = await apiCall('/v1/dex/swap', {
|
|
417
|
+
method: 'POST',
|
|
418
|
+
body: JSON.stringify({ fromToken, toToken, amount, priceRateNano }),
|
|
419
|
+
});
|
|
420
|
+
return {
|
|
421
|
+
content: [{
|
|
422
|
+
type: 'text',
|
|
423
|
+
text: [
|
|
424
|
+
`Swap order created!`,
|
|
425
|
+
``,
|
|
426
|
+
`${fromToken} → ${toToken}`,
|
|
427
|
+
`Amount: ${amount}`,
|
|
428
|
+
`Price Rate: ${priceRateNano} nanoTON`,
|
|
429
|
+
`Pool: ${result.swap?.pool || 'unknown'}`,
|
|
430
|
+
`Request ID: ${result.id}`,
|
|
431
|
+
``,
|
|
432
|
+
`Approve the swap in your wallet app.`,
|
|
433
|
+
].join('\n'),
|
|
434
|
+
}],
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
catch (e) {
|
|
438
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
server.tool('list_dex_pools', 'List available trading pairs on the DEX. Shows which token swaps are configured and available.', {}, async () => {
|
|
442
|
+
try {
|
|
443
|
+
const result = await fetch(`${API_URL}/v1/dex/pools`);
|
|
444
|
+
const data = await result.json();
|
|
445
|
+
if (!data.pools?.length) {
|
|
446
|
+
return { content: [{ type: 'text', text: 'No DEX pools configured yet.' }] };
|
|
447
|
+
}
|
|
448
|
+
const lines = data.pools.map((p) => `- ${p.pair} (${p.direction})`);
|
|
449
|
+
return {
|
|
450
|
+
content: [{ type: 'text', text: `Available pools:\n${lines.join('\n')}` }],
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
catch (e) {
|
|
454
|
+
return { content: [{ type: 'text', text: `Error: ${e.message}` }], isError: true };
|
|
455
|
+
}
|
|
456
|
+
});
|
|
406
457
|
server.tool('deploy_agent_wallet', 'Deploy an Agent Wallet smart contract — a dedicated sub-wallet for autonomous operations. WARNING: The agent can spend funds from this wallet WITHOUT user approval. Only deploy if the user explicitly wants autonomous transfers. After deployment, top up the wallet with funds.', {}, async () => {
|
|
407
458
|
if (!TOKEN) {
|
|
408
459
|
return { content: [{ type: 'text', text: 'No token configured. Use request_auth first.' }], isError: true };
|