Skip to content

Add Playwright integration specification for browser testing in execution environments#156

Merged
notfolder merged 5 commits intomainfrom
copilot/add-playwright-docker-support
Dec 7, 2025
Merged

Add Playwright integration specification for browser testing in execution environments#156
notfolder merged 5 commits intomainfrom
copilot/add-playwright-docker-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 7, 2025

  • レビューフィードバックに対応完了
    • 環境変数設定セクション(3.1.3)を削除
    • 起動スクリプトセクション(3.1.4)を削除
    • イメージサイズ対策セクション(3.2)を削除
    • Java-PlaywrightとGo-Playwrightバリアントを追加
    • Docker間通信セクション(4.1.3)を削除
    • 実装優先順位セクション(12)を削除
    • ポート番号管理セクション(14.2)を削除
    • セクション番号を修正(14→13, 15→14, 16→15, 17→16)
    • 動的なMCP追加の説明を追加(環境選択後のみPlaywright MCPを追加)
    • text-editor MCPと同じ起動方式に変更(docker exec + stdio通信)
      • セクション2.2.2でtext-editor MCPと同じ起動方法を明記
      • セクション5.2.3でMCPサーバー起動の詳細シーケンスを追加
      • セクション5.4.1でPlaywrightMCPClientの処理内容を記述(コード削除)
      • セクション5.4.2でExecutionEnvironmentManagerの処理内容を記述(コード削除)
      • docker execコマンドラインは明記を維持
Original prompt

This section details on the original issue you should resolve

<issue_title>playwright対応</issue_title>
<issue_description>コマンド実行環境(MULTI_LANGUAGE_ENVIRONMENT_SPECIFICATION.md)と同じ様に、
playwrightのdockerコンテナも同時に作成して、playwright mcpサーバーをllmに提供してllmがコードを動かして、playwrightで検証出来る様にしたい。
dockerのネットワーク構成とか、llmに渡すプロンプトを考えて(URLはどうするのが良いか要検討)。

上記の様な仕様を日本語で詳細設計してください。設計はプログラムを書くのではなく、日本語で詳細を記述してください。
markdown形式で仕様を出力して。実装スケジュールは必要ありません。</issue_description>

Comments on the Issue (you are @copilot in this section)

@notfolder 実行環境docker内にplaywrightを導入してMCPサーバーを起動することは十分に可能だと考えられます。以下、その理由と実装方針を説明します。

実装可能性の根拠

  1. 既存のMCPサーバー導入実績
    現在のコードでは、実行環境docker内でtext-editor MCPサーバーを既に導入しています:

dockerfile:docker/executor-python/Dockerfile

Node.jsをインストール(text-editor MCP用)

RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
&& apt-get install -y nodejs
&& rm -rf /var/lib/apt/lists/*
全ての言語環境イメージ(python, miniforge, node, java, go)で同様にNode.jsがインストールされており、MCPサーバーを実行可能な環境が整っています。

  1. コンテナの永続実行設計
    実行環境dockerはENTRYPOINT ["sleep", "infinity"]で永続実行されるため、playwright MCPサーバーをバックグラウンドプロセスとして起動し続けることが可能です。

  2. ネットワーク構成
    python:handlers/execution_environment_manager.py

coding-agent-networkに接続してwebやrabbitmqにアクセス可能にする

"--network", "coding_agent_coding-agent-network",
実行環境dockerは既にcoding-agent-networkに接続されており、複数コンテナ間の通信が可能です。

  1. コマンド実行機構
    python:handlers/execution_environment_manager.py
    def execute_command(self, command: str, working_directory: str | None = None) -> dict[str, Any]:
    exec_args = [
    "exec",
    "-w", work_dir,
    container_id,
    "sh", "-c", command,
    ]
    docker execでコンテナ内のコマンドを自由に実行できるため、playwright MCPサーバーの起動やプロセス管理が可能です。

実装方針:実行環境docker内に統合
各言語環境イメージのDockerfileにplaywrightとブラウザ(chromium)をインストール
playwright MCPサーバーをコンテナ起動時にバックグラウンドで起動(text-editor MCPと同じ方法)
追加コンテナ不要で構成がシンプル

Chromiumなどのブラウザはサイズが大きいため、イメージサイズが増加します
言語毎のイメージに加えてブラウザ入りの環境を用意、計画時に選ばせる様にする

Dockerコンテナ内ではGUI不要なheadlessモードで実行
必要な依存ライブラリ(libxなど)のインストールが必要

検証対象のWebアプリケーションが実行環境docker内で起動している場合はlocalhostでアクセス可能
外部URLへのアクセスも可能


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: notfolder <20558197+notfolder@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Playwright support with Docker environment Add Playwright integration specification for browser testing in execution environments Dec 7, 2025
Copilot AI requested a review from notfolder December 7, 2025 04:36
Copy link
Copy Markdown
Owner

@notfolder notfolder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
レビューに従って修正して下さい
環境を選択後にのみfunction callingやシステムプロンプトにplaywright mcpサーバーを追加する様に定義して下さい

└── playwright/ # Playwright MCP Server作業ディレクトリ
```

#### 3.1.3 環境変数設定
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

環境変数無しで、この章を削除して下さい

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

環境変数設定セクション(3.1.3)を削除しました。(482e63c)

ENTRYPOINT ["/bin/bash", "-c", "/workspace/start-mcp-servers.sh && sleep infinity"]
```

### 3.2 イメージサイズ対策
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

イメージサイズ対策は不要です。この章は削除してください

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

イメージサイズ対策セクション(3.2)を削除しました。(482e63c)

└── Dockerfile # 通常版(Playwrightなし)
```

**注記:**
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javaもgoも用意して下さい

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Java-PlaywrightとGo-Playwrightバリアントを追加しました。全ての言語環境でPlaywright版を提供します。(482e63c)

3. スクリーンショット撮影や要素検証を実行
```

#### 4.1.3 Docker間通信(将来拡張)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker間通信の定義は不要です。この章は削除で

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker間通信セクション(4.1.3)を削除しました。(482e63c)


---

## 12. 実装優先順位
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実装優先度は不要です。この章は削除で

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実装優先順位セクション(旧12章)を削除し、以降のセクション番号を繰り上げました。(482e63c)

- ホワイトリストモードの使用を推奨
- プロダクション環境へのアクセスは慎重に

#### 14.1.3 Docker間通信(将来対応)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この章は削除で

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ポート番号管理セクション(14.2)とDocker間通信セクション(14.1.3)を削除しました。(482e63c)

ENV DISPLAY=:99
```

#### 3.1.4 起動スクリプト
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この起動スクリプトは不要なはずです

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

起動スクリプトセクション(3.1.4)を削除しました。(482e63c)

echo $! > /workspace/mcp-servers/text-editor/server.pid
```

**ENTRYPOINT変更:**
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

エントリポイントは変えないでください

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENTRYPOINTの変更を削除しました。(482e63c)

…ywright variants, dynamic MCP addition

Co-authored-by: notfolder <20558197+notfolder@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 7, 2025

@copilot
レビューに従って修正して下さい
環境を選択後にのみfunction callingやシステムプロンプトにplaywright mcpサーバーを追加する様に定義して下さい...

セクション5.1「動的なMCP追加」を追加し、Playwright対応環境が選択された場合にのみ、実行フェーズでLLMのfunction callingとシステムプロンプトにPlaywright MCPを追加する設計を明記しました。(482e63c)

Copy link
Copy Markdown
Owner

@notfolder notfolder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot
レビューに従って修正してください


実行環境Docker内でバックグラウンドプロセスとして起動し、stdio経由でLLMと通信します。

**起動方法:**
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entry pointで起動するのではなく、text-editor mcpサーバーと同じ立ち上げ方にして下さい
起動方法の詳細を記述してください

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text-editor MCPと同じ起動方式に変更しました。

変更内容:

  • セクション2.2.2: docker exec -iを使用したstdio通信方式を明記
  • セクション5.2.3: MCPサーバー起動の詳細シーケンス図と実装方法を追加
  • セクション5.4.1: PlaywrightMCPClientクラスの詳細実装(subprocess.Popen、start/stop、JSON-RPC通信)
  • セクション5.4.2: ExecutionEnvironmentManagerでの_start_playwright_mcp()メソッド実装とprepare()での起動フローを追加

text-editor MCPと同じく、ENTRYPOINTでの起動ではなく、ExecutionEnvironmentManagerがdocker execでMCPサーバープロセスを起動し、stdioで通信する方式としました。(345a57f)

Co-authored-by: notfolder <20558197+notfolder@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 7, 2025

@copilot
レビューに従って修正してください

レビュー内容に従い、Playwright MCP Serverの起動方法をtext-editor MCPと同じ方式に変更しました。docker execを使用したstdio通信で、subprocess.Popenによるプロセス管理を行います。詳細な起動シーケンスと実装コード例を追加しました。(345a57f)

@notfolder
Copy link
Copy Markdown
Owner

@copilot
コードは出さないで処理の内容を書くようにしてください。
docker execのコマンドラインだけ明記してください。

…cker exec command

Co-authored-by: notfolder <20558197+notfolder@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 7, 2025

@copilot
コードは出さないで処理の内容を書くようにしてください。
docker execのコマンドラインだけ明記してください。

Pythonコード例を削除し、処理内容の説明のみに変更しました。docker execコマンドラインは以下の箇所に明記しています:

docker exec -i -w /workspace/project <container_id> npx @executeautomation/playwright-mcp-server

セクション5.4.1と5.4.2では、各メソッドの処理内容を日本語で記述し、コード例は削除しました。(bc951ff)

@notfolder notfolder marked this pull request as ready for review December 7, 2025 11:04
@notfolder notfolder merged commit 84b6fa6 into main Dec 7, 2025
@notfolder notfolder deleted the copilot/add-playwright-docker-support branch December 7, 2025 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

playwright対応

2 participants