Config tweaks for docker

- Remove `$` interpolation for env
- Allow puppeteer to work headless in docker, headful with npx
This commit is contained in:
colinmcneil 2024-12-18 11:00:11 -05:00 • committed by Jim Clark
commit c64f8de15f
No known key found for this signature in database
GPG key ID: 73305B2338AAA7BE
2 changed files with 72 additions and 59 deletions

View file

@ -72,7 +72,7 @@ Here's the Claude Desktop configuration to use the Puppeter server:
"mcpServers": {
"puppeteer": {
"command": "docker",
"args": ["run", "-i", "--rm", "--init", "ai/mcp-puppeteer"]
"args": ["run", "-i", "--rm", "--init", "-e", "DOCKER_CONTAINER=true", "ai/mcp-puppeteer"]
}
}
}

View file

@ -108,7 +108,9 @@ const screenshots = new Map<string, string>();
async function ensureBrowser() {
if (!browser) {
browser = await puppeteer.launch({ headless: true, args: ["--no-sandbox"] });
const npx_args = { headless: false }
const docker_args = { headless: true, args: ["--no-sandbox", "--single-process", "--no-zygote"] }
browser = await puppeteer.launch(process.env.DOCKER_CONTAINER ? docker_args : npx_args);
const pages = await browser.pages();
page = pages[0];