# MCP-playwright v. 1.0.0

### Name

playwright

### Description

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.


### Server

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

## Tools

<a id="browser-navigate"></a>

### browser_navigate

Navigate to a URL in the current tab.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "url"
  ],
  "properties": {
    "url": {
      "type": "string",
      "description": "The URL to navigate to."
    }
  }
}
```

<a id="browser-navigate-back"></a>

### browser_navigate_back

Navigate back in the browser history.

**Input Schema**

```json
{
  "type": "object",
  "properties": {}
}
```

<a id="browser-snapshot"></a>

### browser_snapshot

Capture the current accessibility tree snapshot of the page. Returns structured element references (ref=eN) used by other tools.


**Input Schema**

```json
{
  "type": "object",
  "properties": {}
}
```

<a id="browser-take-screenshot"></a>

### browser_take_screenshot

Take a screenshot of the current page or a specific element.


**Input Schema**

```json
{
  "type": "object",
  "properties": {
    "element": {
      "type": "string",
      "description": "Ref or CSS selector for the element to screenshot (optional)."
    },
    "raw": {
      "type": "boolean",
      "description": "Return raw base64 image data instead of saving to a file."
    }
  }
}
```

<a id="browser-click"></a>

### browser_click

Click an element on the page.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "element"
  ],
  "properties": {
    "element": {
      "type": "string",
      "description": "Element ref (e.g. \"e5\") or CSS selector."
    },
    "button": {
      "type": "string",
      "enum": [
        "left",
        "right",
        "middle"
      ],
      "description": "Mouse button to use. Defaults to \"left\"."
    },
    "modifiers": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "Alt",
          "Control",
          "Meta",
          "Shift"
        ]
      },
      "description": "Keyboard modifiers to hold during the click."
    }
  }
}
```

<a id="browser-hover"></a>

### browser_hover

Hover over an element on the page.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "element"
  ],
  "properties": {
    "element": {
      "type": "string",
      "description": "Element ref or CSS selector."
    }
  }
}
```

<a id="browser-type"></a>

### browser_type

Type text into the currently focused element.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "text"
  ],
  "properties": {
    "text": {
      "type": "string",
      "description": "Text to type."
    },
    "delay": {
      "type": "number",
      "description": "Milliseconds between keystrokes (optional)."
    }
  }
}
```

<a id="browser-fill-form"></a>

### browser_fill_form

Fill a form field with a value.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "element",
    "value"
  ],
  "properties": {
    "element": {
      "type": "string",
      "description": "Element ref or CSS selector."
    },
    "value": {
      "type": "string",
      "description": "Value to fill."
    }
  }
}
```

<a id="browser-select-option"></a>

### browser_select_option

Select an option in a <select> element.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "element",
    "value"
  ],
  "properties": {
    "element": {
      "type": "string",
      "description": "Element ref or CSS selector of the <select>."
    },
    "value": {
      "type": "string",
      "description": "Option value or label to select."
    }
  }
}
```

<a id="browser-press-key"></a>

### browser_press_key

Press a keyboard key (e.g. "Enter", "Tab", "Escape").

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "key"
  ],
  "properties": {
    "key": {
      "type": "string",
      "description": "Key to press. Accepts Playwright key names such as \"Enter\", \"Tab\", \"ArrowDown\", \"F5\", etc.\n"
    },
    "modifiers": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "Alt",
          "Control",
          "Meta",
          "Shift"
        ]
      }
    }
  }
}
```

<a id="browser-drag"></a>

### browser_drag

Drag an element from one position to another.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "sourceElement",
    "targetElement"
  ],
  "properties": {
    "sourceElement": {
      "type": "string",
      "description": "Ref or CSS selector of the element to drag."
    },
    "targetElement": {
      "type": "string",
      "description": "Ref or CSS selector of the drop target."
    }
  }
}
```

<a id="browser-handle-dialog"></a>

### browser_handle_dialog

