# Playwright MCP (MCP Server)

> Browser automation for agents via Playwright accessibility snapshots

- Type: MCP server
- Publisher: Microsoft (official)
- Categories: Development
- Website: https://github.com/microsoft/playwright-mcp
- Source: https://github.com/microsoft/playwright-mcp
- Transport: stdio
- Launch command: npx @playwright/mcp@latest
- Sign-in: none
- GitHub stars: 37739
- Listed: 2025-03-21

## Overview

Playwright MCP gives a coding agent a real browser to work in. The agent reads each page as an accessibility tree rather than a screenshot, so it finds a button by its label and fills a form without a vision model. That makes it good for checking a feature you just built on localhost, reproducing a bug report step by step, collecting console errors from staging, or turning a manual walkthrough into a draft Playwright test.

Because it runs on your own machine, it fits Codex and other local agents far better than ChatGPT on the web.

## From the publisher

Microsoft's Playwright MCP server lets agents drive a real browser using structured accessibility snapshots instead of screenshots. It supports navigation, clicking, typing, form filling, tabs, network inspection and screenshots across Chromium, Firefox and WebKit.

## What you need

- **Node.js 18 or newer.** The server is a local (stdio) process started with `npx`. A Docker image exists but only runs headless Chromium.
- **No account or API key.** The server has no sign-in of its own.
- **A client that can start local servers**, such as the Codex CLI, the Codex IDE extension or Codex in the ChatGPT desktop app. From code, the OpenAI Agents SDK can launch stdio servers too.
- **For ChatGPT on the web:** a public HTTPS endpoint or Secure MCP Tunnel. Playwright MCP can serve HTTP with `--port`, but exposing it is up to you.

## Good to know

- **Headed and persistent by default.** It opens a visible browser and keeps a profile per workspace, so logins persist between sessions. Use `--isolated` for a throwaway profile and `--headless` to hide the window.
- **It is not a security boundary.** Microsoft says so in the README, and its origin allow and block lists don't stop redirects. Treat text on pages it visits as untrusted input.
- **Some tools run code.** `browser_evaluate` runs JavaScript in the page; `browser_run_code_unsafe` runs code in the server process, which the README calls equivalent to remote code execution. Keep approvals on.
- **Files are fenced in.** By default it only reaches files in the workspace root and blocks `file://` URLs.
- **Snapshots cost tokens.** For coding agents, Microsoft suggests its Playwright CLI with skills as a more token-efficient option.

## Install

1. **Add the server to Codex**

   Codex CLI:

   ```bash
   codex mcp add playwright -- npx @playwright/mcp@latest
   ```

   config.toml:

   ```toml
   [mcp_servers.playwright]
   command = "npx"
   args = ["@playwright/mcp@latest"]
   ```

   Agents SDK:

   ```python
   from agents import Agent, Runner
   from agents.mcp import MCPServerStdio
   
   async with MCPServerStdio(
       name="Playwright MCP",
       params={"command": "npx", "args": ["@playwright/mcp@latest"]},
   ) as server:
       agent = Agent(name="Assistant", mcp_servers=[server])
       result = await Runner.run(agent, "Open localhost:3000 and check that the signup form validates emails")
       print(result.final_output)
   ```

## Remove it

1. **In Codex**

   Codex CLI:

   ```bash
   codex mcp remove playwright
   ```

## Tools

- `browser_navigate`
- `browser_snapshot`
- `browser_click`
- `browser_type`
- `browser_fill_form`
- `browser_select_option`
- `browser_take_screenshot`
- `browser_evaluate`
- `browser_console_messages`
- `browser_network_requests`
- `browser_tabs`
- `browser_wait_for`

## Example prompts

- "Open localhost:3000 and check that the signup form validates emails"
- "Take a screenshot of the pricing page on mobile viewport"
- "Log in to the staging app and list all console errors"
- "Fill out the contact form on this page and submit it"

## Playwright MCP alternatives

- [Chrome DevTools MCP](https://chatgptplugins.directory/mcp/chrome-devtools.md): Let coding agents control and debug a live Chrome browser
- [GitHub](https://chatgptplugins.directory/mcp/github.md): Manage repos, issues, pull requests and Actions from your AI agent
- [Context7](https://chatgptplugins.directory/mcp/context7.md): Pull up-to-date, version-specific library docs into your coding agent
- [Supabase](https://chatgptplugins.directory/mcp/supabase.md): Manage Supabase databases, migrations, edge functions and logs
- [Stripe](https://chatgptplugins.directory/mcp/stripe.md): Query and act on your Stripe account and search Stripe docs from any agent
- [Atlassian Rovo (Jira & Confluence)](https://chatgptplugins.directory/mcp/atlassian-rovo.md): Work with Jira issues and Confluence pages through Atlassian's hosted MCP

## FAQ

### Can I use the Playwright MCP server in ChatGPT?

Not directly on the web. ChatGPT reaches MCP servers through a public HTTPS endpoint or Secure MCP Tunnel, while Playwright MCP normally runs as a local command. You can run it in HTTP mode with `--port` and connect it in developer mode through a tunnel, but anyone who can reach that URL can drive the browser. Codex is the simpler route. See [Add an MCP server to ChatGPT](/tutorials/add-mcp-server-to-chatgpt).

### How do I add Playwright MCP to Codex?

Add it as a stdio server that runs `npx @playwright/mcp@latest`; the install box on this page has the config. The Codex CLI, IDE extension and desktop app share `~/.codex/config.toml`. Start a new session and run `/mcp` to confirm the tools loaded. [Use plugins and MCP servers in Codex](/tutorials/use-plugins-in-codex) has the details.

### Can the agent use my logged-in accounts?

By default it uses its own profile, separate from your everyday browser, so it only sees sites you sign into during agent sessions. With Microsoft's browser extension it attaches to your existing Chrome or Edge tabs and their sessions, which lets it act as you. For testing, `--isolated` plus a `--storage-state` file with test-account cookies is the safer setup.

### Should I use Playwright MCP or Chrome DevTools MCP?

Playwright MCP can run Chromium, Firefox or WebKit and is built for clicking through flows reliably. [Chrome DevTools MCP](/mcp/chrome-devtools) officially supports only Chrome but adds DevTools features such as performance traces and Lighthouse audits. Pick Playwright for cross-browser flows and test drafting, Chrome DevTools for performance and debugging.

_Guide updated 2026-10-24. Sources: https://github.com/microsoft/playwright-mcp, https://learn.chatgpt.com/docs/extend/mcp, https://developers.openai.com/apps-sdk/deploy/connect-chatgpt, https://openai.github.io/openai-agents-python/mcp/._

---
Source: https://chatgptplugins.directory/mcp/playwright · Index: https://chatgptplugins.directory/llms.txt · Independent and community-run. Not affiliated with or endorsed by OpenAI. ChatGPT is a trademark of OpenAI.
