Skip to main content
Glama

playwright-mcp の使い方

npmバージョン ドキュメント

導入

playwright-mcp(Model Context Protocol)は、AIアシスタントとブラウザ自動化のギャップを埋める強力なツールです。AIモデルがウェブブラウザと対話し、DOM要素を検査し、ユーザーインタラクションを記録し、より高精度なPlaywrightテストスクリプトを生成することを可能にします。このガイドでは、playwright-mcpの効果的な設定と使用方法について説明します。

Related MCP server: browser-devtools-mcp

ツール

ブラウザ インターフェースで利用可能なツール:

ブラウザツールボックス

  1. DOMを選択 (🎯): クリックすると、ページからHTML要素を選択してキャプチャします。テストケースのセレクターを記録する際に使用します。

  2. 画像を選択 (📸): 特定の要素のスクリーンショットをキャプチャします。ビジュアルテストやドキュメント作成に便利です。

  3. インタラクションの記録 (📋): クリック、入力、ナビゲーションといったブラウザインタラクションを記録します。これらのインタラクションは自動的にセレクターを生成し、Claude や Cursor などの MCP クライアントにコンテキストとして渡すことで、テストケースの作成に役立ちます。

MCPコマンド

  1. init-browser : Playwright ブラウザを初期化します。

  2. get-context : テストケースの作成に使用するウェブサイトのコンテキストを取得します。

  3. execute-code : 現在のページに対してカスタム Playwright JS コードを実行します。

  4. get-screenshot : 現在のページのスクリーンショットを取得する

  5. get-full-dom : 現在のページの完全なDOMを取得します。(代わりにget-context使用をお勧めします)

もっと詳しく知る

さらに詳しく知りたいですか? 完全なドキュメントをご覧ください。

📖ドキュメントを見る

Available Tools

5 tools
execute-codeA

Execute custom Playwright JS code against the current page

Inputs: code (required).

get-contextB

Get the website context which would be used to write the testcase

Inputs: no named parameters.

get-full-domA

Get the full DOM of the current page. (Deprecated, use get-context instead)

Inputs: no named parameters.

get-screenshotB

Get a screenshot of the current page

Inputs: no named parameters.

init-browserC

Initialize a browser with a URL

Inputs: url (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 5 tools

    Disambiguation3/5

    Most tools have distinct purposes, but get-context and get-full-dom overlap significantly, with the latter deprecated in favor of the former. This creates ambiguity about which to use for DOM-related tasks, though the deprecation note helps clarify.

    Naming Consistency4/5

    The tools follow a consistent verb_noun pattern with hyphens, such as execute-code and get-screenshot. The only minor deviation is init-browser, which uses 'init' instead of a more standard verb like 'initialize', but overall the naming is predictable and readable.

    Tool Count4/5

    With 5 tools, the count is reasonable for a Playwright automation server, covering core operations like initialization, execution, and inspection. It might benefit from additional tools for actions like navigation or element interaction, but it's well-scoped for basic functionality.

    Completeness3/5

    The tools cover initialization, code execution, and page inspection, but there are notable gaps for common Playwright workflows, such as navigation (e.g., go-to-url), element interaction (e.g., click, fill), or test assertion. This limits the server's ability to handle full automation tasks without workarounds.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers