FigmaMind MCP Server

by joao-loker
Verified
// Test script that pipes commands to the MCP server and captures the output const { spawn } = require('child_process'); const readline = require('readline'); // Start the MCP server const mcpServer = spawn('node', ['minimal-cursor-mcp.js'], { env: { ...process.env, MCP_DEBUG: 'true' } }); // Create readline interfaces for stdout and stderr const stdoutRl = readline.createInterface({ input: mcpServer.stdout, terminal: false }); const stderrRl = readline.createInterface({ input: mcpServer.stderr, terminal: false }); // Listen to stdout stdoutRl.on('line', (line) => { console.log(`[MCP stdout]: ${line}`); // Try to parse JSON response try { const response = JSON.parse(line); if (response.id === 4) { console.log('\nTest completed successfully!'); setTimeout(() => { mcpServer.kill(); process.exit(0); }, 1000); } } catch (error) { // Not JSON or couldn't parse } }); // Listen to stderr stderrRl.on('line', (line) => { console.log(`[MCP stderr]: ${line}`); }); // Handle process exit mcpServer.on('close', (code) => { console.log(`MCP server exited with code ${code}`); process.exit(0); }); // Wait for the server to start setTimeout(() => { // Initialize message sequence const messages = [ // Initialize request { jsonrpc: '2.0', method: 'initialize', id: 1 }, // List tools request { jsonrpc: '2.0', method: 'tools.list', id: 2 }, // Get figmamind.info tool { jsonrpc: '2.0', method: 'tools.get', params: { name: 'figmamind.info' }, id: 3 }, // Run figmamind.info tool { jsonrpc: '2.0', method: 'tools.run', params: { name: 'figmamind.info', arguments: {} }, id: 4 } ]; // Send messages with delay async function sendMessages() { for (let i = 0; i < messages.length; i++) { console.log(`\n*** Sending message ${i+1} ***`); console.log(JSON.stringify(messages[i], null, 2)); // Write to the MCP server's stdin mcpServer.stdin.write(JSON.stringify(messages[i]) + '\n'); // Wait between messages if (i < messages.length - 1) { await new Promise(resolve => setTimeout(resolve, 2000)); } } } // Start sending messages sendMessages(); }, 1000); // Give the server a second to start up // Set a timeout to exit if the test takes too long setTimeout(() => { console.log('Test timed out after 30 seconds'); mcpServer.kill(); process.exit(1); }, 30000);