UNPKG

@dorothywebb/any-browser-mcp

Version:

Any Browser MCP - Launch Chrome with your actual data in debug mode for comprehensive browser automation

62 lines (48 loc) • 1.87 kB
#!/usr/bin/env node /** * Entry point for Any Browser MCP Server * Works with both local development and npm global installation */ import { existsSync } from 'fs'; import { join, dirname } from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const projectRoot = join(__dirname, '..'); // Check if dist directory exists (should be built during npm publish) const distPath = join(projectRoot, 'dist', 'server.js'); if (!existsSync(distPath)) { console.error('āŒ Compiled server not found. This package may not be properly built.'); console.error(' If you\'re developing locally, run: npm run build'); console.error(' If you installed via npm, please report this as a bug.'); process.exit(1); } // Import and start the server try { const { AnyBrowserMCPServer } = await import('../dist/server.js'); // Handle command line arguments const args = process.argv.slice(2); const verbose = args.includes('--verbose') || args.includes('-v'); if (verbose) { console.log('šŸš€ Starting Any Browser MCP Server...'); console.log(' āœ… DATA DUPLICATE: Will create Chrome duplicate with your data'); console.log(' āœ… LAZY: Will launch only when tools are used'); console.log(' āœ… SAFE: Will preserve your main Chrome session untouched'); } const server = new AnyBrowserMCPServer(); // Setup graceful shutdown process.on('SIGINT', async () => { console.log('\nšŸ›‘ Shutting down gracefully...'); await server.stop(); process.exit(0); }); process.on('SIGTERM', async () => { console.log('\nšŸ›‘ Shutting down gracefully...'); await server.stop(); process.exit(0); }); await server.start(); } catch (error) { console.error('šŸ’„ Failed to start server:', error); process.exit(1); }