browser_install
Install required browsers for Playwright automation when encountering installation errors, enabling web interaction through structured accessibility snapshots.
Instructions
Install the browser specified in the config. Call this if you get an error about the browser not being installed.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/install.ts:35-58 (handler)The main handler function that forks the Playwright CLI to install the specified browser channel.handle: async context => { const channel = context.config.browser?.launchOptions?.channel ?? context.config.browser?.browserName ?? 'chrome'; const cliUrl = import.meta.resolve('playwright/package.json'); const cliPath = path.join(fileURLToPath(cliUrl), '..', 'cli.js'); const child = fork(cliPath, ['install', channel], { stdio: 'pipe', }); const output: string[] = []; child.stdout?.on('data', data => output.push(data.toString())); child.stderr?.on('data', data => output.push(data.toString())); await new Promise<void>((resolve, reject) => { child.on('close', code => { if (code === 0) resolve(); else reject(new Error(`Failed to install browser: ${output.join('')}`)); }); }); return { code: [`// Browser ${channel} installed`], captureSnapshot: false, waitForNetwork: false, }; },
- src/tools/install.ts:27-33 (schema)The schema definition for the browser_install tool, including name, title, description, input schema, and type.schema: { name: 'browser_install', title: 'Install the browser specified in the config', description: 'Install the browser specified in the config. Call this if you get an error about the browser not being installed.', inputSchema: z.object({}), type: 'destructive', },
- src/tools/install.ts:61-63 (registration)The registration of the install tool by exporting it as default array.export default [ install, ];