From 6898b220c775b6453c55b1f8269f082d977dd85f Mon Sep 17 00:00:00 2001 From: JiangNan <1394485448@qq.com> Date: Sat, 7 Mar 2026 12:39:59 +0800 Subject: [PATCH 1/2] fix(stdio): always set windowsHide on Windows, not just in Electron The windowsHide spawn option was only enabled for Electron apps, causing an empty cmd.exe console window to appear when launching MCP servers from non-Electron Node.js applications on Windows. Since windowsHide is a no-op on non-Windows platforms, just set it to true unconditionally. Also removes the now-unused isElectron() helper. Fixes #1638 --- src/client/stdio.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/client/stdio.ts b/src/client/stdio.ts index e488dcd24..43a2abb55 100644 --- a/src/client/stdio.ts +++ b/src/client/stdio.ts @@ -125,7 +125,9 @@ export class StdioClientTransport implements Transport { }, stdio: ['pipe', 'pipe', this._serverParams.stderr ?? 'inherit'], shell: false, - windowsHide: process.platform === 'win32' && isElectron(), + // Always hide the console window on Windows, not just in Electron. + // The option is a no-op on other platforms. + windowsHide: true, cwd: this._serverParams.cwd }); @@ -257,7 +259,3 @@ export class StdioClientTransport implements Transport { }); } } - -function isElectron() { - return 'type' in process; -} From 3041e0d7efe9a01c1bc57d8b04c9b70f375e5689 Mon Sep 17 00:00:00 2001 From: JiangNan <1394485448@qq.com> Date: Sun, 8 Mar 2026 05:03:11 +0800 Subject: [PATCH 2/2] add changeset for windowsHide fix --- .changeset/fix-stdio-windows-hide.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-stdio-windows-hide.md diff --git a/.changeset/fix-stdio-windows-hide.md b/.changeset/fix-stdio-windows-hide.md new file mode 100644 index 000000000..250e0a45d --- /dev/null +++ b/.changeset/fix-stdio-windows-hide.md @@ -0,0 +1,5 @@ +--- +'@modelcontextprotocol/sdk': patch +--- + +Always set windowsHide to true when spawning stdio server processes on Windows, not just in Electron environments.