default 'chrome' channel requires system Google Chrome, missing on slim Linux hosts; use the postinstall-downloaded Chromium build instead
35 lines
1.7 KiB
JavaScript
35 lines
1.7 KiB
JavaScript
// Skald connector entry point.
|
|
//
|
|
// The MCP server itself is the upstream `@playwright/mcp` package, pinned in
|
|
// package.json and installed by Skald beside this file (`npm ci --omit=dev`,
|
|
// falling back to `npm install --omit=dev`).
|
|
//
|
|
// This file exists because Skald launches a `mcp_local` connector as
|
|
// `<command> <mcp_config.args[0]>`, where args[0] is rewritten to the absolute
|
|
// path of a *shipped* file — so `npx @playwright/mcp` cannot be expressed:
|
|
// args[0] would be taken as the entry file's name.
|
|
//
|
|
// The wrapper rewrites argv with the flags the server needs in a display-less
|
|
// container (headless, isolated in-memory profile, no sandbox) and then
|
|
// imports the package's CLI module, which self-executes at import time.
|
|
// cli.js is not listed in the package's "exports" map, so it is resolved
|
|
// from the exported package.json path instead of a package subpath import.
|
|
import { createRequire } from "node:module";
|
|
import { dirname, join } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const packageDir = dirname(require.resolve("@playwright/mcp/package.json"));
|
|
|
|
process.argv = [
|
|
process.argv[0],
|
|
"playwright-mcp",
|
|
"--browser", "chromium", // default is the "chrome" channel (system Google Chrome), which is not installed on slim hosts; use the Chromium build downloaded by the postinstall hook
|
|
"--headless", // no display in the container/host session
|
|
"--isolated", // in-memory profile: no shared cookies/login state on disk
|
|
"--no-sandbox", // Chromium sandbox cannot run inside containers
|
|
...process.argv.slice(2), // passthrough for any extra args
|
|
];
|
|
|
|
await import(pathToFileURL(join(packageDir, "cli.js")));
|