Skip to main content
Glama
Leviathangk

Playwright MCP Server

by Leviathangk
install-browser.ts1.69 kB
import { exec } from 'child_process'; import { promisify } from 'util'; import { ErrorResponse } from '../errors.js'; const execAsync = promisify(exec); export interface InstallBrowserArgs { browser?: 'chromium' | 'firefox' | 'webkit' | 'all'; withDeps?: boolean; } export async function handleInstallBrowser(args: any): Promise<any> { const { browser = 'chromium', withDeps = false } = args as InstallBrowserArgs; try { console.error(`Installing Playwright ${browser}...`); let command = 'npx playwright install'; if (browser !== 'all') { command += ` ${browser}`; } if (withDeps) { command += ' --with-deps'; } const { stdout, stderr } = await execAsync(command, { maxBuffer: 10 * 1024 * 1024, // 10MB buffer }); const output = stdout + stderr; console.error('Installation output:', output); return { content: [ { type: 'text', text: JSON.stringify({ success: true, browser, withDeps, message: `Successfully installed ${browser}`, output: output.substring(0, 1000), // Limit output length }), }, ], }; } catch (error: any) { console.error('Installation failed:', error); return { content: [ { type: 'text', text: JSON.stringify({ errorCode: 'INSTALL_FAILED', message: error.message || 'Failed to install browser', stderr: error.stderr?.substring(0, 1000), stdout: error.stdout?.substring(0, 1000), } as ErrorResponse), }, ], isError: true, }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Leviathangk/PlaywrightMCPForCrawler'

If you have feedback or need assistance with the MCP directory API, please join our Discord server