@tongateway/mcp 0.10.0 → 0.11.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/dist/index.js +20 -12
- 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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
|
135
|
+
`Wait a moment and call get_auth_token again.`,
|
|
128
136
|
].join('\n'),
|
|
129
137
|
},
|
|
130
138
|
],
|
|
@@ -440,14 +448,14 @@ server.tool('create_dex_order', 'Place a limit order on the open4dev DEX order b
|
|
|
440
448
|
});
|
|
441
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
|
-
const result = await fetch(`${API_URL}/v1/dex/
|
|
451
|
+
const result = await fetch(`${API_URL}/v1/dex/pairs`);
|
|
444
452
|
const data = await result.json();
|
|
445
|
-
|
|
446
|
-
|
|
453
|
+
const tokens = data.tokens || [];
|
|
454
|
+
if (!tokens.length) {
|
|
455
|
+
return { content: [{ type: 'text', text: 'No DEX pairs available.' }] };
|
|
447
456
|
}
|
|
448
|
-
const lines = data.pools.map((p) => `- ${p.pair} (${p.direction})`);
|
|
449
457
|
return {
|
|
450
|
-
content: [{ type: 'text', text: `Available
|
|
458
|
+
content: [{ type: 'text', text: `Available tokens: ${tokens.join(', ')}\n\nAny pair combination is supported (e.g. NOT/TON, USDT/TON, DOGS/NOT).` }],
|
|
451
459
|
};
|
|
452
460
|
}
|
|
453
461
|
catch (e) {
|