@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
JavaScript
/**
* 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);
}