UNPKG

nia-web-eval-agent-mcp

Version:

NIA AI Web Evaluation Agent MCP Server - Autonomous browser testing and debugging

77 lines (66 loc) 1.97 kB
#!/usr/bin/env node const { spawn } = require('cross-spawn'); const path = require('path'); const fs = require('fs'); // Check if required environment variables are set if (!process.env.NIA_API_KEY) { console.error('❌ Error: NIA_API_KEY environment variable is required'); console.error('📖 Get your API key at: https://trynia.ai'); console.error('💡 Set it in your MCP client config:'); console.error(' "env": { "NIA_API_KEY": "your-api-key-here" }'); process.exit(1); } // Check if uv is installed const { execSync } = require('child_process'); try { execSync('uv --version', { stdio: 'ignore' }); } catch (error) { console.error('❌ Error: uv is not installed'); console.error('📦 Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh'); process.exit(1); } // Check if playwright is installed try { execSync('playwright --version', { stdio: 'ignore' }); } catch (error) { console.error('🎭 Installing Playwright...'); try { execSync('npm install -g playwright && playwright install --with-deps', { stdio: 'inherit' }); } catch (installError) { console.error('❌ Failed to install Playwright'); process.exit(1); } } // Run the Python MCP server const args = [ '--from', 'git+https://github.com/nia-ai-app/web-eval-agent.git', 'webEvalAgent' ]; console.error('🚀 Starting NIA Web Eval Agent MCP Server...'); console.error('📦 Installing from git repository (this may take a moment on first run)...'); const child = spawn('uvx', args, { stdio: 'inherit', env: { ...process.env, NIA_API_KEY: process.env.NIA_API_KEY } }); child.on('error', (error) => { console.error('❌ Failed to start server:', error.message); process.exit(1); }); child.on('exit', (code) => { process.exit(code); }); // Handle graceful shutdown process.on('SIGINT', () => { if (child) { child.kill('SIGINT'); } }); process.on('SIGTERM', () => { if (child) { child.kill('SIGTERM'); } });