How to setup Playwright MCP to control browsers

This guide shows you how to set up Playwright MCP to control Chrome and Firefox browsers through the Model Context Protocol. You'll install Playwright, connect the MCP Inspector, and run automation commands to open tabs and navigate websites.

What is Playwright MCP?

Playwright MCP is a Model Context Protocol server that provides programmatic access to Playwright's browser automation capabilities. It is a powerful framework developed by Microsoft that enables reliable end-to-end testing and automation for web applications across Chromium, Firefox, and WebKit browsers.

Steps to follow

Playwright Documentation: https://playwright.dev/docs/intro

  1. Open terminal
  2. Install Playwright
  3. Run MCP Inspector with Chrome
  4. Connect to Playwright MCP server
  5. List available tools
  6. Test Chrome tools

Quick reference commands

Install Playwright:

npx playwright install

Run MCP Inspector with Playwright for Chrome

npx -y @modelcontextprotocol/inspector npx -y @playwright/mcp@latest --browser chrome

Read more about the MCP inspector at: Model Context Protocol (MCP) Inspector

Playwright installation video

The following video shows how to install Playwright browsers on your system. Playwright requires browser binaries to be downloaded before it can automate them.

Step 1 - Open terminal

Open a terminal window by searching for "Terminal" in the start menu and clicking on the application. The terminal provides a command-line interface where you'll install Playwright and run the MCP Inspector (Figure 1).

Open terminal
Figure 1 - Open terminal window

Step 2 - Install Playwright

In the terminal, execute the command npx playwright install to download and install all browser binaries. This command installs Chromium, Firefox, and WebKit browsers that Playwright can automate (Figure 2).

npx playwright install

You need Node.js and NPM installed on your system to run this command. If you don't have Node.js installed, download it from nodejs.org before proceeding.

Run Playwright installer command
Figure 2 - Execute Playwright installation command

When prompted, confirm that you want to proceed with the package installation by typing "y" or pressing Enter to accept (Figure 3).

Agree to package installation
Figure 3 - Confirm package installation

Wait for the installation to complete. Playwright will download browser binaries for Chromium, Firefox, and WebKit (Figure 4).

Wait for installation to finish
Figure 4 - Wait for Playwright installation to complete

Step 3 - Run MCP Inspector with Chrome

The following video shows how to control Chrome browser using Playwright MCP step-by-step. The video covers launching the MCP Inspector with Playwright configured for Chrome, connecting to the server, and executing browser control commands.

Open a terminal window if you don't already have one open (Figure 5).

Open terminal
Figure 5 - Open terminal window

Execute the command npx -y @modelcontextprotocol/inspector npx -y @playwright/mcp@latest --browser chrome to launch the MCP Inspector with Playwright MCP server configured for Chrome (Figure 6).

npx -y @modelcontextprotocol/inspector npx -y @playwright/mcp@latest --browser chrome

Run MCP Inspector with Playwright
Figure 6 - Execute MCP Inspector with Playwright for Chrome

Wait for the MCP Inspector to download dependencies and initialize. Once ready, it will automatically open in your default web browser showing the connection interface (Figure 7).

Wait for MCP Inspector to start
Figure 7 - Wait for MCP Inspector to start

Step 4 - Connect to Playwright MCP server

In the Inspector interface, the connection settings should be pre-configured for the Playwright MCP server. The transport type should be set to stdio. Click the Connect button to establish the connection to the Playwright automation server (Figure 8).

Connect to Playwright MCP server
Figure 8 - Connect to Playwright MCP server

Step 5 - List available tools

Once the connection is successful, click the List Tools button to display all available browser automation tools provided by the Playwright MCP server (Figure 9).

List available tools
Figure 9 - List available Playwright tools

Step 6 - Test Chrome tools

Locate and select the browser_tabs tool from the available tools list. Execute this tool to open a new Chrome browser window (Figure 10).

Use browser tabs tool
Figure 10 - Execute browser_tabs tool to open Chrome

Select the browser_navigate tool and enter a target URL such as https://ozeki.hu in the parameter field. Click the Run Tool button to execute the navigation command (Figure 11).