Accept or dismiss a browser dialog (alert / confirm / prompt).

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "action"
  ],
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "accept",
        "dismiss"
      ]
    },
    "promptText": {
      "type": "string",
      "description": "Text to enter if the dialog is a prompt (optional)."
    }
  }
}
```

<a id="browser-file-upload"></a>

### browser_file_upload

Upload a file via a file input element.

**Input Schema**

```json
{
  "type": "object",
  "required": [
    "element",
    "files"
  ],
  "properties": {
    "element": {
      "type": "string",
      "description": "Ref or CSS selector of the <input type=\"file\"> element."
    },
    "files": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Absolute paths to the files to upload."
    }
  }
}
```

<a id="browser-wait-for"></a>

### browser_wait_for

Wait for an element or a network response to appear.

**Input Schema**

```json
{
  "type": "object",
  "properties": {
    "element": {
      "type": "string",
      "description": "Ref or CSS selector to wait for (optional)."
    },
    "url": {
      "type": "string",
      "description": "URL pattern to wait for a network response on (optional)."
    },
    "timeout": {
      "type": "number",
      "description": "Maximum wait time in milliseconds (default 30000)."
    }
  }
}
```

<a id="browser-tabs"></a>

### browser_tabs

List open tabs, create a new tab, switch to a tab, or close a tab.


**Input Schema**

```json
{
  "type": "object",
  "properties": {
    "action": {
      "type": "string",
      "enum": [
        "list",
        "new",
        "switch",
        "close"
      ],
      "description": "Tab action to perform."
    },
    "tabId": {
      "type": "string",
      "description": "Tab ID for switch / close actions (optional)."
    },
    "url": {
      "type": "string",
      "description": "URL to open in a new tab (optional)."
    }
  }
}
```

<a id="browser-resize"></a>

### browser_resize

Resize the browser viewport or emulate a device.

**Input Schema**

```json
{
  "type": "object",
  "properties": {
    "width": {
      "type": "number",
      "description": "Viewport width in pixels."
    },
    "height": {
      "type": "number",
      "description": "Viewport height in pixels."
    },
    "device": {
      "type": "string",
      "description": "Named device to emulate (e.g. \"iPhone 15\", \"iPad Pro 11\", \"Desktop Chrome\"). Overrides width/height when provided.\n"
    },
    "orientation": {
      "type": "string",
      "enum": [
        "landscape",
        "portrait"
      ]
    }
  }
}
```

<a id="browser-network-requests"></a>

### browser_network_requests

List all network requests made since page load, with status, method, URL, response headers, and optional response body.


**Input Schema**

```json
{
  "type": "object",
  "properties": {
    "responseBody": {
      "type": "boolean",
      "description": "Include response bodies (default false)."
    },
    "responseHeaders": {
      "type": "boolean",
      "description": "Include response headers (default false)."
    }
  }
}
```

<a id="browser-console-messages"></a>

### browser_console_messages

Return browser console messages (errors, warnings, logs).

**Input Schema**

```json
{
  "type": "object",
  "properties": {
    "level": {
      "type": "string",
      "enum": [
        "error",
        "warning",
        "info",
        "debug"
      ],
      "description": "Minimum severity level to return (default \"error\")."
    }
  }
}
```

<a id="browser-evaluate"></a>

### browser_evaluate

Evaluate a JavaScript expression or function in the page context. Accepts a plain expression or an async arrow function body.


**Input Schema**

```json
{
  "type": "object",
  "required": [
    "expression"
  ],
  "properties": {
    "expression": {
      "type": "string",
      "description": "JavaScript to evaluate."
    }
  }
}
```

<a id="browser-run-code"></a>

### browser_run_code

Execute an arbitrary Playwright script (TypeScript/JavaScript) in the MCP server process. RCE-equivalent — enable only for trusted clients. The function receives a `page` argument.


**Input Schema**

```json
{
  "type": "object",
  "required": [
    "code"
  ],
  "properties": {
    "code": {
      "type": "string",
      "description": "Playwright script to run, e.g.: \"async (page) => { return await page.title(); }\"\n"
    }
  }
}
```

<a id="browser-close"></a>

### browser_close

Close the current browser tab or the entire browser session.

**Input Schema**

```json
{
  "type": "object",
  "properties": {
    "all": {
      "type": "boolean",
      "description": "Close all tabs and kill the browser process (default false)."
    }
  }
}
```
