Skip to content

fix(client): add missing Windows env vars to DEFAULT_INHERITED_ENV_VARS#2043

Open
ChrisJr404 wants to merge 1 commit into
modelcontextprotocol:mainfrom
ChrisJr404:fix-default-inherited-env-vars-windows
Open

fix(client): add missing Windows env vars to DEFAULT_INHERITED_ENV_VARS#2043
ChrisJr404 wants to merge 1 commit into
modelcontextprotocol:mainfrom
ChrisJr404:fix-default-inherited-env-vars-windows

Conversation

@ChrisJr404
Copy link
Copy Markdown

Closes #2037.

On Windows, DEFAULT_INHERITED_ENV_VARS is missing a few variables that common dev tooling needs. The most impactful one is PATHEXT: without it, spawn('npm', ...) (and git, python, anything else that ships as .cmd/.exe/.bat) fails with ENOENT even when PATH is set, because Node has no extensions to try.

Added to the win32 branch:

  • PATHEXT — extensions Windows treats as executable. Fix for the spawn npm ENOENT symptom in the issue.
  • COMSPEC — path to cmd.exe; needed by spawn({ shell: true }) and anything that shells out.
  • PROGRAMFILES(X86) and PROGRAMW6432 — the other two Program Files paths. Tools that resolve install locations need at least one of these depending on whether the parent is 32-bit or 64-bit.
  • WINDIR — used by some legacy tooling that doesn't accept SYSTEMROOT.

Also sorted the array so future additions are easier to eyeball.

Test

Added a small assertion in stdio.test.ts that pins the expected list per platform, so a regression on either branch fails locally. pnpm test is green (365/365) and pnpm lint/pnpm typecheck are clean.

Changeset included as a patch bump on @modelcontextprotocol/client.

Without PATHEXT, spawning common tools like npm or git from a stdio
MCP server fails with ENOENT on Windows because Node can't resolve
the .cmd/.exe extension. COMSPEC is required by shell-based spawns.
PROGRAMFILES(X86), PROGRAMW6432, and WINDIR are commonly needed by
Windows tooling that resolves install paths or system binaries.

Closes modelcontextprotocol#2037

Signed-off-by: ChrisJr404 <chris@hacknow.com>
@ChrisJr404 ChrisJr404 requested a review from a team as a code owner May 11, 2026 13:55
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 11, 2026

🦋 Changeset detected

Latest commit: 8ebeb0d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 11, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2043

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2043

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2043

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2043

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2043

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2043

commit: 8ebeb0d

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEFAULT_INHERITED_ENV_VARS

1 participant