UNPKG

spex-mcp

Version:

MCP server for Figma SpeX plugin and Cursor AI integration

57 lines (49 loc) 1.95 kB
#!/usr/bin/env node // For MCP server communication, stdout must be reserved for JSON-RPC // All diagnostic output must go to stderr import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; import { pathToFileURL } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); // Function to safely redirect output to stderr function logToStderr(message) { process.stderr.write(message + '\n'); } async function main() { try { // Resolve the main module path const mainModulePath = join(__dirname, '..', 'src', 'index.js'); const mainModuleUrl = pathToFileURL(mainModulePath); // Import and start the main module await import(mainModuleUrl); } catch (error) { // All error output goes to stderr to preserve stdout for MCP communication if (error.code === 'ERR_MODULE_NOT_FOUND') { logToStderr('❌ Dependencies not found. Please install spex-mcp properly:'); logToStderr(''); logToStderr('Global installation:'); logToStderr(' npm install -g spex-mcp'); logToStderr(''); logToStderr('Local installation:'); logToStderr(' npm install spex-mcp'); logToStderr(' npx spex-mcp'); logToStderr(''); logToStderr('Or run directly from source:'); logToStderr(' git clone <repository>'); logToStderr(' cd spex-mcp'); logToStderr(' npm install'); logToStderr(' npm start'); logToStderr(''); logToStderr(`Error details: ${error.message}`); } else { logToStderr(`❌ Error starting SpeX MCP server: ${error.message}`); } process.exit(1); } } // Run the main function main().catch((error) => { logToStderr(`❌ Unexpected error: ${error.message}`); process.exit(1); });