← Back to all projects

playwright-mcp

Gives an agent a real browser it reads as text, not pixels — an MCP server for driving pages, not for crawling them.

MCP serverOfficialApache-2.0
Stars
38.9k
Forks
3.3k
Open issues
1
Last commit
30 Oct 2026

What is playwright-mcp?

Playwright MCP puts a real Chrome, Firefox, WebKit or Edge behind an MCP server and returns each page as an accessibility snapshot: a text outline of roles, names and reference ids that the agent clicks and types into, with no vision model and no coordinate guessing. Past plain navigation it can mock network requests, read and write cookies and web storage, record a trace or a video, and emit Playwright locators and assertions, which makes it a practical way to turn a session you drove by hand into a test you can check in. The cost is context: Microsoft's own README points coding agents at the Playwright CLI with skills instead, because the tool definitions and the snapshots compete for the same window as your codebase. It earns its keep in long-running loops, where holding one browser open across many turns is worth paying that.

What can you do with playwright-mcp?

  • The page arrives as an accessibility snapshot, not a screenshot — Each page comes back as an outline of roles, names and reference ids such as e5, and the agent acts by naming a ref rather than a coordinate. The documentation puts a snapshot at roughly 200-400 tokens against 3,000-5,000 for a screenshot read by a vision model.
  • A real browser you can watch, on Chrome, Firefox, WebKit or Edge — It starts with a visible window by default, so you can see what the agent is doing rather than infer it from a log. --device emulates a named handset such as an iPhone and --mobile a generic one; the README notes that mobile pages are usually lighter, which saves tokens.
  • Sign in once and keep the session — A browser profile is kept per client workspace, so logins survive between runs, and an isolated mode can instead load a saved storage state file. The Playwright browser extension, or a Chrome or Edge you have enabled remote debugging on, both let it work in tabs you already have open.
  • Only the core tools are on until you ask for more — The rest arrive as opt-in groups: network mocking, cookies and web storage, assertions and locator generation, PDF export, tracing and video recording, and coordinate-based mouse tools for canvas, maps and charts the accessibility tree cannot describe. The documentation argues a shorter tool list both costs fewer tokens and produces fewer invented tool calls.
  • Turn a session you drove by hand into a Playwright test — Verification tools check that an element, some text or a value is present, a locator generator turns a reference id into a role- or label-based locator you can paste into a test, and every action comes back with the matching Playwright line — TypeScript by default, or Python, Java or C#.
  • Drop into Playwright code when the tools run out — A core tool called browser_run_code_unsafe runs a snippet against the page object with the whole Playwright API available. The documentation reaches for it for iframes, for granting permissions such as geolocation or clipboard access, and for waiting on a condition no single tool covers.

Before you choose playwright-mcp

  • In 0.0.79 the always-on core tools include `browser_run_code_unsafe`, which the project's own docs call RCE-equivalent because it runs arbitrary JavaScript in the server process, and core cannot be disabled.
  • The allowed and blocked origin lists are documented as neither a security boundary nor applying to redirects, so they will not contain an agent turned loose on pages you do not trust.

Star history

17 Aug to 30 Oct · +2.7k

36.2k38.9k

Frequently asked questions

Is playwright-mcp free for commercial use?

playwright-mcp is released under the Apache-2.0 licence — OSI-approved open source, which permits commercial use.

How can playwright-mcp be deployed?

playwright-mcp is available as Runs locally / Self-hosted.

playwright-mcp
Ask AI
GitHub