Skip to content

mcp command fails on Windows: fileURLToPath returns POSIX path /C:/... causing C:\C:\ doubling #101

@jiaweing

Description

@jiaweing

Bug

expect mcp crashes on Windows with:

Error: Cannot find module 'C:\C:\Users\...\expect-cli\dist\browser-mcp.js'

Root cause

In dist/index.js, the mcp command spawns browser-mcp.js using:

let v = fileURLToPath(new URL('./browser-mcp.js', import.meta.url))
// then: execFileSync(process.execPath, [v], ...)

On Windows, fileURLToPath returns a POSIX-style path /C:/Users/.../browser-mcp.js instead of C:\Users\...\browser-mcp.js. When this is passed as a CLI argument to node.exe, Windows interprets /C:/... relative to the current drive root, producing C:\C:\....

Repro

npm install -g expect-cli
echo '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1"}},"id":1}' | expect mcp

Environment

  • OS: Windows 11
  • Node.js: v22.22.2
  • expect-cli: 0.1.3
  • Shell: Git Bash (bash via MINGW64)

Fix suggestion

Wrap the path with a Windows path normalization before passing to execFileSync:

import { fileURLToPath } from 'node:url';
import path from 'node:path';

let v = path.resolve(fileURLToPath(new URL('./browser-mcp.js', import.meta.url)));

path.resolve will normalize /C:/...C:\... on Windows.

This blocks Claude Code MCP integration on Windows entirely — the MCP server can never start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions