4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VSCodeのRemote WSLでのPlaywright MCP実行時にブラウザを表示させる方法

Last updated at Posted at 2025-11-14

本題

Playwright MCP の GithubではPlaywright MCPを実行する際、command・args部分は以下の内容となっています。

Windows側(≠WSL)から実行する際は、これで問題なくブラウザが表示されます。

command="npx",
args=[
    "@playwright/mcp@latest"
]

(pythonコードの抜粋です)

一方で、WSL(VSCodeのRemote WSL)から実行する場合は、これだとブラウザが表示されません。
(--headlessオプションを付けていないにもかかわらずheadlessの動作になります)

WSLでもブラウザを表示させるには、以下の内容にする必要があります。

command="/bin/bash",
args=["-c", "export DISPLAY=:0 && npx " + " ".join([
    "@playwright/mcp@latest"
])]

少しはまったので記事にしてみました。
どなたかのお役に立てますと幸いです。

補足

そもそもVSCodeのRemote WSLとは?については、以下の記事などを参考にしていただければです
https://qiita.com/_masa_u/items/d3c1fa7898b0783bc3ed

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?