Run browser navigate tool
Figure 11 - Execute browser_navigate tool

Switch to the Chrome browser window to verify the result. The browser has successfully navigated to the specified website, confirming that Playwright MCP can control Chrome browser (Figure 12).

Website opened in Chrome
Figure 12 - Website opened in Chrome

  1. Open terminal
  2. Install Playwright
  3. Run MCP Inspector with Firefox
  4. Connect to Playwright MCP server
  5. List available tools
  6. Test Firefox tools

Quick reference commands

Install Playwright:

npx playwright install

Run MCP Inspector with Playwright for Firefox

npx -y @modelcontextprotocol/inspector npx -y @playwright/mcp@latest --browser firefox

Read more about the MCP inspector at: Model Context Protocol (MCP) Inspector

Playwright installation video

The following video shows how to install Playwright browsers on your system. Playwright requires browser binaries to be downloaded before it can automate them.

Step 1 - Open terminal

Open a terminal window by searching for "Terminal" in the start menu and clicking on the application. The terminal provides a command-line interface where you'll install Playwright and run the MCP Inspector (Figure 1).

Open terminal
Figure 1 - Open terminal window

Step 2 - Install Playwright

In the terminal, execute the command npx playwright install to download and install all browser binaries. This command installs Chromium, Firefox, and WebKit browsers that Playwright can automate (Figure 2).

npx playwright install

You need Node.js and NPM installed on your system to run this command. If you don't have Node.js installed, download it from nodejs.org before proceeding.

Run Playwright installer command
Figure 2 - Execute Playwright installation command

When prompted, confirm that you want to proceed with the package installation by typing "y" or pressing Enter to accept (Figure 3).

Agree to package installation
Figure 3 - Confirm package installation

Wait for the installation to complete. Playwright will download browser binaries for Chromium, Firefox, and WebKit (Figure 4).

Wait for installation to finish
Figure 4 - Wait for Playwright installation to complete

Step 3 - Run MCP Inspector with Firefox

The following video shows how to control Firefox browser using Playwright MCP step-by-step. The video covers launching the MCP Inspector with Playwright configured for Firefox, connecting to the server, and executing browser control commands.

Open a terminal window if you don't already have one open (Figure 13).

Open terminal
Figure 5 - Open terminal window

Execute the command npx -y @modelcontextprotocol/inspector npx -y @playwright/mcp@latest --browser firefox to launch the MCP Inspector with Playwright MCP server configured for Firefox automation (Figure 14).

npx -y @modelcontextprotocol/inspector npx -y @playwright/mcp@latest --browser firefox

Run MCP Inspector with Playwright
Figure 6 - Run MCP Inspector with Playwright for Firefox

Wait for the MCP Inspector to initialize. Once ready, it will automatically open in your default web browser showing the connection interface (Figure 15).

Wait for MCP Inspector to start
Figure 7 - Wait for MCP Inspector to start

Step 4 - Connect to Playwright MCP server

In the Inspector interface, the connection settings should be pre-configured for the Playwright MCP server. Click the Connect button to establish the connection (Figure 16).

Connect to Playwright MCP server
Figure 8 - Connect to Playwright MCP server

Step 5 - List available tools

Once connected successfully, click the List Tools button to display all available browser automation tools (Figure 17).

List available tools
Figure 9 - List available Playwright tools

Step 6 - Test Firefox tools

Locate and select the browser_tabs tool from the available tools list. Execute this tool to open a new Firefox browser window (Figure 18).

Use browser tabs tool
Figure 10 - Use browser_tabs tool to open Firefox

Select the browser_navigate tool and enter a target URL in the parameter field. Click the Run Tool button to execute the navigation command (Figure 19).

Run browser navigate tool
Figure 11 - Execute browser_navigate tool

Switch to the Firefox browser window to verify the result. The browser has successfully navigated to the specified website, confirming that Playwright MCP can control Firefox browser (Figure 20).

Website opened in Firefox
Figure 12 - Website opened in Firefox

Final thoughts

You have successfully set up Playwright MCP and tested it with both Chrome and Firefox. You can now use MCP commands to control these browsers for testing, web scraping, or building AI tools that need browser automation.

More information