Recommended Free Tools
Playwright CLI does not directly consume MCP tools. To control a browser through MCP, add the Playwright MCP server to an MCP client such as Claude Code or VS Code. To use the CLI with a browser that is already running, use playwright-cli attach with a supported browser or server target. These are related but distinct setups, and choosing the right one avoids trying to connect interfaces that serve different roles.
CLI or MCP: choose the interface you need
Playwright CLI is a shell-command interface for browser automation. Playwright MCP is a server that an MCP client launches or connects to; the client then calls its structured browser tools. The official documentation describes these as different interaction models, not as a direct CLI-to-MCP connection. See the Playwright CLI introduction and Playwright MCP setup.
| Need | Use | What connects to what |
|---|---|---|
| Have an MCP-enabled coding assistant call browser tools | Playwright MCP | The MCP client launches the server over stdio, or connects to a separately hosted MCP endpoint. |
| Issue browser commands through a terminal-oriented agent workflow | Playwright CLI | The CLI is invoked as shell commands. |
| Use the CLI with a browser or Playwright server that already exists | Playwright CLI attach |
The CLI attaches to a supported browser, CDP endpoint, Playwright server endpoint, or browser extension. |
If your actual requirement is “let my MCP client automate a browser,” configure Playwright MCP in that client. If your requirement is “let the CLI control this existing browser,” use attach. Do not treat attaching the CLI to a browser as equivalent to adding an MCP server.
Prerequisites for Playwright MCP
- Node.js 20 or newer, as listed in the Playwright MCP getting-started documentation.
- An MCP client that supports server configuration. The configuration location and format vary by client.
- Network access to download and run the npm package the first time it is invoked.
The configuration below uses @latest, which tracks the latest package rather than pinning a version. For repeatable deployments, review the current package and client documentation before choosing a versioning approach. The examples here reflect the documented setup at the time of writing; package behavior and client configuration can change.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minute#1 Best Overall
Configure Playwright MCP in an MCP client
The standard configuration declares a server named playwright and tells the MCP client to run it with npx:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}
- Open your MCP client’s server configuration UI or configuration file.
- Add the
playwrightserver entry in the format expected by that client. Do not assume all clients use the same settings file. - Save the configuration and restart or reload the client if it does not automatically discover the server.
- In the client, select or invoke the Playwright tools it exposes, then provide a concrete browser task. The server exposes browser automation through structured accessibility snapshots.
For client-specific alternatives, the official setup documentation shows adding the server in VS Code with code --add-mcp and a JSON payload, and adding it in Claude Code with:
claude mcp add playwright npx @playwright/mcp@latest
Use the exact configuration instructions for your MCP client if it differs from these examples. The server command is common; the method of registering it is not universal.
Run Playwright MCP as a separate HTTP server
A separate HTTP process can be useful when the server runs on a host without a display or when an IDE worker needs to connect to it. Start the server with the documented port option:
Rank #2
npx @playwright/mcp@latest --port 8931
Then configure an MCP client that supports a remote server URL:
{
"mcpServers": {
"playwright": {
"url": "http://localhost:8931/mcp"
}
}
}
The address above is local to the machine running the client. If the server is on another host, use a reachable endpoint and apply that environment’s access controls; the cited Playwright setup page does not specify provider authentication requirements. The documentation says HTTP sessions use a five-second heartbeat timeout and identifies PLAYWRIGHT_MCP_PING_TIMEOUT_MS as the setting to lengthen or disable it. These are version-sensitive details, so check the current Playwright MCP getting-started page when adjusting long-running sessions.
Use Playwright CLI with an existing browser or server
The CLI is installed separately from the MCP server. The documented global installation is:
npm install -g @playwright/cli@latest
Alternatively, install it in a project and invoke it with npx, following the current CLI installation instructions. To connect the CLI to an existing target, use playwright-cli attach. The command accepts exactly one target selection, as described in the attach command reference.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- Playwright browser by name: attach to a bound browser using its name.
- CDP channel or URL: connect to a running browser exposed through the Chrome DevTools Protocol. The documented example is
playwright-cli attach --cdp=http://localhost:9222. - Playwright server endpoint: for example,
playwright-cli attach --endpoint=ws://localhost:3000. - Browser extension: attach through the supported extension workflow when the target is an existing browser session.
Cloud browser services that expose CDP can also be used as CDP targets; the attach documentation names Browserbase as an example. The exact endpoint and any authentication requirements are provider-specific and are not established by the Playwright CLI documentation.
For command syntax and supported target forms, use the current Playwright CLI attach reference. The CLI’s job here is to attach to a browser or Playwright server, not to register itself as an MCP client.
Choose browser mode, profile, and runtime
After deciding between CLI and MCP, choose how the browser should run. Playwright MCP documentation describes the following options; their availability and exact flags can change, so consult the MCP configuration options for current details.
Headed or headless
Headed mode is documented as the default. Use --headless when the browser should run without a visible window, such as on a server without a desktop session. A visible browser can be useful when you need to observe interaction or diagnose a page, while headless mode avoids requiring a displayed window.
Browser engine
The MCP documentation describes browser selection for Chrome, Firefox, WebKit, and Microsoft Edge. Select the browser that matches the compatibility target you need; do not assume that a test in one engine establishes identical behavior in another.
Profile and session state
- Persistent profile: retains login state and cookies, which can help with workflows that depend on an authenticated session.
- Isolated profile: starts fresh, useful when each task should avoid inherited cookies or prior browser state.
- Extension profile: connects to existing tabs, when the task needs to work with a browser already open to a page or session.
Persistent and extension sessions can expose account data and authenticated pages to the automation workflow. Use them only when the MCP client and task are trusted with that session.
Troubleshoot setup and connection failures
The MCP client does not show Playwright tools
- Check that the server entry is in the configuration location and format required by that specific client.
- Confirm Node.js 20 or newer is available to the process that launches
npx. - Reload or restart the client after changing configuration, then inspect its MCP connection status or logs if available.
- Verify the package command and JSON syntax. A missing comma or a misspelled property can prevent the client from loading the server.
The HTTP client cannot connect
- Confirm the server process is running with
--port 8931and that the client URL ends in/mcp. - Check that
localhostrefers to the same host from the client’s perspective. In a container, remote worker, or IDE service, it may refer to that environment rather than your desktop. - If the connection drops during a long session, check the documented heartbeat behavior and
PLAYWRIGHT_MCP_PING_TIMEOUT_MSsetting.
The CLI attach command rejects the target
- Supply one attach target, not multiple target options in the same command.
- For CDP, ensure the browser is actually exposing a reachable CDP address and use the correct URL or channel.
- For a Playwright server, use its websocket endpoint, not the MCP HTTP URL. The attach example uses a
ws://endpoint. - For cloud browsers, check the provider’s current endpoint and authentication instructions; Playwright’s attach reference does not define those provider-specific values.
The browser opens in the wrong mode or profile
Review the MCP browser and profile options in the current configuration reference. Check whether the task requires a fresh isolated session, a persistent profile, a visible window, or existing tabs, then configure that mode explicitly rather than relying on defaults.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Reliability, performance, and cost considerations
The official pages describe setup and operating modes, but do not provide a comparative benchmark showing that CLI or MCP is universally faster or more reliable. The practical choice is the interface your agent can use and the browser session model the task requires. A client-launched stdio server avoids separately managing an HTTP process; a separately hosted server gives the client an endpoint to connect to, but adds endpoint reachability and session-lifetime considerations.
The cited setup documents do not establish a Playwright MCP service price or per-operation charge. Your operational costs depend on the machines and browser infrastructure you run, plus any third-party cloud browser service you choose. For reliability, make the runtime arrangement explicit, keep the endpoint and profile configuration consistent, and verify current package and client behavior before relying on a long-running automation workflow.
Or skip the browser setup
If your goal is to capture page images or PDFs rather than interactively automate a browser, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. For example, use cURL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
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)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the ScreenshotNeo API documentation for setup and options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for free and try ScreenshotNeo.
Frequently Asked Questions
Does Playwright CLI itself connect to an MCP server?
The reviewed Playwright documentation describes the CLI and MCP as separate interfaces; it does not document the CLI as an MCP client.
Can I use Playwright MCP without a visible browser window?
Yes. Playwright MCP documentation describes headed mode as the default and provides a headless option.
Quick Recap
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.

