Skip to main content
Glama

Playwright MCP

A Model Context Protocol (MCP) server that provides browser automation capabilities using Playwright. Enables LLMs to interact with web pages through structured accessibility snapshots, bypassing the need for screenshots or visually-tuned models.

Features

  • Fast and lightweight - Uses Playwright's accessibility tree, not pixel-based input

  • LLM-friendly - No vision models needed, operates purely on structured data

  • Deterministic - Avoids ambiguity common with screenshot-based approaches

Requirements

  • Node.js 18 or newer

  • Any MCP client (VS Code, Cursor, Claude Desktop, Windsurf, etc.)

Quick Start

Add to your MCP client configuration:

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

VS Code / Cursor

Go to Settings → MCP → Add Server and configure manually using the standard config above.

Configuration

Basic Options

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "playwright-mcp@latest",
        "--headless",              // Run browser in headless mode
        "--browser", "chromium",    // Choose browser: chromium, firefox, webkit
        "--viewport-size", "1280x720" // Set viewport size
      ]
    }
  }
}

Browser Extension (Connect to Existing Browser)

Connect to your existing Chrome/Edge browser with logged-in sessions:

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

See extension/README.md for extension installation.

Isolated Sessions

Run each session in an isolated browser context:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": [
        "playwright-mcp@latest",
        "--isolated",
        "--storage-state", "path/to/storage.json"
      ]
    }
  }
}

Common Use Cases

Web Scraping

Navigate to pages, extract data, take screenshots, and interact with forms.

Testing & Automation

Verify elements, fill forms, click buttons, and run automated workflows.

Browser Extension Integration

Connect to your existing browser to interact with pages where you're already logged in.

Available Tools

  • Navigation: browser_navigate, browser_navigate_back

  • Interaction: browser_click, browser_type, browser_fill_form, browser_select_option

  • Inspection: browser_snapshot, browser_take_screenshot, browser_evaluate

  • Tab Management: browser_tabs (list, create, close, select)

  • Network: browser_network_requests, browser_console_messages

  • Advanced: PDF generation, coordinate-based interactions, test assertions

Run npx playwright-mcp@latest --help for full list of options.

Documentation

License

MIT

Available Tools

23 tools
browser_clickB
Destructive

Perform click on a web page

Inputs: element (required), ref (required), doubleClick, button, +1 more.

browser_closeA
Destructive

Close the page

Inputs: no named parameters.

browser_console_messagesB
Read-only

Returns all console messages

Inputs: level.

browser_dragB
Destructive

Perform drag and drop between two elements

Inputs: startElement (required), startRef (required), endElement (required), endRef (required).

browser_evaluateA
Destructive

Evaluate JavaScript expression on page or element

Inputs: function (required), element, ref.

browser_file_uploadB
Destructive

Upload one or multiple files

Inputs: paths.

browser_fill_formB
Destructive

Fill multiple form fields

Inputs: fields (required).

browser_handle_dialogC
Destructive

Handle a dialog

Inputs: accept (required), promptText.

browser_hoverB
Destructive

Hover over element on page

Inputs: element (required), ref (required).

browser_installA
Destructive

Install the browser specified in the config. Call this if you get an error about the browser not being installed.

Inputs: no named parameters.

browser_navigateB
Destructive

Navigate to a URL

Inputs: url (required).

browser_navigate_backA
Destructive

Go back to the previous page

Inputs: no named parameters.

browser_network_requestsB
Read-only

Returns all network requests since loading the page

Inputs: includeStatic.

browser_press_keyB
Destructive

Press a key on the keyboard

Inputs: key (required).

browser_resizeA
Destructive

Resize the browser window

Inputs: width (required), height (required).

browser_run_codeA
Destructive

Run Playwright code snippet

Inputs: code (required).

browser_select_optionB
Destructive

Select an option in a dropdown

Inputs: element (required), ref (required), values (required).

browser_snapshotA
Read-only

Capture accessibility snapshot of the current page, this is better than screenshot

Inputs: filename.

browser_tabsA
Destructive

List, create, close, or select a browser tab.

Inputs: action (required), index.

browser_take_screenshotA
Read-only

Take a screenshot of the current page. You can't perform actions based on the screenshot, use browser_snapshot for actions.

Inputs: type, filename, element, ref, +1 more.

browser_typeA
Destructive

Type text into editable element

Inputs: element (required), ref (required), text (required), submit, +1 more.

browser_wait_forB
Read-only

Wait for text to appear or disappear or a specified time to pass

Inputs: time, text, textGone.

health_checkA

Perform a local system health check to verify Playwright MCP server configuration and connectivity. Returns system information and configuration status.

Inputs: browserType.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 23 tools

    Disambiguation4/5

    Most tools have distinct purposes, such as browser_click for clicking, browser_fill_form for form filling, and browser_take_screenshot for screenshots. However, some overlap exists: browser_snapshot and browser_take_screenshot both capture page states, and browser_evaluate and browser_run_code both execute JavaScript, which could cause confusion. Descriptions help clarify differences, but the overlap is noticeable.

    Naming Consistency5/5

    Tool names follow a highly consistent snake_case pattern with a 'browser_' prefix for most tools, such as browser_click, browser_navigate, and browser_wait_for. The only exception is health_check, which still uses snake_case and fits the overall style. This consistency makes the tool set predictable and easy to navigate.

    Tool Count3/5

    With 23 tools, the count is on the higher side for a Playwright automation server, which typically involves many actions. It feels slightly heavy but reasonable given the domain's complexity. However, it borders on being overwhelming, as some tools might be combined or streamlined to reduce the number without losing functionality.

    Completeness5/5

    The tool set provides comprehensive coverage for web automation tasks, including navigation, interaction (click, type, hover), form handling, file uploads, dialog management, and debugging (console messages, network requests). It also includes utility functions like health_check and browser_install, ensuring no obvious gaps for common Playwright workflows. The surface is well-rounded and supports full automation lifecycles.

    Related MCP Connectors