Skip to content

Windows + Claude Code: Playwright MCP fails with npx/cmd.exe — working solution #1540

@varanakonda

Description

@varanakonda

Problem

Playwright MCP server fails to start in Claude Code on Windows when configured with npx (either directly or via cmd.exe /c). The stdio transport pipes don't connect, and the server appears as disconnected with no error output.

Environment

  • Windows 11
  • Claude Code CLI (native, not VS Code extension)
  • Edge running with --remote-debugging-port=9222
  • @playwright/mcp versions tested: 0.0.41, 0.0.68

What doesn't work

1. claude mcp add with cmd /c npx:

claude mcp add playwright -- cmd /c npx -y @playwright/mcp@0.0.41 --cdp-endpoint http://127.0.0.1:9222

Result: Claude Code parses /c as a path (C:/), producing broken config:

{ "command": "cmd", "args": ["C:/", "npx", ...] }

2. Manual config with cmd.exe /c npx:

{
  "command": "cmd.exe",
  "args": ["/c", "npx", "-y", "@playwright/mcp@0.0.68", "--cdp-endpoint", "http://127.0.0.1:9222"]
}

Result: Process starts but stdin/stdout pipes don't connect. MCP stdio transport hangs silently.

Root cause: On Windows, npx is actually npx.cmd (a batch wrapper). When spawned via cmd.exe /c, the stdin/stdout pipes used by MCP's stdio transport don't connect properly to the actual Node.js process.

3. Playwright plugin (playwright@claude-plugins-official):
The official Claude Code plugin doesn't support --cdp-endpoint and has namespace conflicts (plugin:playwright:playwright).

Working solution

Use node directly with the absolute path to cli.js:

In ~/.claude.json (under the project's mcpServers):

"playwright": {
  "type": "stdio",
  "command": "node",
  "args": [
    "/absolute/path/to/project/node_modules/@playwright/mcp/cli.js",
    "--cdp-endpoint",
    "http://127.0.0.1:9222"
  ]
}

Steps:

  1. Install the package: npm add -D @playwright/mcp
  2. Find cli.js: node_modules/@playwright/mcp/cli.js
  3. Add the config above to ~/.claude.json under your project's mcpServers section
  4. Restart Claude Code

This bypasses the .cmd batch wrapper entirely and connects stdin/stdout correctly for MCP stdio transport.

Verification

You can test the MCP handshake manually:

echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"capabilities":{},"clientInfo":{"name":"test","version":"1.0"},"protocolVersion":"2024-11-05"}}' | node node_modules/@playwright/mcp/cli.js --cdp-endpoint http://127.0.0.1:9222

Should return: {"jsonrpc":"2.0","id":1,"result":{"serverInfo":{"name":"Playwright","version":"..."},...}}

Suggestion

Consider documenting the node cli.js approach for Windows users in the README, or fixing npx stdio pipe handling on Windows.

Related issues: #1234, #1359

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions