Skip to main content
Glama

Playwright MCP

An MCP server that gives compatible clients structured control of a real Playwright browser for QA, scraping diagnostics, accessibility-minded inspection, and reproducible browser workflows.

Architecture

Transport entrypoints are thin:

  • src/index.ts starts MCP over stdio.

  • src/http.ts starts MCP over Streamable HTTP.

  • src/server.ts builds one McpServer and registers all tools.

Core services own browser state:

  • BrowserManager serializes tool execution, launches browsers lazily, and manages contexts/pages.

  • TelemetryStore captures console messages, page errors, failed requests, and recent network events.

  • Tool modules register focused actions and depend only on the public browser/session APIs.

Tool groups:

  • Browser/context/page lifecycle

  • Navigation and waiting

  • Interaction

  • Inspection and screenshots

  • Assertions

  • Diagnostics, tracing, and storage

Related MCP server: Playwright Server MCP

Install

npm install
npm run install-browsers
npm run build

Run

npm start

HTTP transport:

npm run start:http

Default HTTP endpoint: http://127.0.0.1:8931/mcp.

Production Controls

Configuration is environment-driven:

  • PLAYWRIGHT_MCP_HTTP_TOKEN: require Authorization: Bearer <token> for HTTP mode.

  • PLAYWRIGHT_MCP_HTTP_ALLOWED_ORIGINS: comma-separated CORS allowlist.

  • PLAYWRIGHT_MCP_ALLOWED_ORIGINS: comma-separated browser navigation allowlist.

  • PLAYWRIGHT_MCP_BLOCKED_ORIGINS: comma-separated browser navigation blocklist.

  • PLAYWRIGHT_MCP_ALLOW_EVALUATE: enable the dangerous evaluate tool. Default: false.

  • PLAYWRIGHT_MCP_ALLOW_DOWNLOADS: enable download tools and accepting downloads. Default: false.

  • PLAYWRIGHT_MCP_ALLOW_UPLOADS: enable upload tools. Default: false.

  • PLAYWRIGHT_MCP_ARTIFACT_DIR: screenshots, traces, PDFs, downloads, and storage state directory. Default: ./artifacts.

  • PLAYWRIGHT_MCP_MAX_CONTEXTS: browser context cap. Default: 8.

  • PLAYWRIGHT_MCP_MAX_PAGES: page cap. Default: 32.

  • PLAYWRIGHT_MCP_DEFAULT_TIMEOUT_MS: default Playwright timeout. Default: 30000.

  • PLAYWRIGHT_MCP_LOG_LEVEL: debug, info, warn, or error.

HTTP mode should use PLAYWRIGHT_MCP_HTTP_TOKEN before binding to anything other than localhost.

MCP client config

Examples are available in examples/:

  • claude_config.json

  • cursor_mcp.json

  • codex_config.toml

  • cline_mcp_settings.json

  • opencode_config.json

Development

npm run check

Available Tools

34 tools
assertAssertC

Run a browser assertion and return a pass/fail result with failure context.

Inputs: kind (required), pageId, expected, selector, +1 more.

browser_closeClose BrowserA

Close the browser and release all contexts/pages.

Inputs: no named parameters.

browser_launchLaunch BrowserB

Launch a Playwright browser lazily. Other tools also launch Chromium automatically when needed.

Inputs: browser, headless, slowMoMs.

browser_stateBrowser StateB

List active browser, contexts, pages, and current active page.

Inputs: no named parameters.

clickClickC

Click an element by selector, text, role, label, test id, or xpath.

Inputs: selector (required), button, pageId, timeoutMs, +1 more.

context_closeClose ContextC

Close a browser context. Defaults to the active context.

Inputs: contextId.

context_newNew ContextC

Create an isolated browser context and make it active.

Inputs: locale, userAgent, timezoneId, permissions, +5 more.

download_by_clickDownload By ClickB

Click an element, wait for a download, and save it into the artifact directory.

Inputs: selector (required), pageId, timeoutMs.

element_infoElement InfoB

Return text, attributes, bounding box, visibility, and enabled state for an element.

Inputs: selector (required), pageId.

evaluateEvaluate JavaScriptB

Evaluate JavaScript in the page. Use for diagnostics when dedicated tools are insufficient.

Inputs: script (required), arg, pageId.

fillFillC

Fill an input, textarea, contenteditable, or labelled field.

Inputs: value (required), selector (required), pageId, timeoutMs.

go_backGo BackC

Navigate back in page history.

