launch-browser-automation.shā¢2.51 kB
#!/bin/bash
# Launch Script for Browser Automation MCP Server
# Version: 2.0.0
# Created: 2025-07-02
echo "š EuConquisto Composer Browser Automation Launcher v2.0.0"
echo "======================================================="
# Check if JWT redirect server is running
check_jwt_server() {
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/health | grep -q "200"; then
echo "ā
JWT redirect server is already running on port 8080"
return 0
else
echo "ā ļø JWT redirect server is not running"
return 1
fi
}
# Start JWT redirect server if not running
start_jwt_server() {
echo "š Starting JWT redirect server..."
node tools/servers/jwt-redirect-server-v1.0.2.js &
JWT_PID=$!
echo " JWT server started with PID: $JWT_PID"
# Wait for server to be ready
sleep 2
if check_jwt_server; then
echo "ā
JWT server is ready"
else
echo "ā Failed to start JWT server"
exit 1
fi
}
# Check JWT token
check_jwt_token() {
JWT_FILE="archive/authentication/correct-jwt-new.txt"
if [ -f "$JWT_FILE" ]; then
echo "ā
JWT token found at $JWT_FILE"
# Check token expiration (hardcoded for now)
echo " Token expires: 2025-07-28"
return 0
else
echo "ā JWT token not found at $JWT_FILE"
echo " Please ensure you have a valid JWT token"
return 1
fi
}
# Check Playwright installation
check_playwright() {
if npm list playwright &>/dev/null; then
echo "ā
Playwright is installed"
return 0
else
echo "ā ļø Playwright not found, installing..."
npm install playwright
npx playwright install chromium
echo "ā
Playwright installed"
fi
}
# Main execution
echo ""
echo "š Pre-flight checks:"
echo "--------------------"
# Check JWT token
if ! check_jwt_token; then
exit 1
fi
# Check Playwright
check_playwright
# Check/Start JWT server
if ! check_jwt_server; then
start_jwt_server
fi
echo ""
echo "šÆ Starting Browser Automation MCP Server..."
echo "-------------------------------------------"
echo ""
# Start the MCP server
npm run mcp:browser-automation
# Cleanup function
cleanup() {
echo ""
echo "š Shutting down..."
if [ ! -z "$JWT_PID" ]; then
echo " Stopping JWT server (PID: $JWT_PID)"
kill $JWT_PID 2>/dev/null
fi
exit 0
}
# Set up cleanup on exit
trap cleanup EXIT INT TERM