Skip to content

[macOS] Console launch fails: ''default'' quoting broken in shell command #45

@ben1440

Description

@ben1440

Bug Description

On macOS (Apple Silicon, Sequoia 15.5), the PowerShell.MCP proxy fails to maintain a connection. The proxy spawns a Terminal.app window with pwsh, but the shell quoting for the -Command argument is broken — identical root cause to #39 (Linux), but affecting macOS.

The spawned command looks like:

pwsh -NoExit -WorkingDirectory '/Users/user' -Command '$global:PowerShellMCPProxyPid = 78022; $global:PowerShellMCPAgentId = ''default''; Import-Module PowerShell.MCP -Force; Remove-Module PSReadLine -ErrorAction SilentlyContinue'

The ''default'' is interpreted by bash/zsh as:

  1. '' → empty string
  2. default → executed as a bare command
  3. '' → empty string

Result:

default: The term 'default' is not recognized as a name of a cmdlet, function, script file, or executable program.

The module partially loads but the $global:PowerShellMCPAgentId is never set correctly, the IPC back to the proxy fails, and the MCP connection drops.

Environment

  • macOS: Sequoia 15.5, Darwin 24.6.0, ARM64 (Mac Mini M4)
  • pwsh: 7.5.2 (Core), installed via .pkg at /usr/local/bin/pwsh
  • Shell: zsh 5.9
  • Terminal: Terminal.app
  • Claude Code: CLI (latest)
  • PowerShell.MCP: Tested 1.6.8, 1.7.2, and 1.7.6 — all affected

Steps to Reproduce

  1. Install PowerShell.MCP on macOS ARM64
  2. Register as MCP server in Claude Code: claude mcp add PowerShell /path/to/PowerShell.MCP.Proxy
  3. Launch Claude Code
  4. MCP shows "Connected" briefly, then tools become unavailable
  5. A Terminal.app window opens with the default: The term 'default' is not recognized error

Expected Behavior

The proxy should correctly quote the -Command argument so that $global:PowerShellMCPAgentId is set to 'default' and the module initializes properly.

Suggested Fix

Same as #39 — use -EncodedCommand with Base64-encoded UTF-16LE to avoid shell quoting issues entirely. The fix in #39 was applied to the Linux launcher (PwshLauncherLinux.cs) but the macOS launcher still uses the broken '' quoting.

Alternatively, the command could be written to a temp .ps1 file and executed with -File.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions