Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To connect an MCP client to Playwright’s standalone HTTP server, start the server on a port and put its /mcp URL in the client’s server entry. The documented local setup is:

npx @playwright/mcp@latest --port 8931
{
  "mcpServers": {
    "playwright": {
      "url": "http://localhost:8931/mcp"
    }
  }
}

The value in url is the MCP transport address. It is not the address of a browser, Playwright server, or Chrome DevTools Protocol (CDP) socket. Those are separate options passed to the Playwright MCP process.

What the remote MCP URL does

Playwright MCP exposes browser automation through the Model Context Protocol (MCP), allowing an AI client to operate pages through structured accessibility snapshots. The MCP client sends tool calls to the HTTP endpoint; Playwright MCP then launches or connects to a browser and performs the actions.

In the normal standalone arrangement, three pieces are involved:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • MCP client: Claude, Cursor, or another MCP-compatible application.
  • Playwright MCP server: the process started with npx @playwright/mcp@latest.
  • Browser: launched by Playwright MCP unless you explicitly attach it to another browser service.

The client’s url must point to the MCP HTTP route, normally ending in /mcp. It should not point directly to a browser WebSocket or CDP port.

Prerequisites

  • Node.js 20 or newer.
  • An MCP client that supports an HTTP server URL entry.
  • Network reachability between the client and the machine running Playwright MCP.

Playwright’s getting-started documentation lists Node.js 20+ and an MCP client as prerequisites: Playwright MCP getting started guide.

Start Playwright MCP in HTTP mode

Run the standalone server

Open a terminal on the host that will run browser automation:

npx @playwright/mcp@latest --port 8931

This starts the HTTP service on port 8931. Keep the process running while your MCP client uses it. The documented example uses port 8931; you may choose another unused port, but the client URL must use the same one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Bind for a container or another machine

The local example binds to a loopback interface, so localhost works only when the MCP client and server share that network namespace. It does not automatically mean “the computer running the client” when the server is in another machine, VM, container, or remote host.

For container scenarios, Playwright documents:

npx @playwright/mcp@latest --host 0.0.0.0 --port 8931

Use a client-reachable hostname or IP in the MCP configuration, such as http://automation-host:8931/mcp. The correct address depends on your routing, DNS, port publishing, firewall, and proxy setup; there is no single universal public-hosting configuration in the Playwright documentation. Exposing an automation service beyond a trusted network also requires you to apply your own authentication and transport-security controls.

Configure the MCP client’s server entry

HTTP URL configuration

In the client’s MCP configuration file, add a server named playwright with a url property:

{
  "mcpServers": {
    "playwright": {
      "url": "http://localhost:8931/mcp"
    }
  }
}

Replace localhost with the hostname or IP that the client can actually reach. Replace 8931 if you selected another port. Do not remove /mcp; it identifies the MCP HTTP route in the documented setup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Command-and-arguments entries versus URL entries

Many clients also support a configuration that starts a local process themselves, for example a server command with arguments. That is a different transport arrangement from the standalone HTTP example. Use a url entry when Playwright MCP is already running as a separate service. Use a command entry when the client is responsible for launching the process. Follow your client’s current configuration schema for the exact file location and reload procedure.

Do not confuse MCP, Playwright, and CDP endpoints

Setting Where it goes Typical value What it connects
MCP HTTP URL Client’s mcpServers entry http://localhost:8931/mcp The MCP protocol service
--endpoint Playwright MCP command line ws://localhost:3000/ A browser exposed by a Playwright server
--cdp-endpoint Playwright MCP command line http://localhost:9222 A Chromium instance exposing Chrome DevTools Protocol

Playwright’s browser-connection guide shows the --endpoint and --cdp-endpoint forms: Connecting to Browsers. For example, to have MCP attach to an existing Playwright server:

npx @playwright/mcp@latest --port 8931 --endpoint ws://localhost:3000/

To attach to Chromium’s CDP service instead:

npx @playwright/mcp@latest --port 8931 --cdp-endpoint http://localhost:9222

The client still connects to http://localhost:8931/mcp. The browser endpoint changes what the MCP server uses behind that HTTP interface; it does not replace the client’s MCP URL.

Configuration precedence

