GitHub Issue Draft: DesktopCommanderMCP pwsh stdout
Repo: wonderwhy-er/DesktopCommanderMCP
Title: start_process captures no stdout from external executables when defaultShell is pwsh.exe
Description
When defaultShell is set to pwsh.exe (PowerShell 7.5.4), start_process
captures zero stdout lines from any external executable (python, git, node,
etc.). The process exits with code 0 but all output is lost. Only pwsh-native
commands (Write-Output, echo) produce captured output.
Switching back to powershell.exe (5.1) immediately restores stdout capture
for all external executables.
Environment
- DC version: 0.2.38 (DXT/Electron)
- OS: Windows 11
- Node.js: 25.7.0
- pwsh: 7.5.4 (.NET 8)
- powershell.exe: 5.1.x
- Python: 3.14.3
- Git: 2.53.0
Steps to Reproduce
set_config_value defaultShell to pwsh.exe
start_process with python -c "print('hello')"
- Observe: PID assigned,
(shell: pwsh.exe) shown, but Initial output is empty
read_process_output: 0 lines, exit code 0
set_config_value defaultShell back to powershell.exe
- Same command: output captured normally
Test Matrix
| Command |
defaultShell |
Captured? |
echo "test" (native) |
pwsh.exe |
YES |
Write-Output "test" |
pwsh.exe |
YES |
python -c "print('hello')" |
pwsh.exe |
NO - 0 lines, exit 0 |
& python -c "print('hello')" |
pwsh.exe |
NO - 0 lines, exit 0 |
git --version |
pwsh.exe |
NO - 0 lines, exit 0 |
python -c "import sys; print('hello'); sys.stdout.flush()" |
pwsh.exe |
NO |
$out = python -c "print('hello')"; Write-Output $out |
pwsh.exe |
NO |
python -c "print('hello')" |
powershell.exe |
YES |
git --version |
powershell.exe |
YES |
Key observation: A visible python.exe console window appears on the
desktop during pwsh tests, suggesting stdout is routed to a detached console
rather than DC's capture pipe.
Patches Attempted
Patch 1: Remove -Login flag
getShellSpawnArgs() uses ['-Login', '-Command', command] for pwsh.
Removed -Login so args become ['-Command', command].
Result: No fix. External exe stdout still not captured.
Patch 2: shell option + explicit stdio
Changed from spawn('pwsh.exe', ['-Command', cmd]) to
spawn(cmd, [], { shell: 'pwsh.exe', stdio: ['pipe','pipe','pipe'] }).
Result: npx cache regenerated on restart, wiping patch. Even if preserved,
the architectural issue likely remains.
Analysis
The issue appears to be in how Node.js child_process.spawn() handles stdio
inheritance differently for pwsh.exe vs powershell.exe:
- powershell.exe (native Windows console host): Child processes inherit
DC's stdio pipes correctly. stdout flows back through Node.js to DC.
- pwsh.exe (.NET 8 app): Child processes appear to get a new console
allocation instead of inheriting pipes. stdout goes to the visible console
window, not back to DC.
This may relate to:
- .NET 8 runtime allocating its own console via
AllocConsole()
- Differences in how
CreateProcess handles STARTUPINFO for .NET vs native
executables
- Node.js spawn not setting
CREATE_NO_WINDOW or DETACHED_PROCESS flags
appropriately for .NET-based shells
Workaround
Using powershell.exe (5.1) as defaultShell. This has its own issues
(UTF-8 BOM injection in pipes, UTF-16LE encoding in redirects) but stdout
capture works reliably for all external executables.
Suggested Fix
The getShellSpawnArgs() function in terminal-manager.js may need
platform-specific spawn options for pwsh.exe on Windows, such as:
- Explicit
windowsHide: true in spawn options
CREATE_NO_WINDOW process creation flag
- Different stdio configuration for .NET-based shells
GitHub Issue Draft: DesktopCommanderMCP pwsh stdout
Repo: wonderwhy-er/DesktopCommanderMCP
Title:
start_processcaptures no stdout from external executables when defaultShell is pwsh.exeDescription
When
defaultShellis set topwsh.exe(PowerShell 7.5.4),start_processcaptures zero stdout lines from any external executable (python, git, node,
etc.). The process exits with code 0 but all output is lost. Only pwsh-native
commands (Write-Output, echo) produce captured output.
Switching back to
powershell.exe(5.1) immediately restores stdout capturefor all external executables.
Environment
Steps to Reproduce
set_config_valuedefaultShell topwsh.exestart_processwithpython -c "print('hello')"(shell: pwsh.exe)shown, but Initial output is emptyread_process_output: 0 lines, exit code 0set_config_valuedefaultShell back topowershell.exeTest Matrix
echo "test"(native)Write-Output "test"python -c "print('hello')"& python -c "print('hello')"git --versionpython -c "import sys; print('hello'); sys.stdout.flush()"$out = python -c "print('hello')"; Write-Output $outpython -c "print('hello')"git --versionKey observation: A visible
python.execonsole window appears on thedesktop during pwsh tests, suggesting stdout is routed to a detached console
rather than DC's capture pipe.
Patches Attempted
Patch 1: Remove -Login flag
getShellSpawnArgs()uses['-Login', '-Command', command]for pwsh.Removed
-Loginso args become['-Command', command].Result: No fix. External exe stdout still not captured.
Patch 2: shell option + explicit stdio
Changed from
spawn('pwsh.exe', ['-Command', cmd])tospawn(cmd, [], { shell: 'pwsh.exe', stdio: ['pipe','pipe','pipe'] }).Result: npx cache regenerated on restart, wiping patch. Even if preserved,
the architectural issue likely remains.
Analysis
The issue appears to be in how Node.js
child_process.spawn()handles stdioinheritance differently for pwsh.exe vs powershell.exe:
DC's stdio pipes correctly. stdout flows back through Node.js to DC.
allocation instead of inheriting pipes. stdout goes to the visible console
window, not back to DC.
This may relate to:
AllocConsole()CreateProcesshandlesSTARTUPINFOfor .NET vs nativeexecutables
CREATE_NO_WINDOWorDETACHED_PROCESSflagsappropriately for .NET-based shells
Workaround
Using
powershell.exe(5.1) as defaultShell. This has its own issues(UTF-8 BOM injection in pipes, UTF-16LE encoding in redirects) but stdout
capture works reliably for all external executables.
Suggested Fix
The
getShellSpawnArgs()function interminal-manager.jsmay needplatform-specific spawn options for pwsh.exe on Windows, such as:
windowsHide: truein spawn optionsCREATE_NO_WINDOWprocess creation flag