browser_install
Install the required browser when encountering a 'browser not installed' error in Playwright MCP for web automation tasks.
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 handler function executes the browser installation by forking the Playwright CLI 'install' command for the browser channel specified in the config (defaults to 'chrome'). It captures output and returns a success message.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 defines the tool name 'browser_install', its title, description, an empty input schema (no parameters), and marks it as 'destructive'.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 tool is assigned to const install via defineTool and exported as a default array, allowing it to be imported and spread into central tools lists (e.g., snapshotTools and visionTools in src/tools.ts).export default [ install, ];
- src/tools.ts:21-21 (registration)Imports the install tool module containing 'browser_install'.import install from './tools/install.js';
- src/tools.ts:35-50 (registration)Spreads the install tools (including 'browser_install') into the snapshotTools array for registration.export const snapshotTools: Tool<any>[] = [ ...common(true), ...console, ...dialogs(true), ...files(true), ...install, ...keyboard(true), ...navigate(true), ...network, ...pdf, ...screenshot, ...snapshot, ...tabs(true), ...testing, ...wait(true), ];