Playwright MCP accepts settings from configuration files, environment variables, and command-line arguments. They are applied in increasing order of precedence: file settings first, environment variables next, and command-line arguments last. If the same option is supplied more than once, the CLI value wins.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

This matters when a container image or shared configuration supplies a default host or port. Inspect the final command line and environment if the service appears to listen somewhere unexpected. The option reference documents the precedence rules and host setting: Playwright MCP configuration.

Test the connection with a real task

  1. Start the server and confirm that the terminal remains running.
  2. Reload or restart the MCP client so it reads the updated server entry.
  3. Ask the client to navigate to https://demo.playwright.dev/todomvc and add a few todo items.
  4. Watch the server log for an incoming session and tool calls.
  5. Verify that the page state changed in the browser controlled by that MCP process.

The task wording comes from Playwright’s official example. Playwright MCP generally represents pages with accessibility snapshots rather than requiring the model to interpret raw pixels; see Playwright MCP introduction.

Remote-topology examples

Client and server on one machine

Start on port 8931 and use http://localhost:8931/mcp. This is the simplest documented case because both processes share the host network namespace.

Client on the host, server in a container

Start the container process with --host 0.0.0.0 --port 8931, publish the container port to the host, and configure the client with the host-side address and published port. For example, if the published port is 8931, the client may use http://localhost:8931/mcp; if it is published as 18931, use http://localhost:18931/mcp.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Client and server on different machines

Bind the server to an interface reachable from the client and use the server’s resolvable hostname or IP. A URL containing localhost would point back to the client machine, not the remote server. The exact routing and access controls are deployment-specific.

Heartbeat behavior and long-lived sessions

HTTP sessions use a documented five-second heartbeat timeout. If a client, reverse proxy, or network path does not answer server-initiated pings quickly enough, increase PLAYWRIGHT_MCP_PING_TIMEOUT_MS. Set it to 0 to disable the heartbeat, according to the getting-started documentation.

Set the environment variable before launching the server, for example:

PLAYWRIGHT_MCP_PING_TIMEOUT_MS=15000 npx @playwright/mcp@latest --port 8931

Choose a value appropriate for your proxy and network rather than disabling the check automatically. A disabled heartbeat can leave dead sessions around longer.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting

“Connection refused” or timeout

  • Confirm the Playwright MCP process is still running.
  • Check that the client URL uses the same port passed to --port.
  • Replace localhost with the server hostname when the client is on another machine or container.
  • If containerized, verify --host 0.0.0.0, port publishing, and network policy.

404 or “not an MCP endpoint”

Check the path. The documented URL is http://localhost:8931/mcp, not only http://localhost:8931. Also ensure a reverse proxy preserves the /mcp path.

The client starts a second server

You may have both a command-based entry and a URL entry. Remove the unused entry or give each server a distinct name. A URL entry assumes the standalone process is already running; it does not launch one.

The browser connection fails

Inspect --endpoint and --cdp-endpoint. Use --endpoint only for a Playwright server and --cdp-endpoint for Chromium’s CDP service. These values belong on the Playwright MCP command, not in the client’s url field.

Sessions drop after idle periods

Check the five-second heartbeat behavior and any proxy idle timeout. Increase PLAYWRIGHT_MCP_PING_TIMEOUT_MS or set it to 0 when the documented heartbeat is incompatible with your environment.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a rendered image or PDF rather than interactive MCP control, ScreenshotNeo provides a direct screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF, without configuring Playwright locally.

For example, using the documented API pattern (see ScreenshotNeo documentation):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture.
  • Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers identify the page verdict and billing result.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI clients.
  • The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots.

Create a free ScreenshotNeo account to try it without a card.

Frequently Asked Questions

Can I put a WebSocket browser URL in the MCP client’s url field?

No. The client field is for the MCP HTTP URL, such as http://localhost:8931/mcp. A Playwright WebSocket or CDP address belongs in the MCP server’s –endpoint or –cdp-endpoint option.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does localhost refer to the machine running Playwright MCP?

Only from the perspective of the process making the connection. If the client runs elsewhere, localhost points to the client’s own network namespace, so use a reachable server hostname or IP instead.

What does Playwright MCP automate?

It gives an MCP client browser tools and represents page structure through accessibility snapshots, allowing navigation and interactions without requiring raw screenshot interpretation.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.