Logo de Playwright MCP

Playwright MCP

Organisation
roxybrowserlabs

@roxybrowser/playwright is a Playwright-style browser-automation library with humanized behavior by default, plus an MCP server (@roxybrowser/playwright/mcp) that exposes the same capabilities as…

Éditeurroxybrowserlabs
Dépôtroxybrowser-playwright-mcp
LangueTypeScript
Forks
5
Étoiles
19
Outils disponibles
21
Type de transportstdio
Catégories
Liens
  • Connectez des outils à vos workflows IA

    Playwright MCP propose des fonctionnalités MCP utilisables par les clients et agents IA compatibles.

  • 21 outils disponibles

    Parcourez les actions invocables ci-dessous, avec leurs noms et descriptions lorsque le serveur les fournit.

  • Configuration prête à copier

    Utilisez les exemples de configuration pour configurer ce serveur dans votre client MCP préféré.

  • Indicateurs de popularité open source

    19 étoiles et 5 forks sur le dépôt associé.

@roxybrowser/playwright

@roxybrowser/playwright is a Playwright-style browser-automation library with humanized behavior by default, plus an MCP server (@roxybrowser/playwright/mcp) that exposes the same capabilities as tools. It targets Chromium over CDP and Firefox over WebDriver BiDi. It is not a fork of Playwright — it reproduces a Playwright-familiar public API on top of a protocol-agnostic adapter layer.

Design goals

  • Keep the public API familiar to Playwright users.
  • Route all browser operations through a protocol-agnostic adapter layer.
  • Support both CDP (Chromium) and WebDriver BiDi (Firefox) as protocol backends.
  • Make click, type, hover, and scroll behavior humanized by default instead of adding a second API.
  • Expose the same capabilities as MCP tools for agent-driven automation.

Install

bash
npm install @roxybrowser/playwright
# or
pnpm add @roxybrowser/playwright

The package is ESM-only ("type": "module", NodeNext resolution). Two entry points are published:

  • @roxybrowser/playwright — the Playwright-style library (chromium, firefox, Browser, BrowserContext, Page, Locator, ElementHandle).
  • @roxybrowser/playwright/mcp — the MCP server factories and transports.

