🗂

Claude Code:Playwright MCP:初期設定時のエラーの解消

に公開

前提条件

2025.6.29時点の現象と対応の記録。

エラー概要

1..mcp.jsonを作成して/mcpを実行すると以下のエラーが表示されて、playwright-mcpが実行できない。

no-mcp
No MCP servers configured

2.playwright-mcp実行後、指示を出すが、以下のエラーメッセージが出て処理ができない。

alredy-use
Error: Browser is already in use for ~/.cache/ms-playwright/mcp-chrome-profile, use --isolated to 
     run multiple instances of the same browser

No MCP servers configured

コンテナ内のプロジェクトフォルダルートにて、以下のコマンドを実行。
設定ファイルをプロジェクトフォルダ内に作成。

claude mcp add playwright -s project -- npx -y @playwright/mcp@latest

上記のコマンドの結果、プロジェクトフォルダルートに以下の内容の.mcp.jsonファイルが作成される。

.mcp.json

.mcp.json
{
  "mcpServers": {
    "playwright": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "@playwright/mcp@latest"
      ],
      "env": {}
    }
  }
}

claude code内で以下のコマンドを実行すると、以下のメッセージが表示される。

/mcp
No MCP servers configured

ここでポイントは、「.mcp.json」ファイルを作るときに、claude codeが起動中であったこと。

対応方法は、claude codeを再起動すると、以下の画面が表示された。

loaded

上記の1番を選択してclaude codeを実行。
/mcpコマンドを実行すると以下のようにplaywright mcpが認識される。

playwright mcp connected

以上で問題は解決した。

Error: Browser is already in use

claude codeにplaywright-mcpを利用して操作させようとすると以下のエラーが出て、mcp経由では実行ができない。

playwring-mcpをつかってgoogle.comのtitleを取得して。(プロンプト)

Error: Browser is already in use for ~/.cache/ms-playwright/mcp-chrome-profile, use --isolated to 
     run multiple instances of the same browser

.mcp.jsonを以下のように修正することで上記のエラーは解消した。

.mcp.json
{
  "mcpServers": {
    "playwright": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "@playwright/mcp@latest",
        "--headless",
        "--no-sandbox",
        "--isolated"
      ],
      "env": {}
    }
  }
}

上記は、以下の公式ドキュメントのオプション設定方法に即して設定した。

https://github.com/microsoft/playwright-mcp

上記設定後、claude codeを再起動すると、playwring-mcpがプロンプト経由で利用できる。

get-title-from-google.com-by-playwright-mcp
> playwright-mcpをつかってgoogle.comのtitleを取得して

● I'll get the title from google.com using playwright-mcp.

● playwright:browser_navigate (MCP)(url: "https://google.com")
  ⎿  - Ran Playwright code:           
     ```js
     // Navigate to https://google.com
     … +67 lines (ctrl+r to expand)

● The title of google.com is: Google
  ⎿  No open pages available. Use the "browser_navigate" tool to navigate to a page first.

参考資料

https://github.com/microsoft/playwright-mcp

https://zenn.dev/sesere/articles/4c0b55102dcc84

https://zenn.dev/karaage0703/articles/3bd2957807f311

https://qiita.com/Earthfreedom/items/fabd3aaa2bec2fccdcbc

Discussion