[BUG] PowerShell tool reports "PowerShell is not available on this system" when running as MCP server (mcp serve mode) on Windows with Git Bash installed

Resolved 💬 3 comments Opened May 2, 2026 by kimysseojinsys Closed May 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

When claude.exe runs in mcp serve mode (as an MCP server for Claude Desktop), the PowerShell tool always fails with "PowerShell is not available on this system" — even though:

  • CLAUDE_CODE_USE_POWERSHELL_TOOL=1 is set in ~/.claude/settings.json
  • powershell.exe (5.1) is confirmed at C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe and accessible from the process PATH
  • powershell.exe -Command "..." works fine via the Bash tool

What Should Happen?

claude-code:PowerShell tool should execute PowerShell commands successfully.

Environment

  • Claude Code version: 2.1.123 (C:\Users\Admin\.local\bin\claude.exe)
  • MCP server binary: 2.1.121 (AppData\Roaming\Claude\claude-code\2.1.121\claude.exe)
  • OS: Windows 10 (native, not WSL)
  • Shell: Git Bash (Git for Windows installed)
  • PowerShell available: powershell.exe 5.1 at C:\Windows\System32\WindowsPowerShell\v1.0\
  • PowerShell 7: Installed via Microsoft Store (App Execution Alias only — C:\Users\Admin\AppData\Local\Microsoft\WindowsApps\pwsh.exe, Length=0, ReparsePoint)

Root Cause Analysis (via binary inspection)

Inspected claude.exe binary and identified the PowerShell detection function uT9():

async function uT9() {
  let H = await RY("pwsh");
  if (H) { /* linux snap check */ return H; }
  let q = await RY("powershell");
  if (q) return q;
  return null;
}

And PT7() which checks stat().isFile():

async function PT7(H) {
  try { return (await fs.stat(H)).isFile() ? H : null; }
  catch { return null; }
}

Problem: RY("pwsh") finds C:\Users\Admin\AppData\Local\Microsoft\WindowsApps\pwsh.exe, but this is a Windows App Execution Alias (a ReparsePoint stub with Length=0). stat().isFile() returns false, so it is rejected.

Then RY("powershell") should fall back to powershell.exe 5.1, but this also fails in the mcp serve process context. The exact reason RY("powershell") fails is unclear — Node.js simulation (node.exe) finds it correctly via PATH, but the MCP server process apparently does not.

Steps to Reproduce

  1. Install Git for Windows (Git Bash)
  2. Install Claude Desktop with claude-code MCP server configured in claude_desktop_config.json
  3. Set CLAUDE_CODE_USE_POWERSHELL_TOOL=1 in ~/.claude/settings.json
  4. Restart Claude Desktop
  5. Call claude-code:PowerShell tool with any command

Actual Behavior

PowerShell is not available on this system.

Expected Behavior

PowerShell command executes successfully.

Workaround

Using claude-code:Bash with powershell.exe -NoProfile -Command "..." works correctly. However, this requires wrapping every PowerShell command.

Additional Context

  • The mcp serve process PATH in Git Bash context: /c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32:/c/Windows
  • which powershell from the Bash process returns: /c/Windows/System32/WindowsPowerShell/v1.0/powershell
  • powershell.exe -Command "Write-Output test" from Bash returns test successfully
  • Tried adding defaultShell: "powershell" to settings.json — no effect
  • Tried various PATH configurations in claude_desktop_config.json env — no effect
  • Microsoft Store PowerShell 7 App Execution Alias detection issue may be related to: the changelog entry "Windows: PowerShell 7 installed via the Microsoft Store, MSI without PATH, or .NET global tool is now detected"

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