fix(client): add missing Windows env vars to DEFAULT_INHERITED_ENV_VARS#2043
Open
ChrisJr404 wants to merge 1 commit into
Open
fix(client): add missing Windows env vars to DEFAULT_INHERITED_ENV_VARS#2043ChrisJr404 wants to merge 1 commit into
ChrisJr404 wants to merge 1 commit into
Conversation
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>
🦋 Changeset detectedLatest commit: 8ebeb0d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2037.
On Windows,
DEFAULT_INHERITED_ENV_VARSis missing a few variables that common dev tooling needs. The most impactful one isPATHEXT: without it,spawn('npm', ...)(andgit,python, anything else that ships as.cmd/.exe/.bat) fails withENOENTeven whenPATHis set, because Node has no extensions to try.Added to the win32 branch:
PATHEXT— extensions Windows treats as executable. Fix for thespawn npm ENOENTsymptom in the issue.COMSPEC— path tocmd.exe; needed byspawn({ shell: true })and anything that shells out.PROGRAMFILES(X86)andPROGRAMW6432— 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 acceptSYSTEMROOT.Also sorted the array so future additions are easier to eyeball.
Test
Added a small assertion in
stdio.test.tsthat pins the expected list per platform, so a regression on either branch fails locally.pnpm testis green (365/365) andpnpm lint/pnpm typecheckare clean.Changeset included as a patch bump on
@modelcontextprotocol/client.