modelcontextprotocol / modelcontextprotocol/typescript-sdk
DEFAULT_INHERITED_ENV_VARS
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 13.4k
- Forks
- 2.2k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 4
Description
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, 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 main and v1.x.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/client/stdio.ts, especially the Windows branch of DEFAULT_INHERITED_ENV_VARS. Review how the inherited environment is used when spawning MCP servers, then add PATHEXT, COMSPEC, PROGRAMFILES(X86), PROGRAMW6432, and WINDIR to both main and v1.x as applicable. Done means the Windows environment includes all five variables without changing the non-Windows list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100