Skip to main content

Playwright MCP

A Model Context Protocol server that provides browser automation capabilities using Playwright. Enables LLMs to interact with web pages through structured accessibility snapshots — no vision models required.

Example

You: Navigate to https://demo.playwright.dev/todomvc and add "Buy groceries".

→ browser_navigate { url: "https://demo.playwright.dev/todomvc" }

- heading "todos" [level=1] [ref=e3]
- textbox "What needs to be done?" [ref=e5]

→ browser_type { target: "e5", text: "Buy groceries", submit: true }

- heading "todos" [level=1] [ref=e3]
- textbox "What needs to be done?" [ref=e5]
- list [ref=e8]:
- listitem [ref=e9]:
- checkbox "Toggle Todo" [ref=e10]
- text: Buy groceries
- contentinfo [ref=e12]:
- text: 1 item left

The LLM reads the accessibility snapshot, finds element refs like e5, and passes them as the target of the next tool call — clicking buttons, filling forms, checking checkboxes. No screenshots or coordinate guessing needed.

Key Features

  • Snapshot-based — operates on the accessibility tree, not pixels. Each element gets a unique ref for deterministic interaction
  • LLM-friendly — structured text output that LLMs parse naturally, far cheaper than DOM dumps or screenshots
  • Cross-browser — Chrome, Firefox, WebKit, and Edge support
  • Full automation — 70+ tools covering navigation, forms, network mocking, storage, tracing, video, and more
  • Persistent sessions — login state and cookies preserved between sessions by default
  • Works everywhere — VS Code, Cursor, Windsurf, Claude Code, Claude Desktop, and any MCP client

Quick Start

Add the server to your MCP client:

{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["@playwright/mcp@latest"]
}
}
}

The browser opens in headed mode by default so you can see what's happening. See Installation for client-specific setup.

Playwright MCP vs Playwright CLI

MCPPlaywright CLI
Best forSpecialized agentic loops, exploratory automationCoding agents (Claude Code, Copilot) working with large codebases
How it worksLLM calls MCP tools with structured parametersAgent runs shell commands
Token costHigher — tool schemas + snapshots in contextLower — concise CLI output, skills loaded on demand
Default modeHeadedHeadless
SetupJSON config in MCP clientnpm install -g @playwright/cli

Available Tools

Core (always enabled)

ToolDescription
browser_navigateNavigate to a URL
browser_navigate_backGo back in history
browser_snapshotCapture accessibility snapshot
browser_findSearch the snapshot for text or a regexp
browser_clickClick an element
browser_hoverHover over an element
browser_dragDrag and drop between elements
browser_dropDrop files or MIME-typed data onto an element
browser_typeType text into an element
browser_fill_formFill multiple form fields at once
browser_select_optionSelect dropdown option
browser_press_keyPress a key (Enter, Tab, etc.)
browser_take_screenshotTake a PNG/JPEG/WebP screenshot
browser_tabsList, create, close, select tabs
browser_handle_dialogAccept or dismiss dialogs
browser_file_uploadUpload files into a file chooser
browser_console_messagesGet console output
browser_network_requestsList network requests
browser_network_requestShow one request in full detail
browser_evaluateEvaluate JavaScript on page or element
browser_run_code_unsafeExecute a Playwright code snippet
browser_wait_forWait for text or time
browser_closeClose the page
browser_resizeResize the browser window

Network (--caps=network)

ToolDescription
browser_routeMock network requests
browser_route_listList active mocked routes
browser_unrouteRemove mocked routes
browser_network_state_setGo online or offline

Storage (--caps=storage)

ToolDescription
browser_cookie_list/get/set/delete/clearManage cookies
browser_localstorage_list/get/set/delete/clearManage localStorage
browser_sessionstorage_list/get/set/delete/clearManage sessionStorage
browser_storage_stateSave cookies + local storage to a file
browser_set_storage_stateRestore saved state

Testing (--caps=testing)

ToolDescription
browser_generate_locatorGenerate a Playwright locator for tests
browser_verify_element_visibleAssert element is visible
browser_verify_text_visibleAssert text is visible
browser_verify_list_visibleAssert a list and its items are visible
browser_verify_valueAssert form field value

Developer tools (--caps=devtools)

ToolDescription
browser_start_tracing / browser_stop_tracingRecord execution traces
browser_start_video / browser_stop_videoRecord session video
browser_video_chapterAdd a chapter card to the video
browser_video_show_actions / browser_video_hide_actionsToggle action callouts
browser_start_recording / browser_stop_recordingRecord manual actions as code
browser_highlight / browser_hide_highlightHighlight an element on the page
browser_annotateAsk the user to draw annotations on the page
browser_resumeResume paused script execution

PDF (--caps=pdf)

ToolDescription
browser_pdf_saveExport page as PDF

Vision (--caps=vision)

ToolDescription
browser_mouse_move_xyMove mouse to coordinates
browser_mouse_click_xyClick at coordinates
browser_mouse_drag_xyDrag between coordinates
browser_mouse_down / browser_mouse_upMouse button press/release
browser_mouse_wheelScroll with mouse wheel

Config (--caps=config)

ToolDescription
browser_get_configGet the resolved config