[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
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=1is set in~/.claude/settings.jsonpowershell.exe(5.1) is confirmed atC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeand accessible from the process PATHpowershell.exe -Command "..."works fine via theBashtool
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.exe5.1 atC:\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
- Install Git for Windows (Git Bash)
- Install Claude Desktop with
claude-codeMCP server configured inclaude_desktop_config.json - Set
CLAUDE_CODE_USE_POWERSHELL_TOOL=1in~/.claude/settings.json - Restart Claude Desktop
- Call
claude-code:PowerShelltool 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 serveprocess PATH in Git Bash context:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32:/c/Windows which powershellfrom the Bash process returns:/c/Windows/System32/WindowsPowerShell/v1.0/powershellpowershell.exe -Command "Write-Output test"from Bash returnstestsuccessfully- Tried adding
defaultShell: "powershell"tosettings.json— no effect - Tried various PATH configurations in
claude_desktop_config.jsonenv — 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"
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