@solworks/poll-mcp 0.1.6 → 0.1.7
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.d.ts +4 -2
- package/dist/index.js +22 -5
- package/dist/tools/index.js +10 -8
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
-
import
|
|
3
|
+
import pkg from '@solworks/poll-api-client';
|
|
4
|
+
declare const PollClient: typeof pkg.PollClient;
|
|
4
5
|
export interface McpServerConfig {
|
|
5
6
|
apiToken: string;
|
|
6
7
|
apiUrl: string;
|
|
7
8
|
}
|
|
8
|
-
export declare function createServer(config?: McpServerConfig, clientOverride?: PollClient): McpServer;
|
|
9
|
+
export declare function createServer(config?: McpServerConfig, clientOverride?: InstanceType<typeof PollClient>): McpServer;
|
|
10
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import
|
|
5
|
+
import pkg from '@solworks/poll-api-client';
|
|
6
|
+
const { PollClient } = pkg;
|
|
6
7
|
import { TOOL_DEFINITIONS } from './tools/index.js';
|
|
7
8
|
import { RESOURCE_DEFINITIONS } from './resources/index.js';
|
|
8
9
|
import { PROMPT_DEFINITIONS } from './prompts/index.js';
|
|
@@ -45,13 +46,29 @@ export function createServer(config, clientOverride) {
|
|
|
45
46
|
shape[key] = zodType;
|
|
46
47
|
}
|
|
47
48
|
// Use the deprecated tool() API which is simpler and avoids deep type recursion
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
const toolName = tool.name;
|
|
50
|
+
server.tool(toolName, tool.description, shape, async (args) => {
|
|
51
|
+
const start = Date.now();
|
|
52
|
+
const result = await tool.handler(args, client);
|
|
53
|
+
client.trackEvent('MCP Tool Invoked', {
|
|
54
|
+
tool: toolName,
|
|
55
|
+
duration_ms: Date.now() - start,
|
|
56
|
+
is_error: result.isError ?? false,
|
|
57
|
+
}).catch(() => { });
|
|
58
|
+
return result;
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
61
|
else {
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
const toolName = tool.name;
|
|
63
|
+
server.tool(toolName, tool.description, async () => {
|
|
64
|
+
const start = Date.now();
|
|
65
|
+
const result = await tool.handler({}, client);
|
|
66
|
+
client.trackEvent('MCP Tool Invoked', {
|
|
67
|
+
tool: toolName,
|
|
68
|
+
duration_ms: Date.now() - start,
|
|
69
|
+
is_error: result.isError ?? false,
|
|
70
|
+
}).catch(() => { });
|
|
71
|
+
return result;
|
|
55
72
|
});
|
|
56
73
|
}
|
|
57
74
|
}
|
package/dist/tools/index.js
CHANGED
|
@@ -148,7 +148,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
148
148
|
`Bet Details:`,
|
|
149
149
|
` Question: ${bet.question}`,
|
|
150
150
|
` Status: ${bet.status}`,
|
|
151
|
-
` Options: ${bet.options.join(', ')}`,
|
|
151
|
+
` Options: ${Array.isArray(bet.options) ? bet.options.join(', ') : 'For / Against'}`,
|
|
152
152
|
` Volume: ${bet.totalVolume ?? 'N/A'}`,
|
|
153
153
|
` Created: ${bet.createdAt}`,
|
|
154
154
|
];
|
|
@@ -390,7 +390,7 @@ export const TOOL_DEFINITIONS = {
|
|
|
390
390
|
amount: args.amount,
|
|
391
391
|
expiresAt: args.expiresAt,
|
|
392
392
|
});
|
|
393
|
-
return textResult(`Bet created successfully!\n Question: ${bet.question}\n Options: ${bet.options.join(', ')}\n Status: ${bet.status}\n ID: ${bet.
|
|
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 ID: ${bet.betAddress}`);
|
|
394
394
|
}
|
|
395
395
|
catch (err) {
|
|
396
396
|
return errorResult(err.message);
|
|
@@ -445,8 +445,9 @@ export const TOOL_DEFINITIONS = {
|
|
|
445
445
|
if (amount === undefined || amount === null)
|
|
446
446
|
return errorResult('Missing required parameter: amount');
|
|
447
447
|
try {
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
const side = optionIndex === 0 ? 'for' : 'against';
|
|
449
|
+
await client.placeWager({ marketPubkey: betAddress, amount, side: side });
|
|
450
|
+
return textResult(`Wager placed successfully!\n Bet: ${betAddress}\n Option: ${optionIndex} (${side})\n Amount: ${amount}`);
|
|
450
451
|
}
|
|
451
452
|
catch (err) {
|
|
452
453
|
return errorResult(err.message);
|
|
@@ -473,8 +474,8 @@ export const TOOL_DEFINITIONS = {
|
|
|
473
474
|
if (!wagerAddress)
|
|
474
475
|
return errorResult('Missing required parameter: wagerAddress');
|
|
475
476
|
try {
|
|
476
|
-
await client.cancelWager({ betAddress
|
|
477
|
-
return textResult(`Wager cancelled successfully: ${
|
|
477
|
+
await client.cancelWager({ marketPubkey: betAddress });
|
|
478
|
+
return textResult(`Wager cancelled successfully for bet: ${betAddress}`);
|
|
478
479
|
}
|
|
479
480
|
catch (err) {
|
|
480
481
|
return errorResult(err.message);
|
|
@@ -525,8 +526,9 @@ export const TOOL_DEFINITIONS = {
|
|
|
525
526
|
if (optionIndex === undefined || optionIndex === null)
|
|
526
527
|
return errorResult('Missing required parameter: optionIndex');
|
|
527
528
|
try {
|
|
528
|
-
|
|
529
|
-
|
|
529
|
+
const outcome = optionIndex === 0 ? 'for' : 'against';
|
|
530
|
+
await client.vote({ marketPubkey: betAddress, outcome: outcome });
|
|
531
|
+
return textResult(`Vote cast successfully on bet ${betAddress} for option ${optionIndex} (${outcome})`);
|
|
530
532
|
}
|
|
531
533
|
catch (err) {
|
|
532
534
|
return errorResult(err.message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solworks/poll-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
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": "^0.1.6",
|
|
22
22
|
"zod": "^3.24.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|