Merge remote-tracking branch 'origin/farm/960c6137/hide-mcp-cmd-windows'

This commit is contained in:
can1357
2026-06-26 09:19:04 +02:00
3 changed files with 37 additions and 2 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Fixed Windows stdio MCP server launches showing a separate `cmd.exe` window for direct executable servers; MCP subprocesses now set `windowsHide` on every Windows spawn path. ([#3535](https://github.com/can1357/oh-my-pi/issues/3535))
## [16.1.21] - 2026-06-26
### Fixed
@@ -0,0 +1,28 @@
import { describe, expect, it } from "bun:test";
import { resolveStdioSpawnCommand } from "./stdio";
describe("resolveStdioSpawnCommand", () => {
it("hides direct Windows executable MCP servers", async () => {
await expect(
resolveStdioSpawnCommand(
{ command: "server.exe", args: ["--stdio"] },
{ cwd: process.cwd(), env: {}, platform: "win32" },
),
).resolves.toEqual({
cmd: ["server.exe", "--stdio"],
windowsHide: true,
});
});
it("keeps off-Windows spawn options unchanged", async () => {
await expect(
resolveStdioSpawnCommand(
{ command: "server.exe", args: ["--stdio"] },
{ cwd: process.cwd(), env: {}, platform: "linux" },
),
).resolves.toEqual({
cmd: ["server.exe", "--stdio"],
});
});
});
@@ -239,12 +239,15 @@ export async function resolveStdioSpawnCommand(
// Direct-spawn only when we resolved to a concrete file AND its extension
// is not a batch script. Everything else (resolved .cmd/.bat, or an
// unresolved extensionless command) goes through cmd.exe so PATHEXT runs.
// Every Windows stdio server launch hides its console window; otherwise
// direct .exe servers pop a visible cmd window while the MCP server lives.
const windowsHide = true;
const needsCmdExe = resolved === null || isWindowsBatchCommand(resolvedCommand);
if (!needsCmdExe) return { cmd: [resolvedCommand, ...args] };
if (!needsCmdExe) return { cmd: [resolvedCommand, ...args], windowsHide };
return {
cmd: [resolveComSpec(options.env), "/d", "/s", "/c", buildCmdExeCommand(resolvedCommand, args)],
windowsHide: true,
windowsHide,
};
}