Skip to content

[Bug] PowerShell MCP clear prefix corrupts consecutive commands #3252

Description

@JasonWenTheFox

Operating system

macOS

Netcatty version

1.1.82

How did you install Netcatty?

GitHub Release (.dmg / .exe / .AppImage / .deb / .rpm / .pacman)

Affected area

SSH connection / terminal; AI assistant

Can you reproduce it?

Always (100%)

Steps to reproduce

  1. On macOS, connect Netcatty 1.1.82 to a Windows OpenSSH host whose registry DefaultShell is unset (so the login shell is cmd.exe).
  2. Configure the host startup command to launch pwsh.exe -NoLogo. Wait for the default PS C:\\...> prompt. The reproduced host used Windows OpenSSH 9.5.6.1 and PowerShell 7.6.5.
  3. Attach External MCP to that already-open terminal session.
  4. Call terminal_execute with Write-Output 'PROBE_1'.
  5. Call terminal_execute again with Write-Output 'PROBE_2'.

Expected behavior

Both commands should execute with the PowerShell wrapper, return only their requested output, and leave the interactive SSH tab connected at a clean PowerShell prompt.

Actual behavior

The first call prints PROBE_1 and reports exit code 0, but also emits a CommandNotFoundException for an empty command. The second call falls back to the cmd.exe wrapper even though the live shell is still PowerShell. PowerShell enters the >> continuation prompt, reports Missing closing ')' in expression, and terminal_execute times out after 60 seconds with exit code -1. The terminal tab then disappears from the External MCP scope.

This is a remaining case after #2959/#2960: the probed login-shell hint is cmd, while a host startup command moves the interactive PTY into PowerShell.

Isolation results:

  • Typing the current PowerShell wrapper body directly in the same terminal succeeds without the extra error.
  • Sending the current PowerShell pending-input clear sequence (Escape, Ctrl+U, Ctrl+K) before a simple command reproduces the empty-command error. On this PSReadLine configuration the control keys are not a safe universal line-clear sequence.
  • Ordinary UI-entered PowerShell commands work, so the SSH transport and PowerShell session are healthy outside MCP injection.

Logs / screenshots

Redacted External MCP output from the second call:

... set "SYSTEMD_PAGER=" ... call cmd /d /s /c ...
>>
ParserError:
Missing closing ')' in expression.
PS C:\\Users\\redacted>
>>
[exit code: -1]
[error] Command timed out (60s)

Relevant current code:

  • electron/bridges/ai/ptyExecHelpers.cjs: buildPendingInputClearPrefix("powershell") returns Escape + Ctrl+U + Ctrl+K.
  • electron/bridges/ai/ptyExec.cjs: startPtyJob prepends that sequence even when expectedPrompt already proves a clean idle prompt.

Before submitting

  • I searched existing issues and did not find a duplicate
  • I removed passwords, private keys, host addresses, usernames, session IDs, and other secrets from this report

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriageTouched by Cursor automationtriage:admittedReserved for serialized automatic issue triage admissiontriage:bug-readyConfirmed Netcatty bug ready for automatic implementation

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions