User Agents

Web browsers and everyday web tech, explained

Choosing a Browser with Playwright MCP

· 5 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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

  1. 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.
  2. 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.
  3. Install additional browsers (if needed). Run npx playwright install firefox or npx playwright install webkit to download Firefox or WebKit engines. For Chrome or Edge (which are Chromium-based but have proprietary features), install them via npx playwright install chrome or npx playwright install msedge.
  4. 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.json or the user settings. Check your client's documentation.
  5. Modify the MCP server configuration. In the config file, find the playwright server entry. Add or modify the args array to include a --browser flag. For example:
    "args": ["--browser", "firefox"] or "args": ["--browser", "chrome"].
  6. 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.
  7. 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.
  8. Verify browser version and features. If you need a specific browser version, use Playwright's --browser-version flag or configure the channel option in the MCP server settings. For example, to use Chrome stable, set "channel": "chrome".
  9. Consider headless vs. headed mode. By default, Playwright MCP runs headless. If you need to see the browser window (e.g., for debugging), add --headed to the args. Some browsers may behave differently in headless mode, so test both if needed.
  10. 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 env variables instead of args. Check the client's documentation; the flag might need to be passed as an environment variable like PLAYWRIGHT_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 channel option 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-deps regularly 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-dir argument. 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-deps to fix dependency issues.
  • Wrong browser opens. Re-check your config file for typos. Ensure the --browser flag is exactly firefox, webkit, chrome, msedge, or chromium (lowercase).
  • Browser opens but pages look broken. Some sites detect headless browsers and serve different content. Try adding --headed to 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.