UNPKG

wowok_arbitration_mcp_server

Version:

Operations to create or modify an on-chain Arbitration object, where the 'account' field is used to sign transactions and the 'data' field defines object details. The Arbitration object enables its managers to provide dispute arbitration for orders on-cha

70 lines (69 loc) 2.44 kB
#!/usr/bin/env node import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport, } from "@modelcontextprotocol/sdk/server/stdio.js"; import { CallToolRequestSchema, ListToolsRequestSchema, ToolSchema } from "@modelcontextprotocol/sdk/types.js"; import * as A from 'wowok_agent'; const ToolInputSchema = ToolSchema.shape.inputSchema; const ToolOutputSchema = ToolSchema.shape.outputSchema; // Create server instance const server = new Server({ name: "wowok_arbitration_mcp_server", version: "1.3.57", description: `${A.CallArbitrationSchemaDescription} - A server for handling Arbitration calls in the WOWOK protocol. ${A.NoticeFieldsOrder}`, }, { capabilities: { prompts: {}, resources: {}, tools: {}, logging: {}, tokensOptimized: true, // Optimize tokens for better performance and efficiency. }, }); async function main() { const TOOLS = [ { name: A.ToolName.OP_ARBITRATION, description: A.CallArbitrationSchemaDescription, inputSchema: A.CallArbitrationSchemaInput(), }, ]; const transport = new StdioServerTransport(); server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS }; }); server.setRequestHandler(CallToolRequestSchema, async (request) => { try { if (!request.params.arguments) { throw new Error("Arguments are required"); } switch (request.params.name) { case A.ToolName.OP_ARBITRATION: { const args = A.CallArbitrationSchema.parse(request.params.arguments); return { content: [{ type: "text", text: A.ObjectOperationResult(await A.call_arbitration(args)) }] }; } default: throw new Error(`Unknown tool: ${request.params.name}`); } } catch (error) { throw new Error(`Invalid input: ${JSON.stringify(error)}`); } }); await server.connect(transport); // Cleanup on exit process.on("SIGINT", async () => { await cleanup(); await server.close(); process.exit(0); }); } async function cleanup() { } main().catch((error) => { process.exit(1); }); process.stdin.on("close", async () => { await cleanup(); await server.close(); process.exit(0); });