Inputs: pageId, timeoutMs.

hoverHoverC

Hover an element.

Inputs: selector (required), pageId, timeoutMs.

network_blockBlock NetworkC

Block requests whose URL matches a regular expression for the active page.

Inputs: urlPattern (required), pageId.

network_mock_jsonMock JSON ResponseC

Fulfill matching requests with a JSON response for the active page.

Inputs: body (required), urlPattern (required), pageId, status.

page_closeClose PageC

Close a page. Defaults to the active page.

Inputs: pageId.

page_newNew PageC

Create a new page in a context and make it active.

Inputs: contextId.

page_switchSwitch PageC

Make an existing page active.

Inputs: pageId (required).

pdfExport PDFC

Export the current page as a PDF artifact. Chromium only.

Inputs: format, pageId, printBackground.

pressPressC

Press a key, optionally scoped to a selector.

Inputs: key (required), pageId, selector, timeoutMs.

reloadReloadC

Reload the current page.

Inputs: pageId, timeoutMs, waitUntil.

screenshotScreenshotC

Capture a page or element screenshot as PNG image content.

Inputs: pageId, fullPage, selector, saveArtifact.

select_optionSelect OptionC

Select options in a element.

Inputs: values (required), selector (required), pageId, timeoutMs.

set_checkedSet CheckedB

Check or uncheck a checkbox/radio control.

Inputs: checked (required), selector (required), pageId, timeoutMs.

set_viewportSet ViewportC

Set viewport dimensions for a page.

Inputs: width (required), height (required), pageId.

snapshotPage SnapshotB

Return title, URL, capped visible text, interactive elements, console errors, and network failures.

Inputs: pageId, maxElements, maxTextChars, telemetryLimit.

storage_stateStorage StateB

Return cookies and local storage for the active page context.

Inputs: pageId.

storage_state_saveSave Storage StateB

Save cookies and local storage for the active page context into the artifact directory.

Inputs: pageId.

telemetryTelemetryC

Return recent console, page error, response, and failed request telemetry.

Inputs: clear, limit, pageId.

trace_startStart TraceC

Start Playwright tracing for the active page context.

Inputs: pageId, sources, snapshots, screenshots.

trace_stopStop TraceA

Stop tracing and return trace zip bytes as base64.

Inputs: pageId.

upload_filesUpload FilesA

Set files on an input[type=file]. File paths must be inside the artifact directory.

Inputs: paths (required), selector (required), pageId.

wait_forWait ForC

Wait for selector, text, URL regex, timeout, load state, or network idle.

Inputs: kind (required), state, value, pageId, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    C2.9/5.0

    Scored across 34 tools

    Disambiguation4/5

    Most tools have distinct purposes: lifecycle management (browser/context/page), interactions (click, fill, press), inspection (snapshot, element_info, telemetry), and artifact/network utilities. There is some potential overlap between snapshot, element_info, telemetry, evaluate, and assert, but the descriptions make the intended boundaries reasonably clear.

    Naming Consistency3/5

    Everything uses snake_case, which is good, but conventions are mixed: noun_verb lifecycle names (browser_launch, page_new), bare action verbs (navigate, click), verb_noun actions (set_viewport, upload_files), and noun-only tools (pdf, storage_state). It remains readable, but an agent cannot fully predict the naming pattern.

    Tool Count2/5

    34 tools is well above the comfortable range and feels heavy for a browser automation surface. While Playwright is feature-rich, several areas could be consolidated (e.g., storage_state/storage_state_save, trace_start/trace_stop, browser_launch versus implicit launch), making the set harder to navigate than necessary.

    Completeness4/5

    The surface covers the core browser automation lifecycle very broadly: launch/state/close, contexts, pages, navigation, interactions, waits, assertions, screenshots, PDFs, tracing, storage, uploads/downloads, and network mocking. Minor gaps remain around dialogs, iframes, drag-and-drop, forward history, and direct cookie/localStorage mutation, but evaluate can work around many of those.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      Not graded
      maintenance
      A MCP server that provides browser automation tools, allowing users to navigate websites, take screenshots, click elements, fill forms, and execute JavaScript through Playwright.
      8
      2
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      A browser automation server providing Playwright capabilities for controlling web browsers, capturing screenshots, extracting content, and performing complex interactions through an MCP interface.
      6
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      A universal browser automation MCP server using Playwright, enabling programmatic control of Chrome with 63 tools for navigation, interaction, media control, and CDP-based diagnostics.
      63
      14 npm
      3
      MIT