Choosing a Browser with Playwright MCP
In this article
Playwright MCP (Model Context Protocol) lets an AI assistant control a real browser through Playwright, but you must first choose which browser to use. This guide walks you through selecting the right browser for your automation tasks, covering installation, configuration, and practical tips.
What You'll Need
- A Node.js environment (version 18 or later) with npm installed.
- Playwright installed in your project (
npm install playwright). - Access to the MCP server configuration (e.g., in Claude Desktop, VS Code, or a custom MCP client).
- Basic familiarity with JSON configuration files.
Step-by-Step
- Understand your automation needs. Ask yourself: Are you testing a modern web app with heavy JavaScript? Do you need to emulate a specific browser engine? Are you working with legacy sites that only support older browser versions? Your answers will guide the browser choice.
- Know the default browser. Playwright MCP defaults to Chromium. If you have no special requirements, Chromium is a safe, fast choice with excellent DevTools support and broad compatibility.
- Install additional browsers (if needed). Run
npx playwright install firefoxornpx playwright install webkitto download Firefox or WebKit engines. For Chrome or Edge (which are Chromium-based but have proprietary features), install them vianpx playwright install chromeornpx playwright install msedge. - Locate your MCP configuration file. This depends on your client. For Claude Desktop, it's usually
claude_desktop_config.json. For VS Code, it's in.vscode/mcp.jsonor the user settings. Check your client's documentation. - Modify the MCP server configuration. In the config file, find the
playwrightserver entry. Add or modify theargsarray to include a--browserflag. For example:"args": ["--browser", "firefox"]or"args": ["--browser", "chrome"]. - Restart your MCP client. After changing the config, fully restart the client (e.g., quit and reopen Claude Desktop or reload the VS Code window). The new browser setting takes effect only after a clean restart.
- Test the browser selection. Send a simple prompt like "Open example.com and tell me the page title" to your AI assistant. It should launch the chosen browser. If it fails, check the client's logs for errors.
- Verify browser version and features. If you need a specific browser version, use Playwright's
--browser-versionflag or configure thechanneloption in the MCP server settings. For example, to use Chrome stable, set"channel": "chrome". - Consider headless vs. headed mode. By default, Playwright MCP runs headless. If you need to see the browser window (e.g., for debugging), add
--headedto the args. Some browsers may behave differently in headless mode, so test both if needed. - Document your choice. Note the browser and version in your project's README so other team members know what to expect.
Common Mistakes
- Not installing the browser before configuring. If you set the browser to Firefox but haven't run
npx playwright install firefox, the MCP server will fail to launch with an error. - Using the wrong config key. Some MCP clients use
envvariables instead ofargs. Check the client's documentation; the flag might need to be passed as an environment variable likePLAYWRIGHT_BROWSER=firefox. - Forgetting to restart the client. Changes to the MCP config are not hot-reloaded. Always restart the client completely.
- Assuming all browsers are identical. WebKit (Safari's engine) has different rendering and permissions behavior. Test your automation thoroughly on the chosen browser, especially if it involves media or file downloads.
Tips
- Use Chromium for general automation. It's the most stable and widely used. Use Firefox for testing Mozilla-specific features, and WebKit for Safari compatibility checks.
- Leverage the
channeloption for branded browsers. If you need Chrome or Edge, using the channel is more reliable than downloading the Chromium build. - Keep browsers updated. Run
npx playwright install --with-depsregularly to ensure system dependencies and browser versions are current. - Use a separate profile for MCP. If you need persistent login states, configure a user data directory via the MCP server's
--user-data-dirargument. This avoids conflicts with your personal browser profile.
Troubleshooting
- Browser doesn't launch. Check the MCP server logs for errors. Common causes: missing browser installation, incorrect flag syntax, or missing system dependencies. Run
npx playwright install --with-depsto fix dependency issues. - Wrong browser opens. Re-check your config file for typos. Ensure the
--browserflag is exactlyfirefox,webkit,chrome,msedge, orchromium(lowercase). - Browser opens but pages look broken. Some sites detect headless browsers and serve different content. Try adding
--headedto see if the issue persists. If it's a site-specific issue, you may need to use a real browser profile or user agent. - MCP client ignores the config. Some clients cache the config. Try clearing the cache or using a different config file location. Also ensure the JSON is valid (no trailing commas).
Frequently Asked Questions
Can I use Safari with Playwright MCP?
No, Playwright does not support Safari directly. Use WebKit, which is the same engine that powers Safari, but it's a separate binary.
What's the difference between Chromium and Chrome in Playwright?
Chromium is the open-source browser that Chrome is based on. Chrome includes proprietary codecs and features like Widevine DRM. Playwright can launch either, but Chrome must be installed separately.
How do I switch browsers without editing config each time?
You can define multiple MCP server entries in your client, each with a different browser, and switch between them by choosing the server in the client's UI.
Does the browser choice affect performance?
Yes, Chromium generally has the fastest startup and execution times. WebKit and Firefox may be slower for some operations, but the difference is usually negligible for small tasks.
Can I run tests in multiple browsers simultaneously?
Yes, but not through MCP's single browser instance. You would need to run multiple MCP server instances, each configured with a different browser, and coordinate them in your automation script.
What if I need a specific browser version?
Use the --browser-version flag in the MCP args or specify a version in Playwright's config. However, Playwright only supports a limited set of versions; check the Playwright documentation for supported versions.