Logotipo de Playwright MCP

Playwright MCP

Organización
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…

Editorroxybrowserlabs
Repositorioroxybrowser-playwright-mcp
IdiomaTypeScript
Forks
5
Estrellas
19
Herramientas disponibles
21
Tipo de transportestdio
Categorías
Enlaces
  • Conecta herramientas a flujos de trabajo con IA

    Playwright MCP ofrece funciones MCP que pueden usar los clientes y agentes de IA compatibles.

  • 21 herramientas disponibles

    Explora a continuación las acciones que se pueden invocar, con sus nombres y descripciones cuando el servidor los proporcione.

  • Configuración lista para copiar

    Usa los ejemplos de instalación para configurar este servidor en tu cliente MCP preferido.

  • Indicadores de interés en el código abierto

    19 estrellas y 5 forks en el repositorio enlazado.

@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

Instalación

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

Herramientas 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

Usa el MCP de Playwright MCP con varios modelos de IA

TypingMind conecta las herramientas MCP a nivel del espacio de trabajo, por lo que, una vez conectado Playwright MCP, puedes usarlo con distintos modelos de IA en TypingMind sin tener que configurarlo por separado para cada modelo. Esta integración MCP se ejecuta localmente en tu dispositivo a través del conector MCP de TypingMind.

Guía de configuración para usar el conector local

Usa esta opción si el servidor MCP necesita acceder a archivos locales, aplicaciones o recursos privados de tu ordenador.

1

Abre los ajustes de MCP

En TypingMind, ve a Ajustes, luego a Ajustes avanzados y a Model Context Protocol, y elige Configurar conector.

  1. Abre TypingMind en tu navegador.
  2. Haz clic en el icono de Ajustes.
  3. Ve a Ajustes avanzados.
  4. Abre la sección Model Context Protocol.
  5. Haz clic en Configurar conector y elige Este dispositivo.
Pantalla de configuración del conector MCP de TypingMind con «Este dispositivo» seleccionado
2

Ejecuta el comando del conector

Elige Este dispositivo, copia el comando de TypingMind y ejecútalo en Terminal. Mantén el proceso en ejecución mientras uses MCP.

  1. Copia el comando de configuración que muestra TypingMind.
  2. Abre Terminal en macOS o Windows Terminal en Windows.
  3. Pega y ejecuta el comando.
  4. Acepta la instalación del paquete si Terminal te pide confirmación para continuar.
  5. Mantén el proceso en ejecución en la ventana de Terminal mientras uses las herramientas MCP.
3

Añade Playwright MCP como servidor

Cuando el estado del conector sea «Listo», haz clic en «Edita servidores» y pega la configuración del servidor MCP.

  1. Espera hasta que el estado del conector indique «Listo».
  2. Haz clic en Edita servidores.
  3. Pega la configuración del servidor MCP de Playwright MCP.
  4. Guarda la lista de servidores.
  5. Actualiza para comprobar que el conector sigue listo.
Ajustes de MCP de TypingMind con un servidor activo y el botón «Edita servidores»
{
  "mcpServers": {
    "roxybrowser-playwright-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@roxybrowser/playwright-mcp"
      ]
    }
  }
}
4

Úsala con distintos modelos

Guarda la lista de servidores, abre Plugins, activa las herramientas MCP de Playwright MCP y selecciona cualquier modelo de IA compatible en TypingMind para usar las herramientas en el chat o asignárselas a un agente de IA.

  1. Abre la página Plugins en TypingMind.
  2. Activa las herramientas MCP de Playwright MCP.
  3. Inicia un chat y elige el modelo de IA que quieras usar.
  4. Usa las herramientas MCP en el chat o asígnalas a un agente de IA.
  5. Cambia a otro modelo de IA cuando lo necesites sin volver a conectar MCP.
Chat de TypingMind que usa herramientas MCP activadas con un modelo de IA seleccionado
¿Puedes usar Playwright MCP para ayudarme con esta tarea?
Playwright MCP
Claro. Lo he leído.
Esto he encontrado usando Playwright MCP.

Preguntas frecuentes

¿Para qué sirve el servidor MCP Playwright MCP?

Playwright MCP es un servidor MCP que permite a los clientes de IA compatibles conectarse a herramientas y contexto externos. En TypingMind, basta con añadir este servidor MCP una vez para que sus herramientas estén disponibles en tu espacio de trabajo de IA.

¿Puedo usar el servidor MCP Playwright MCP con varios modelos de IA en TypingMind?

Sí. TypingMind conecta las herramientas MCP a nivel del espacio de trabajo, por lo que puedes usar Playwright MCP con distintos modelos de IA, como Claude, ChatGPT, Gemini u otros que hayas configurado en TypingMind, sin configurar el servidor MCP por separado para cada modelo.

¿Por qué usar el conector MCP de Playwright MCP con TypingMind?

TypingMind es una de las mejores interfaces de chat con LLM porque reúne varios modelos de IA, prompts, plugins, agentes de IA, claves de API y herramientas MCP en un solo espacio de trabajo. Con Playwright MCP conectado, puedes usar sus herramientas MCP con tus modelos preferidos y mantener organizado tu flujo de trabajo de chat en TypingMind.

¿Cómo conecto el servidor MCP Playwright MCP a TypingMind?

Playwright MCP funciona a través del conector MCP local de TypingMind. Es la mejor opción cuando el servidor MCP necesita acceder a archivos locales, aplicaciones de escritorio, herramientas de línea de comandos o recursos privados de tu ordenador.

¿Qué herramientas ofrece el servidor MCP Playwright MCP en TypingMind?

Playwright MCP ofrece 21 herramientas MCP que puedes activar desde la página Plugins de TypingMind y usar en el chat o asignar a agentes de IA.

¿Tengo que compartir mis claves de API con TypingMind para usar el servidor MCP Playwright MCP?

No. TypingMind prioriza el funcionamiento local y te permite mantener el control de tus proveedores de modelos, claves de API, prompts y configuración MCP. Si Playwright MCP requiere autenticación, añade las cabeceras, los ajustes de OAuth o la configuración local necesarios para ese servidor MCP al crear la conexión.

Servidores MCP relacionados

Ver todos

Crea ya tu propio espacio de trabajo IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