Summary
The Windows branch of DEFAULT_INHERITED_ENV_VARS in src/client/stdio.ts is missing several variables that Windows needs to resolve and execute common commands. As a result, MCP servers that try to spawn npm, git, .bat/.cmd files, or use cmd.exe features can fail in non-obvious ways even when PATH is correctly inherited.
Current state
src/client/stdio.ts (identical on main):
export const DEFAULT_INHERITED_ENV_VARS =
process.platform === 'win32'
? [
'APPDATA', 'HOMEDRIVE', 'HOMEPATH', 'LOCALAPPDATA',
'PATH', 'PROCESSOR_ARCHITECTURE', 'SYSTEMDRIVE',
'SYSTEMROOT', 'TEMP', 'USERNAME', 'USERPROFILE',
'PROGRAMFILES'
]
: ['HOME', 'LOGNAME', 'PATH', 'SHELL', 'TERM', 'USER'];
Missing variables
PATHEXT — Windows uses this to determine which file extensions count as executable when resolving a bare command name. Without it, spawning npm, git, or any .cmd/.bat shim by name fails with ENOENT even when PATH is set correctly.
COMSPEC — Path to cmd.exe. Required by Node's child_process.spawn({ shell: true }), by npm run scripts internally, and by anything that shells out via cmd.exe.
PROGRAMFILES(X86) — 32-bit Program Files path on 64-bit Windows. Tools that probe both paths get inconsistent results when only one is inherited.
PROGRAMW6432 — Resolves to the 64-bit Program Files path even from 32-bit processes.
WINDIR — Path to the Windows directory. Used as a fallback by some legacy tooling and PowerShell modules.
Proposed change
Add these five variables to the Windows branch of DEFAULT_INHERITED_ENV_VARS. They're non-secret, system-defined, and pose no privacy or security concern beyond what's already inherited (PATH, SYSTEMROOT, etc.).
The same gap exists on both main and v1.x.
Summary
The Windows branch of
DEFAULT_INHERITED_ENV_VARSinsrc/client/stdio.tsis missing several variables that Windows needs to resolve and execute common commands. As a result, MCP servers that try to spawnnpm,git,.bat/.cmdfiles, or usecmd.exefeatures can fail in non-obvious ways even whenPATHis correctly inherited.Current state
src/client/stdio.ts(identical onmain):Missing variables
PATHEXT— Windows uses this to determine which file extensions count as executable when resolving a bare command name. Without it, spawningnpm,git, or any.cmd/.batshim by name fails withENOENTeven whenPATHis set correctly.COMSPEC— Path tocmd.exe. Required by Node'schild_process.spawn({ shell: true }), bynpm runscripts internally, and by anything that shells out viacmd.exe.PROGRAMFILES(X86)— 32-bit Program Files path on 64-bit Windows. Tools that probe both paths get inconsistent results when only one is inherited.PROGRAMW6432— Resolves to the 64-bit Program Files path even from 32-bit processes.WINDIR— Path to the Windows directory. Used as a fallback by some legacy tooling and PowerShell modules.Proposed change
Add these five variables to the Windows branch of
DEFAULT_INHERITED_ENV_VARS. They're non-secret, system-defined, and pose no privacy or security concern beyond what's already inherited (PATH, SYSTEMROOT, etc.).The same gap exists on both
mainandv1.x.