home / mcp / playwright mcp server

Playwright MCP Server

Playwright Model Context Protocol Server - Tool to automate Browsers and APIs in Claude Desktop, Cline, Cursor IDE and More πŸ”Œ

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "aakashh242-mcp-playwright": {
      "command": "npx",
      "args": [
        "-y",
        "@executeautomation/playwright-mcp-server"
      ],
      "env": {
        "YOUR_ENV": "PLACEHOLDER"
      }
    }
  }
}

Playwright MCP Server is a Model Context Protocol server that enables LLMs to automate and interact with web pages through a real Playwright-driven browser. It supports actions like navigation, taking screenshots, generating tests, and extracting page data, all within a scalable MCP HTTP/gateway workflow.

How to use

You run the Playwright MCP Server as a local or HTTP-enabled service and connect your MCP client to it. Use the stdio configuration for a local, in-process server, or enable the HTTP transport to run behind gateways and share artifacts across sessions. The server exposes a set of tools to automate browser actions, capture outputs, and generate tests.

How to install

Prerequisites: Node.js and npm (or an alternative package manager that supports npm packages). You will install the MCP server package and run it with a standard command.

# Install globally via npm
npm install -g @executeautomation/playwright-mcp-server
```

```
# Or install and start with npx (no global install required)
npx @executeautomation/playwright-mcp-server
```

```
# Alternative: install via Smithery (if you use Smithery workflow)
npx @smithery/cli install @executeautomation/playwright-mcp-server --client claude
````}]} ,{

Configuration to use Playwright Server

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@executeautomation/playwright-mcp-server"]
    }
  }
}
```

This configuration defines a local, stdio-based server named playwright that you can reference from your MCP client. Use the provided command and arguments exactly as shown to start the server in your environment.

Streamable HTTP mode

You can run the Playwright MCP Server in HTTP mode to work behind gateways and share session artifacts through resource links.

Start in HTTP mode (port and path defaults apply):

npx @executeautomation/playwright-mcp-server --http
```

Override port and path if needed:

```
npx @executeautomation/playwright-mcp-server --http --port 3000 --path /custom-mcp

Files and resource sharing in HTTP mode

Generated artifacts (screenshots, PDFs, console logs, and generated tests) are stored under /data/<session>/<resourceId>.<ext> on the server. Each session has isolated resources, and links expire after the configured TTL. Tools return resourceLinks that point to download URLs like http://host:port/path/resources/session/resourceId/filename.

Uploads in HTTP mode

In HTTP mode, you upload files for input elements by first obtaining a session-scoped upload URL, then calling the upload tool with the returned URI.

First, call construct_upload_url to get an upload endpoint, then post the file with multipart/form-data under the field file. After a successful upload, you receive a session-scoped resourceUri, and you pass that to playwright_upload_file to attach the file to your page.

Client configuration

Configure your MCP client (Claude Desktop, VS Code, or other) to point at the server using the mcpServers section you defined above. The command and URL in the example are what you will use to connect.

CLI flags

Use the following flags when running the server to tailor transport, host, and resource settings.

  • --http Enable Streamable HTTP transport (default: off; stdio is used when omitted)
  • --port <number> HTTP port (default: 8000)
  • --path <path> Base HTTP path (default: /mcp)
  • --host-name <hostname> Hostname for download URLs
  • --listen <address> Bind address for HTTP server
  • --insecure Use http scheme for download links (omit for https)
  • --resource-ttl <seconds> TTL for resources (default 600 seconds)
  • --static-user-agent Disable default User-Agent rotation

Agents / Prompts

A starter agent prompt is available to guide you in building and testing workflows. Use it as a template and customize for your environment.

Contributing

Follow standard contribution practices, ensure tooling like pre-commit hooks and lint/tests run cleanly locally, and update documentation when you add or change MCP capabilities.

Docker Support

The Playwright MCP Server can run in a Docker container with browsers and dependencies included. You can pull the image and run in standard Docker or compose for production HTTP usage.

Testing

Tests use Jest and cover the server’s toolset and API. Run tests with the provided scripts to verify behavior and generate coverage reports.

Available Tools

This server exposes tools for browser automation, navigation, interaction, and data extraction. See the tool list in your client to discover all supported commands such as navigate, click, fill, get text, take screenshots, and generate tests.

Available tools

playwright_navigate

Open a URL with optional viewport/headless/browser type; browser launches if needed.

playwright_screenshot

Capture a screenshot of the page or a specific element; in HTTP mode, a resource link is returned.

playwright_save_as_pdf

Save the current page as a PDF and obtain a downloadable resource in HTTP mode.

playwright_console_logs

Retrieve browser console logs with optional filters for debugging.

playwright_upload_file

Set a file into an <input type="file"> element; in HTTP mode, upload first via a session-scoped URL.

construct_upload_url

Return a session-scoped upload URL for HTTP mode to attach uploaded files.

playwright_click

Click on an element with optional selectors and wait strategies.

playwright_fill

Fill an input field with a value; supports selectors for targeting elements.

playwright_select

Select an option from a dropdown by value or visible text.

playwright_hover

Hover over an element to reveal menus or tooltips.

playwright_drag

Drag and drop or drag to a target element.

playwright_press_key

Press a keyboard key or combination on the active element.

playwright_iframe_click

Interact with elements inside an iframe.

playwright_iframe_fill

Fill inputs inside an iframe context.

playwright_get_visible_text

Extract visible text content from the page.

playwright_get_visible_html

Retrieve cleaned visible HTML content.

playwright_custom_user_agent

Override the User-Agent string for browser contexts.

playwright_go_back

Navigate back in the browser history.

playwright_go_forward

Navigate forward in the browser history.

playwright_close

Close the current page or the browser context.

playwright_evaluate

Execute JavaScript in the page context and return results.

playwright_expect_response

Wait for and validate a network response.

playwright_assert_response

Assert properties of a network response during a test.

playwright_get

HTTP GET helper for API interactions.

playwright_post

HTTP POST helper for API interactions.

playwright_put

HTTP PUT helper for API interactions.

playwright_patch

HTTP PATCH helper for API interactions.

playwright_delete

HTTP DELETE helper for API interactions.

start_codegen_session

Begin a code generation session to record Playwright interactions.

end_codegen_session

End a code generation session and produce reusable tests.