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:
- Install the package:
npm add -D @playwright/mcp
- Find
cli.js: node_modules/@playwright/mcp/cli.js
- Add the config above to
~/.claude.json under your project's mcpServers section
- 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
Problem
Playwright MCP server fails to start in Claude Code on Windows when configured with
npx(either directly or viacmd.exe /c). The stdio transport pipes don't connect, and the server appears as disconnected with no error output.Environment
--remote-debugging-port=9222@playwright/mcpversions tested: 0.0.41, 0.0.68What doesn't work
1.
claude mcp addwithcmd /c npx:Result: Claude Code parses
/cas 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,
npxis actuallynpx.cmd(a batch wrapper). When spawned viacmd.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-endpointand has namespace conflicts (plugin:playwright:playwright).Working solution
Use
nodedirectly with the absolute path tocli.js:In
~/.claude.json(under the project'smcpServers):Steps:
npm add -D @playwright/mcpcli.js:node_modules/@playwright/mcp/cli.js~/.claude.jsonunder your project'smcpServerssectionThis bypasses the
.cmdbatch wrapper entirely and connects stdin/stdout correctly for MCP stdio transport.Verification
You can test the MCP handshake manually:
Should return:
{"jsonrpc":"2.0","id":1,"result":{"serverInfo":{"name":"Playwright","version":"..."},...}}Suggestion
Consider documenting the
node cli.jsapproach for Windows users in the README, or fixingnpxstdio pipe handling on Windows.Related issues: #1234, #1359