home / mcp / playwright mcp server

Playwright MCP Server

Provides browser automation via MCP by managing sessions, pages, and network requests across Chromium, Firefox, and WebKit.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "leviathangk-playwrightmcpforcrawler": {
      "command": "node",
      "args": [
        "@leviathangk/playwright-mcp@latest",
        "--browser",
        "chromium",
        "--headless",
        "false",
        "--session-timeout",
        "300000",
        "--max-sessions",
        "10"
      ]
    }
  }
}

The Playwright MCP Server lets you manage multiple browser automation sessions across Chromium, Firefox, and WebKit. It supports concurrent sessions, page/tab management, navigation, user input, and network inspection, all through a structured MCP interface that you can drive from your own client.

How to use

You control the server by issuing well-defined tool calls from your MCP client. Each session runs in isolation, so you can create multiple sessions, perform browser actions in each, and gather results without interference.

Key usage patterns include creating a session, navigating pages, interacting with elements, and inspecting network activity. You can manage multiple pages within a session, switch focus between them, and collect structured data from the page. When you are finished, close the session to free resources.

Example usage flow in your client: - Create a new browser session - Navigate to a URL - Perform actions like clicking elements or typing text - Retrieve page data or inspect network requests - Close the session when done

How to install

npm i @leviathangk/playwright-mcp

Next, configure the MCP Server so your client can load and start the Playwright MCP endpoint.

Configuration and operation notes

- The server runs as a local process started through an MCP command with Node. You can customize browser type, headless mode, session timeout, and max concurrent sessions.

- Core options you can set when starting the server include which browser to use, whether to run headless, session timeout in milliseconds, and the maximum number of concurrent sessions.

Examples and detailed commands

Configure the MCP to run the Playwright MCP Server with Chromium in non-headless mode and specific session limits as shown in the example below. This config is added to your MCP Server configuration under mcpServers.

{
  "mcpServers": {
    "playwright": {
      "command": "node",
      "args": [
        "@leviathangk/playwright-mcp@latest",
        "--browser", "chromium",
        "--headless", "false",
        "--session-timeout", "300000",
        ""--max-sessions"", "10"]
    }
  }
}

Security and maintenance notes

- Sessions auto-clean up after timeout to free resources. Make sure your session timeout aligns with your workload.

- Keep the MCP server up to date to benefit from browser driver improvements and any safety updates.

Available tools

browser_install

Install Playwright browsers for the server (Chromium, Firefox, WebKit).

browser_create_session

Create a new browser automation session to run in parallel with any active sessions.

browser_close_session

Terminate a specific session and release associated resources.

browser_get_pages

Return a list of all open pages (tabs) within a session.

browser_new_page

Open a new page (tab) in the specified session.

browser_switch_page

Switch focus to a specified page in a session.

browser_close_page

Close a specific page within a session.

browser_navigate

Navigate the active page to a given URL.

browser_click

Click an element matching a selector on the active page.

browser_type

Type text into an element on the active page.

browser_scroll

Scroll the active page to a specified position.

browser_wait_for_element

Wait for a specific element to appear on the page.

browser_execute_script

Run custom JavaScript in the context of the active page.

browser_get_page_structure

Analyze and retrieve the structure of the current page.

browser_find_element_by_text

Find an element by visible text.

browser_query_selector

Query elements using CSS selectors.

browser_get_page_content

Fetch the page content in HTML or text formats.

browser_get_text_content

Extract the text content from a specific element.

browser_screenshot

Capture a screenshot of the page or element.

browser_search_requests

Search captured network requests with optional regex filters.

browser_get_requests

Retrieve all captured network requests for the session.

browser_get_request_detail

Get detailed information about a request, including curl commands.

browser_clear_requests

Clear the captured network request history.