@solworks/poll-mcp 0.1.9 → 0.1.11
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/tools/index.js +22 -7
- package/package.json +2 -2
package/dist/tools/index.js
CHANGED
|
@@ -4,6 +4,10 @@ function errorResult(message) {
|
|
|
4
4
|
function textResult(text) {
|
|
5
5
|
return { content: [{ type: 'text', text }] };
|
|
6
6
|
}
|
|
7
|
+
/** Format a raw USDC micro-unit amount (6 decimals) as a human-readable dollar string. */
|
|
8
|
+
function formatUsdc(raw) {
|
|
9
|
+
return `$${(raw / 1e6).toFixed(2)}`;
|
|
10
|
+
}
|
|
7
11
|
export const TOOL_DEFINITIONS = {
|
|
8
12
|
// ── Read tools (scope: read) ───────────────────────────────────────
|
|
9
13
|
get_account: {
|
|
@@ -92,7 +96,11 @@ export const TOOL_DEFINITIONS = {
|
|
|
92
96
|
const page = args.page;
|
|
93
97
|
const bets = await client.listPublicBets({ page });
|
|
94
98
|
const display = bets.slice(0, 20);
|
|
95
|
-
const lines = display.map((b, i) =>
|
|
99
|
+
const lines = display.map((b, i) => {
|
|
100
|
+
const volume = formatUsdc(b.totalOiFor + b.totalOiAgainst);
|
|
101
|
+
const participants = Array.isArray(b.wagers) ? b.wagers.length : 0;
|
|
102
|
+
return `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${volume} (For: ${formatUsdc(b.totalOiFor)} / Against: ${formatUsdc(b.totalOiAgainst)}), Participants: ${participants}, Address: ${b.betAddress}`;
|
|
103
|
+
});
|
|
96
104
|
let text = `Public Bets:\n${lines.join('\n')}`;
|
|
97
105
|
if (bets.length > 20)
|
|
98
106
|
text += `\n\n(Showing 20 of ${bets.length})`;
|
|
@@ -114,7 +122,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
114
122
|
try {
|
|
115
123
|
const bets = await client.getTrendingBets();
|
|
116
124
|
const display = bets.slice(0, 20);
|
|
117
|
-
const lines = display.map((b, i) => `${i + 1}. ${b.question} — Volume: ${b.
|
|
125
|
+
const lines = display.map((b, i) => `${i + 1}. ${b.question} — Volume: ${formatUsdc(b.totalOiFor + b.totalOiAgainst)} (For: ${formatUsdc(b.totalOiFor)} / Against: ${formatUsdc(b.totalOiAgainst)}), Address: ${b.betAddress}`);
|
|
118
126
|
let text = `Trending Bets:\n${lines.join('\n')}`;
|
|
119
127
|
if (bets.length > 20)
|
|
120
128
|
text += `\n\n(Showing 20 of ${bets.length})`;
|
|
@@ -144,12 +152,13 @@ export const TOOL_DEFINITIONS = {
|
|
|
144
152
|
return errorResult('Missing required parameter: id');
|
|
145
153
|
try {
|
|
146
154
|
const bet = await client.getBet(id);
|
|
155
|
+
const volume = formatUsdc(bet.totalOiFor + bet.totalOiAgainst);
|
|
147
156
|
const lines = [
|
|
148
157
|
`Bet Details:`,
|
|
149
158
|
` Question: ${bet.question}`,
|
|
150
159
|
` Status: ${bet.status}`,
|
|
151
160
|
` Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}`,
|
|
152
|
-
` Volume: ${bet.
|
|
161
|
+
` Volume: ${volume} (For: ${formatUsdc(bet.totalOiFor)} / Against: ${formatUsdc(bet.totalOiAgainst)})`,
|
|
153
162
|
` Created: ${bet.createdAt}`,
|
|
154
163
|
];
|
|
155
164
|
if (bet.betAddress)
|
|
@@ -177,7 +186,12 @@ export const TOOL_DEFINITIONS = {
|
|
|
177
186
|
const wagers = await client.getMyWagers({ active });
|
|
178
187
|
if (wagers.length === 0)
|
|
179
188
|
return textResult('No wagers found.');
|
|
180
|
-
const lines = wagers.map((w, i) =>
|
|
189
|
+
const lines = wagers.map((w, i) => {
|
|
190
|
+
const bet = w.ProgramBet;
|
|
191
|
+
const betName = bet?.question ?? 'Unknown';
|
|
192
|
+
const betAddr = w.betAddress ?? w.programBetBetAddress ?? '?';
|
|
193
|
+
return `${i + 1}. ${betName} — Side: ${w.outcome}, Amount: ${formatUsdc(w.amount)}, Status: ${w.status}, Address: ${betAddr}`;
|
|
194
|
+
});
|
|
181
195
|
return textResult(`Your Wagers:\n${lines.join('\n')}`);
|
|
182
196
|
}
|
|
183
197
|
catch (err) {
|
|
@@ -236,7 +250,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
236
250
|
const txns = await client.getWalletTransactions();
|
|
237
251
|
if (txns.length === 0)
|
|
238
252
|
return textResult('No transactions found.');
|
|
239
|
-
const lines = txns.map((t, i) => `${i + 1}. ${t.type} — Amount: ${t.amount}, Date: ${t.createdAt}`);
|
|
253
|
+
const lines = txns.map((t, i) => `${i + 1}. ${t.type} — Amount: ${formatUsdc(t.amount)}, Date: ${t.createdAt}`);
|
|
240
254
|
return textResult(`Wallet Transactions:\n${lines.join('\n')}`);
|
|
241
255
|
}
|
|
242
256
|
catch (err) {
|
|
@@ -320,7 +334,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
320
334
|
const bets = await client.getFavouriteBets();
|
|
321
335
|
if (bets.length === 0)
|
|
322
336
|
return textResult('No favourite bets found.');
|
|
323
|
-
const lines = bets.map((b, i) => `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${b.
|
|
337
|
+
const lines = bets.map((b, i) => `${i + 1}. ${b.question} — Status: ${b.status}, Volume: ${formatUsdc(b.totalOiFor + b.totalOiAgainst)} (For: ${formatUsdc(b.totalOiFor)} / Against: ${formatUsdc(b.totalOiAgainst)}), Address: ${b.betAddress}`);
|
|
324
338
|
return textResult(`Favourite Bets:\n${lines.join('\n')}`);
|
|
325
339
|
}
|
|
326
340
|
catch (err) {
|
|
@@ -390,7 +404,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
390
404
|
amount: args.amount,
|
|
391
405
|
expiresAt: args.expiresAt,
|
|
392
406
|
});
|
|
393
|
-
return textResult(`Bet created successfully!\n Question: ${bet.question}\n Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}\n Status: ${bet.status}\n
|
|
407
|
+
return textResult(`Bet created successfully!\n Question: ${bet.question}\n Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}\n Status: ${bet.status}\n Address: ${bet.betAddress}`);
|
|
394
408
|
}
|
|
395
409
|
catch (err) {
|
|
396
410
|
return errorResult(err.message);
|
|
@@ -446,6 +460,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
446
460
|
return errorResult('Missing required parameter: amount');
|
|
447
461
|
try {
|
|
448
462
|
const side = optionIndex === 0 ? 'for' : 'against';
|
|
463
|
+
await client.validateWagerSide(betAddress, side);
|
|
449
464
|
await client.placeWager({ marketPubkey: betAddress, amount, side: side });
|
|
450
465
|
return textResult(`Wager placed successfully!\n Bet: ${betAddress}\n Option: ${optionIndex} (${side})\n Amount: ${amount}`);
|
|
451
466
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solworks/poll-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "MCP server for Poll.fun. See documentation at https://dev.poll.fun",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
21
|
-
"@solworks/poll-api-client": "
|
|
21
|
+
"@solworks/poll-api-client": "file:../poll-api-client",
|
|
22
22
|
"zod": "^3.24.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|