@mario.andreschak/mcp-browser 3.45.1 → 3.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mario.andreschak/mcp-browser",
3
- "version": "3.45.1",
3
+ "version": "3.46.0",
4
4
  "description": "FLUJO's isolated Patchright browser MCP server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,6 +8,37 @@ import { pathToFileURL } from 'node:url';
8
8
  const MAX_DIAGNOSTIC_CHARS = 12_000;
9
9
  const TRUTHY = new Set(['1', 'true', 'yes', 'on']);
10
10
 
11
+ function browserCli() {
12
+ const require = createRequire(import.meta.url);
13
+ return join(dirname(require.resolve('patchright/package.json')), 'cli.js');
14
+ }
15
+
16
+ export function installBrowserDependencies({ spawn = spawnSync, env = process.env } = {}) {
17
+ const childEnv = { ...env };
18
+ delete childEnv.NODE_TLS_REJECT_UNAUTHORIZED;
19
+ // Inherit the terminal so Patchright can request sudo and stream apt output.
20
+ const child = spawn(process.execPath, [browserCli(), 'install-deps', 'chromium'], {
21
+ env: childEnv,
22
+ stdio: 'inherit',
23
+ });
24
+ if (child.error) throw child.error;
25
+ return Number.isInteger(child.status) ? child.status : 1;
26
+ }
27
+
28
+ export async function verifyBrowser({ loadChromium = async () => (await import('patchright')).chromium } = {}) {
29
+ const chromium = await loadChromium();
30
+ const browser = await chromium.launch({ headless: true, channel: 'chromium', timeout: 30_000 });
31
+ try {
32
+ const page = await browser.newPage();
33
+ await page.setContent('<title>FLUJO browser verification</title>', { timeout: 10_000 });
34
+ if (await page.title() !== 'FLUJO browser verification') {
35
+ throw new Error('Managed Chromium could not render the verification page.');
36
+ }
37
+ } finally {
38
+ await browser.close();
39
+ }
40
+ }
41
+
11
42
  export function sanitizeInstallOutput(input, env = process.env) {
12
43
  let safe = String(input ?? '');
13
44
  safe = safe.replace(/(https?:\/\/)[^/@\s]+@/gi, '$1[REDACTED]@');
@@ -55,7 +86,7 @@ export function classifyBrowserInstallFailure(output) {
55
86
  remediation: 'Check proxy reachability or increase FLUJO_PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT.',
56
87
  };
57
88
  }
58
- if (/host system is missing dependencies|missing librar|install-deps/.test(text)) {
89
+ if (/host system is missing dependencies|missing librar|error while loading shared libraries|install-deps/.test(text)) {
59
90
  return {
60
91
  category: 'OS_DEPENDENCY',
61
92
  remediation: 'Install the operating-system browser dependencies reported above, then retry.',
@@ -150,17 +181,32 @@ export function runBrowserInstall({
150
181
  '\n',
151
182
  );
152
183
  stderr.write(
153
- '[FLUJO installer] Retry from the FLUJO directory with: npm run install --workspace=@mario.andreschak/mcp-browser\n',
184
+ '[FLUJO installer] Retry from the FLUJO directory with: node mcp-servers/browser/scripts/install-browser.mjs\n',
154
185
  );
155
186
  writeResultFile(result, env);
156
187
  return result;
157
188
  }
158
189
 
159
- function main() {
160
- const result = runBrowserInstall();
161
- process.exitCode = result.exitCode;
190
+ async function main() {
191
+ try {
192
+ if (process.argv[2] === '--install-deps') {
193
+ process.exitCode = installBrowserDependencies();
194
+ } else if (process.argv[2] === '--verify') {
195
+ await verifyBrowser();
196
+ process.stderr.write('[FLUJO installer] Managed Chromium launch and rendering verified.\n');
197
+ } else {
198
+ const result = runBrowserInstall();
199
+ process.exitCode = result.exitCode;
200
+ }
201
+ } catch (error) {
202
+ process.stderr.write(sanitizeInstallOutput(error?.message) + '\n');
203
+ if (process.platform === 'linux') {
204
+ process.stderr.write('[FLUJO installer] Check the system browser dependencies. On Ubuntu/Debian, retry as root (using sudo when needed): node mcp-servers/browser/scripts/install-browser.mjs --install-deps\n');
205
+ }
206
+ process.exitCode = 1;
207
+ }
162
208
  }
163
209
 
164
210
  if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) {
165
- main();
211
+ await main();
166
212
  }