Package layout

  • src/browser*.ts: public browser, context, and browser type objects.
  • src/page.ts and src/locator.ts: Playwright-style page and locator APIs.
  • src/protocol/*: protocol abstraction plus CDP and BiDi backend entry points.
  • src/human/*: humanization profiles and controller contracts.
  • src/mcp/*: the MCP server, runtime, connected-browser session, and tools.
  • CLAUDE.md / AGENTS.md: architecture notes and repository guidance.

Testing

  • pnpm test runs the unit suite in tests/unit.
  • pnpm test:e2e runs a real-browser CDP flow in tests/e2e.
  • pnpm test:e2e:bidi runs the Firefox BiDi e2e suite in tests/e2e/bidi.

The e2e suite writes a temporary HTML fixture, launches Chrome or Edge in headless mode, and verifies the public API against a real page through CDP. If auto-detection is not enough for your machine or CI image, set ROXY_E2E_EXECUTABLE_PATH to a Chromium-based browser binary before running the e2e command.

The BiDi e2e suite prefers connecting to an existing Firefox BiDi websocket when ROXY_BIDI_WS_ENDPOINT is set. Without that variable, it launches a local Firefox binary with a temporary test profile and will use ROXY_BIDI_EXECUTABLE_PATH when provided. Set ROXY_BIDI_USE_ROXYBROWSER_API=1 to opt into opening a Firefox profile through the RoxyBrowser local API; the helper closes the connected browser/profile after each test by default so repeated local runs do not leak Firefox windows. Set ROXY_BIDI_KEEP_BROWSER_OPEN=1 only when deliberately debugging a shared endpoint and you intentionally want the Firefox window to stay open after a test. See .env.example for the supported local settings.

Browser connect

RoxyBrowser uses browserType.connect(endpointURL) as the only browser entry point. launch() and connectOverCDP() are intentionally unsupported and throw migration errors that point callers to connect().

chromium.connect() attaches to a Chromium/CDP WebSocket endpoint such as ws://127.0.0.1:9222/devtools/browser/<id>.

firefox.connect() attaches to a Firefox/WebDriver BiDi WebSocket endpoint. The Firefox BiDi path supports context creation, page creation, navigation, title lookup, script evaluation, and locator-based click, hover, fill, type, press, textContent, and isVisible flows.

  • ws:// and wss:// endpoints are supported.
  • launch() is not supported by the public Roxy API.
  • connectOverCDP() is not supported by the public Roxy API; use connect() for CDP and BiDi.

Examples

The examples directory contains runnable .mjs scripts grouped by entry point. Prefer the shared runner so endpoint environment variables are loaded and injected consistently:

  • pnpm examples page connect-over-cdp Connects to an existing CDP WebSocket endpoint from ROXY_CDP_ENDPOINT with chromium.connect() and runs the same flow.
  • pnpm examples page verify-baidu-search Drives Baidu search through the Page API and types into the search box with page.type(...).
  • pnpm examples page page-events-and-screenshot Connects to an endpoint, starts a temporary HTTP fixture, logs page.on(...) events, removes a request listener, and writes a screenshot to a temporary file.
  • pnpm examples page connect-firefox-bidi Exercises the Firefox WebDriver BiDi backend by connecting to an existing BiDi websocket.
  • pnpm examples mcp verify-baidu-search Drive the MCP server end-to-end (Baidu search, drag, file upload, humanized typing) and double as integration checks.

Use examples/page/ for direct Browser/Context/Page API examples, examples/mcp/ for MCP tool examples, and examples/repro/ for bug reproductions. Use pnpm examples <module> <script> to run a script through the shared examples runner. The runner loads .env, injects ROXY_CDP_ENDPOINT / ROXY_BIDI_ENDPOINT, and can open a RoxyBrowser profile through the local API when an endpoint is missing.

Useful environment variables:

  • ROXY_BROWSER_CHANNEL=chrome|msedge|chromium
  • ROXY_BROWSER_NAME=chromium|firefox
  • ROXY_EXECUTABLE_PATH=/absolute/path/to/browser
  • ROXY_HEADLESS=false
  • ROXY_CDP_ENDPOINT=ws://127.0.0.1:9222/devtools/browser/<id>
  • ROXY_BIDI_ENDPOINT=ws://127.0.0.1:9222/session/<id>
  • ROXY_PLAYWRIGHT_ARTIFACTS_DIR=/absolute/path/to/artifacts
  • ROXY_PLAYWRIGHT_DOWNLOADS_DIR=/absolute/path/to/downloads
  • ROXY_PLAYWRIGHT_TEMP_DIR=/absolute/path/to/temp

Connecting the MCP server to a browser

Before other MCP tools can act on a page, attach the session to a running browser with the roxy_browser_connect tool:

  • endpoint (required): the CDP WebSocket endpoint (Chrome) or the BiDi websocket endpoint (Firefox).
  • browser: chrome (default) or firefox. Chrome connects over CDP; Firefox connects over WebDriver BiDi.
  • sessionId (optional): reuse an existing BiDi session.

Endpoints typically come from the RoxyBrowser desktop app's local API, which opens a profile and returns a debugging endpoint. Once connected, the standard browser_* tools (browser_navigate, browser_snapshot, browser_click, browser_type, browser_take_screenshot, and so on) operate on the active tab.

browser_tabs keeps tab creation, selection, and closing in the background by default, so automation does not steal OS focus. Pass activate: true when the browser tab should be brought to the foreground. Background tab creation requires Chromium 145 or newer because older Chromium builds activate the application even when CDP receives background: true. On an older build, new fails with background_tab_unsupported before creating anything; background select remains available.

The Playwright-style Page API also creates new pages in the background by default. Call page.bringToFront() explicitly when the browser UI should be focused. This is an intentional RoxyBrowser divergence from Playwright's foreground page-creation behavior.

In-memory launch-and-connect

roxy_browser_launch is a special convenience tool for createRoxyBrowserMcpInMemory() only. The stdio and HTTP MCP servers keep exposing roxy_browser_connect and do not register roxy_browser_launch by default.

Enable it by passing RoxyBrowser launch configuration when creating the in-memory server:

ts
import { createRoxyBrowserMcpInMemory } from "@roxybrowser/playwright/mcp";

const bundle = await createRoxyBrowserMcpInMemory({
  roxyBrowserLaunch: {
    workspaceId: 123,
    apiToken: process.env.ROXYBROWSER_API_TOKEN!,
    apiPort: process.env.ROXYBROWSER_API_PORT ?? 50000
  }
});

The tool input is intentionally small:

  • dirId (required): the RoxyBrowser profile/window directory ID.
  • browser: chrome (default) or firefox.
  • forceOpen: passed to the RoxyBrowser open call when the profile is not already open.
  • args: optional browser startup arguments.

Before opening anything, roxy_browser_launch calls the RoxyBrowser connection-info API for that dirId. If an endpoint is already available, it connects directly. Otherwise it opens the profile and then connects. On success, it returns structured JSON in structuredContent and the same JSON as text:

json
{
  "browsers": [
    {
      "dirId": "profile-dir-id",
      "endpoint": "ws://127.0.0.1:9222/devtools/browser/...",
      "connected": true,
      "pageUrl": "https://example.com/",
      "browserType": "chrome"
    }
  ]
}

Asset directories

Page API and MCP tools share one asset model. Screenshots, downloads, snapshots, traces, videos, network exports, console exports, script outputs, and temporary runtime files are resolved by the same asset manager.

API options take precedence over environment variables. Relative filename arguments are resolved inside the relevant asset directory. Absolute asset paths are rejected by default.

Supported environment variables:

  • ROXY_PLAYWRIGHT_ARTIFACTS_DIR: default durable asset root.
  • ROXY_PLAYWRIGHT_DOWNLOADS_DIR: browser downloads.
  • ROXY_PLAYWRIGHT_SCREENSHOTS_DIR: screenshots.
  • ROXY_PLAYWRIGHT_SNAPSHOTS_DIR: accessibility snapshots and snapshot markdown files.
  • ROXY_PLAYWRIGHT_TRACES_DIR: traces.
  • ROXY_PLAYWRIGHT_VIDEOS_DIR: videos and screencast recordings.
  • ROXY_PLAYWRIGHT_NETWORK_DIR: network exports.
  • ROXY_PLAYWRIGHT_CONSOLE_DIR: console exports.
  • ROXY_PLAYWRIGHT_SCRIPTS_DIR: script and evaluate outputs.
  • ROXY_PLAYWRIGHT_TEMP_DIR: short-lived runtime files.
  • SANDBOX_OUTPUT_DIR: agent sandbox output directory. When set and no API asset option is provided, it becomes the default artifacts/downloads/scripts root.

The old MCP-specific variables ROXY_MCP_OUTPUT_DIR, PLAYWRIGHT_MCP_OUTPUT_DIR, ROXY_MCP_TEMP_DIR, and PLAYWRIGHT_MCP_TEMP_DIR are not supported.

You can also set asset directories directly when creating the MCP server or transports:

ts
import {
  createRoxyBrowserMcpInMemory,
  createRoxyBrowserMcpServer,
  startRoxyBrowserMcpHttp,
  startRoxyBrowserMcpStdio
} from "@roxybrowser/playwright/mcp";

const artifactsDir = "/absolute/path/to/artifacts";
const downloadsDir = "/absolute/path/to/downloads";
const screenshotsDir = "/absolute/path/to/screenshots";
const snapshotsDir = "/absolute/path/to/snapshots";
const tempDir = "/absolute/path/to/temp";

createRoxyBrowserMcpServer({
  artifactsDir,
  downloadsDir,
  screenshotsDir,
  snapshotsDir,
  tempDir
});

await createRoxyBrowserMcpInMemory({
  artifactsDir,
  downloadsDir,
  screenshotsDir,
  snapshotsDir,
  tempDir
});

await startRoxyBrowserMcpHttp({
  port: 3000,
  artifactsDir,
  downloadsDir,
  screenshotsDir,
  snapshotsDir,
  tempDir
});

await startRoxyBrowserMcpStdio({
  artifactsDir,
  downloadsDir,
  screenshotsDir,
  snapshotsDir,
  tempDir
});

MCP inspector workflow

This repo includes @modelcontextprotocol/inspector as a dev dependency so we can debug the Playwright MCP server locally.

Local stdio inspector

Use the inspector to spawn the built MCP server over stdio:

bash
pnpm inspector

That command will:

  • build the TypeScript sources into dist/
  • start the MCP Inspector UI on http://127.0.0.1:6274
  • launch node ./dist/bin/roxybrowser-mcp.js as the inspected MCP server

This is the fastest loop when you want to manually exercise tools from the inspector UI.

Local HTTP inspector

If you want to keep the MCP server running separately and connect the inspector over Streamable HTTP:

Terminal 1:

bash
pnpm mcp:http

Terminal 2:

bash
pnpm inspector:http

By default the HTTP server listens on http://127.0.0.1:3333/mcp.

Inspector CLI smoke

For a non-interactive check through the Inspector v2 CLI:

bash
pnpm test:mcp-inspector

This builds the server, runs mcp-inspector --cli against the stdio launcher, calls tools/list, and verifies the expected RoxyBrowser tools are exposed.

MCP server CLI options

The bundled roxybrowser-mcp launcher supports both transports:

bash
node ./dist/bin/roxybrowser-mcp.js --transport stdio
node ./dist/bin/roxybrowser-mcp.js --transport http --port 3333 --host 127.0.0.1 --path /mcp

Optional flags:

  • --artifacts-dir /absolute/path
  • --downloads-dir /absolute/path
  • --screenshots-dir /absolute/path
  • --snapshots-dir /absolute/path
  • --traces-dir /absolute/path
  • --videos-dir /absolute/path
  • --network-dir /absolute/path
  • --console-dir /absolute/path
  • --scripts-dir /absolute/path
  • --temp-dir /absolute/path
  • --snapshot-mode full
  • --snapshot-mode none

Installation

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

Outils disponibles

  • browser_close

    Close the page

  • browser_resize

    Resize the browser window

  • browser_console_messages

    Returns all console messages

  • browser_handle_dialog

    Handle a dialog

  • browser_evaluate

    Evaluate JavaScript expression on page or element

  • browser_file_upload

    Upload one or multiple files

  • browser_fill_form

    Fill multiple form fields

  • browser_install

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

  • browser_press_key

    Press a key on the keyboard

  • browser_type

    Type text into editable element

  • browser_navigate

    Navigate to a URL

  • browser_navigate_back

    Go back to the previous page

  • browser_network_requests

    Returns all network requests since loading the page

  • browser_take_screenshot

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

  • browser_snapshot

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

  • browser_click

    Perform click on a web page

  • browser_drag

    Perform drag and drop between two elements

  • browser_hover

    Hover over element on page

  • browser_select_option

    Select an option in a dropdown

  • browser_tabs

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

  • browser_wait_for

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

Utilisez le serveur MCP Playwright MCP avec plusieurs modèles IA

TypingMind connecte les outils MCP au niveau de l’espace de travail. Une fois Playwright MCP connecté, vous pouvez donc l’utiliser avec différents modèles IA dans TypingMind sans avoir à le configurer séparément pour chaque modèle. Cette intégration MCP s’exécute localement sur votre appareil via le connecteur MCP de TypingMind.

Guide de configuration du connecteur local

Choisissez cette méthode si le serveur MCP doit accéder à des fichiers locaux, à des applications ou à des ressources privées sur votre ordinateur.

1

Ouvrir les paramètres MCP

Dans TypingMind, accédez à « Paramètres », puis à « Paramètres avancés » et à « Model Context Protocol », et choisissez « Configurer connecteur ».

  1. Ouvrez TypingMind dans votre navigateur.
  2. Cliquez sur l’icône Paramètres.
  3. Accédez aux paramètres avancés.
  4. Ouvrez la section Model Context Protocol.
  5. Cliquez sur « Configurer connecteur » et choisissez « Cet appareil ».
Écran de configuration du connecteur MCP de TypingMind avec l’option « Cet appareil » sélectionnée
2

Exécuter la commande du connecteur

Choisissez « Cet appareil », copiez la commande depuis TypingMind et exécutez-la dans Terminal. Laissez le processus en cours d’exécution pendant que vous utilisez MCP.

  1. Copiez la commande de configuration affichée par TypingMind.
  2. Ouvrez Terminal sur macOS ou Windows Terminal sur Windows.
  3. Collez et exécutez la commande.
  4. Autorisez l’installation du paquet si Terminal vous demande de confirmer.
  5. Gardez la fenêtre de Terminal ouverte et le processus en cours d’exécution pendant que vous utilisez les outils MCP.
3

Ajoutez Playwright MCP en tant que serveur

Lorsque l’état du connecteur affiche « Prêt », cliquez sur « Éditer serveurs » et collez la configuration du serveur MCP.

  1. Attendez que l’état du connecteur affiche « Prêt ».
  2. Cliquez sur « Éditer serveurs ».
  3. Collez la configuration du serveur MCP Playwright MCP.
  4. Enregistrez la liste des serveurs.
  5. Actualisez pour vérifier que le connecteur est toujours prêt.
Paramètres MCP de TypingMind affichant un serveur actif et le bouton « Éditer serveurs »
{
  "mcpServers": {
    "roxybrowser-playwright-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@roxybrowser/playwright-mcp"
      ]
    }
  }
}
4

Utiliser la connexion avec différents modèles

Enregistrez la liste des serveurs, ouvrez « Plugins », activez les outils MCP de Playwright MCP, puis sélectionnez un modèle IA compatible dans TypingMind et utilisez les outils dans une discussion ou attribuez-les à un agent IA.

  1. Ouvrez la page Plugins dans TypingMind.
  2. Activez les outils MCP de Playwright MCP.
  3. Démarrez une discussion et choisissez le modèle IA que vous souhaitez utiliser.
  4. Utilisez les outils MCP dans le chat ou attribuez-les à un agent IA.
  5. Passez à un autre modèle IA selon vos besoins sans rétablir la connexion MCP.
Discussion TypingMind utilisant des outils MCP activés avec un modèle d’IA sélectionné
Pouvez-vous utiliser Playwright MCP pour m’aider dans cette tâche ?
Playwright MCP
Bien sûr. J’ai tout lu.
Voici ce que j’ai trouvé avec Playwright MCP.

Foire aux questions

À quoi sert le serveur MCP Playwright MCP ?

Playwright MCP est un serveur MCP qui permet aux applications IA compatibles d’accéder à des outils et à des informations contextuelles externes. Dans TypingMind, il vous suffit d’ajouter ce serveur MCP une seule fois pour rendre ses outils disponibles dans votre espace de travail IA.

Puis-je utiliser le serveur MCP Playwright MCP avec plusieurs modèles IA dans TypingMind ?

Oui. TypingMind connecte les outils MCP au niveau de l’espace de travail. Vous pouvez donc utiliser Playwright MCP avec différents modèles IA comme Claude, ChatGPT, Gemini ou d’autres modèles configurés dans TypingMind, sans avoir à configurer le serveur MCP séparément pour chaque modèle.

Pourquoi utiliser le connecteur MCP Playwright MCP avec TypingMind ?

TypingMind est l’une des meilleures interfaces de chat avec les LLM, car elle réunit plusieurs modèles IA, prompts, plugins, agents IA, clés API et outils MCP dans un seul espace de travail. Une fois Playwright MCP connecté, vous pouvez utiliser ses outils MCP avec vos modèles préférés tout en gardant vos discussions bien organisées dans TypingMind.

Comment connecter le serveur MCP Playwright MCP à TypingMind ?

Playwright MCP fonctionne via le connecteur MCP local de TypingMind. C’est l’option idéale lorsque le serveur MCP doit accéder à des fichiers locaux, des applications de bureau, des outils en ligne de commande ou des ressources privées sur votre ordinateur.

Quels outils le serveur MCP Playwright MCP propose-t-il dans TypingMind ?

Playwright MCP propose 21 outils MCP que vous pouvez activer depuis la page Plugins de TypingMind et utiliser dans les discussions ou attribuer à des agents IA.

Dois-je partager mes clés API avec TypingMind pour utiliser le serveur MCP Playwright MCP ?

Non. TypingMind privilégie le fonctionnement local et vous permet de garder le contrôle de vos fournisseurs de modèles, clés API, prompts et paramètres MCP. Si Playwright MCP nécessite une authentification, ajoutez les en-têtes, les paramètres OAuth ou la configuration locale requis pour ce serveur MCP lors de la création de la connexion.

Serveurs MCP similaires

Tout voir

Créez votre propre espace IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