-
Notifications
You must be signed in to change notification settings - Fork 733
Closed
Labels
Description
Summary
Running chrome-devtools-mcp as the root user causes Chrome to exit immediately with Running as root without --no-sandbox is not supported, so the MCP client receives Target closed / Connection closed
errors.
Environment
- chrome-devtools-mcp 0.6.0
- Node.js 22.20.0
- OS: Linux container (root user)
- Command:
node build/src/index.js --headless --isolated
Steps to Reproduce
- Checkout v0.6.0
- Run
npm install && npm run build - Execute
node build/src/index.js --headless --isolatedas root - Observe Chrome crashing with the log above and the MCP server exiting
Expected Behavior
The bundled Chrome should launch successfully even when the server runs as root (typical for containers/CI), without requiring extra flags from the user.
Suggested Fix
Automatically add sandbox flags when running as root. For example in src/browser.ts:
const args = [
...(options.args ?? []),
'--hide-crash-restore-bubble',
];
if (process.getuid?.() === 0 && !args.some(arg => arg.startsWith('--no-sandbox'))) {
args.push('--no-sandbox', '--disable-setuid-sandbox');
}
Then rebuild (npm run build) so the generated build/src/browser.js picks up the same logic.wsxiaoys