// Test script to connect to figmamind on Smithery
const WebSocket = require('ws');
// Initialize connection to the Smithery server
const socket = new WebSocket('wss://server.smithery.ai/@joao-loker/figmamind');
// Connection opened
socket.on('open', () => {
console.log('Connection established successfully!');
// Send initialize message
const initMessage = {
jsonrpc: '2.0',
method: 'initialize',
id: 1
};
socket.send(JSON.stringify(initMessage));
console.log('Sent initialize message');
});
// Listen for messages
socket.on('message', (data) => {
console.log('Received message:', data.toString());
try {
const response = JSON.parse(data.toString());
// If this was the initialize response, try listing tools
if (response.id === 1) {
console.log('Initialization successful, listing tools...');
const toolsMessage = {
jsonrpc: '2.0',
method: 'tools.list',
id: 2
};
socket.send(JSON.stringify(toolsMessage));
}
// If we received the tools list, try executing the info tool
if (response.id === 2) {
console.log('Tools list received, trying to run figmamind.info...');
const runInfoMessage = {
jsonrpc: '2.0',
method: 'tools.run',
params: {
name: 'figmamind.info',
arguments: {}
},
id: 3
};
socket.send(JSON.stringify(runInfoMessage));
}
// After getting info, close the connection
if (response.id === 3) {
console.log('Test completed successfully!');
socket.close();
}
} catch (error) {
console.error('Error parsing message:', error);
}
});
// Connection error
socket.on('error', (error) => {
console.error('WebSocket error:', error);
});
// Connection closed
socket.on('close', (code, reason) => {
console.log(`Connection closed: ${code} - ${reason}`);
process.exit(0);
});
// Set a timeout to exit if nothing happens
setTimeout(() => {
console.log('Test timed out after 10 seconds');
socket.close();
process.exit(1);
}, 10000);