diff --git a/README.md b/README.md index 57d80fc..975d762 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,9 @@ Playwright MCP server supports following arguments. They can be provided in the --config path to the configuration file. --device device to emulate, for example: "iPhone 15" --executable-path path to the browser executable. + --extension Connect to a running browser instance + (Edge/Chrome only). Requires the "Playwright MCP + Bridge" browser extension to be installed. --headless run browser in headless mode, headed by default --host host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces. @@ -214,7 +217,7 @@ Playwright MCP server supports following arguments. They can be provided in the ### User profile -You can run Playwright MCP with persistent profile like a regular browser (default), or in the isolated contexts for the testing sessions. +You can run Playwright MCP with persistent profile like a regular browser (default), in isolated contexts for testing sessions, or connect to your existing browser using the browser extension. **Persistent profile** @@ -254,6 +257,10 @@ state [here](https://playwright.dev/docs/auth). } ``` +**Browser Extension** + +The Playwright MCP Chrome Extension allows you to connect to existing browser tabs and leverage your logged-in sessions and browser state. See [extension/README.md](extension/README.md) for installation and setup instructions. + ### Configuration file The Playwright MCP server can be configured using a JSON configuration file. You can specify the configuration file diff --git a/extension/README.md b/extension/README.md new file mode 100644 index 0000000..6421798 --- /dev/null +++ b/extension/README.md @@ -0,0 +1,48 @@ +# Playwright MCP Chrome Extension + +## Introduction + +The Playwright MCP Chrome Extension allows you to connect to pages in your existing browser and leverage the state of your default user profile. This means the AI assistant can interact with websites where you're already logged in, using your existing cookies, sessions, and browser state, providing a seamless experience without requiring separate authentication or setup. + +## Prerequisites + +- Chrome/Edge/Chromium browser + +## Installation Steps + +### Download the Extension + +Download the latest Chrome extension from GitHub: +- **Download link**: https://github.com/microsoft/playwright-mcp/releases + +### Load Chrome Extension + +1. Open Chrome and navigate to `chrome://extensions/` +2. Enable "Developer mode" (toggle in the top right corner) +3. Click "Load unpacked" and select the extension directory + +### Configure Playwright MCP server + +Configure Playwright MCP server to connect to the browser using the extension by passing the `--extension` option when running the MCP server: + +```json +{ + "mcpServers": { + "playwright-extension": { + "command": "npx", + "args": [ + "@playwright/mcp@latest", + "--extension" + ] + } + } +} +``` + +## Usage + +### Browser Tab Selection + +When the LLM interacts with the browser for the first time, it will load a page where you can select which browser tab the LLM will connect to. This allows you to control which specific page the AI assistant will interact with during the session. + + diff --git a/src/program.ts b/src/program.ts index ee0e64b..bc313c2 100644 --- a/src/program.ts +++ b/src/program.ts @@ -43,6 +43,7 @@ program .option('--config ', 'path to the configuration file.') .option('--device ', 'device to emulate, for example: "iPhone 15"') .option('--executable-path ', 'path to the browser executable.') + .option('--extension', 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.') .option('--headless', 'run browser in headless mode, headed by default') .option('--host ', 'host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces.') .option('--ignore-https-errors', 'ignore https errors') @@ -59,7 +60,6 @@ program .option('--user-agent ', 'specify user agent string') .option('--user-data-dir ', 'path to the user data directory. If not specified, a temporary directory will be created.') .option('--viewport-size ', 'specify browser viewport size in pixels, for example "1280, 720"') - .addOption(new Option('--extension', 'Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed.').hideHelp()) .addOption(new Option('--connect-tool', 'Allow to switch between different browser connection methods.').hideHelp()) .addOption(new Option('--loop-tools', 'Run loop tools').hideHelp()) .addOption(new Option('--vision', 'Legacy option, use --caps=vision instead').hideHelp())