Conversation
… any casing on Windows Fixes modelcontextprotocol#2859. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: c99b0b2 The changes in this PR will be included in the next version bump. 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 |
commit: |
This branch has not been deployed
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.
Fixes #2859.
On Windows, environment variable names are case-insensitive, but StdioClientTransport builds the child env with a plain object spread:
getDefaultEnvironment() stores the inherited value under
PATH. If the caller passesPath, the spread keeps both keys, and the child ends up with the inherited PATH instead of the one the caller configured.This change routes the merge through a small private helper. On win32 it skips an inherited default whenever
envalready has the same name in any casing, then appliesenvon top. On every other platform it is the same spread as before. getDefaultEnvironment() and DEFAULT_INHERITED_ENV_VARS are unchanged.A side effect of the old behaviour: cross-spawn already resolved
commandwith the explicitPath(path-key picks the last matching key), but the child then ran with the inheritedPATH, so the command was found with one PATH and run with the other. With this change both use the caller's value.The Windows casing half mirrors a fix merged this week in the Vercel AI SDK's MCP client, vercel/ai#21435.
Tests:
env: { Path: 'C:\\explicit-only' }, the spawned env equals every other inherited default plusPath, so it also fails if the merge ever drops the rest of the defaults. A second test pins the non-Windows behaviour: keys stay case-sensitive and the result is the plain spread.C:\explicit-only.Both win32 tests fail on v1.x without the source change and pass with it (Windows 11, Node 24.12.0). npm run lint and npm run typecheck pass. Added a patch changeset.
One note for Windows runs: the existing
morebased tests in test/client/stdio.test.ts log 2 unhandled "Unexpected end of JSON input" errors. That happens on v1.x without this change too, so I left it alone.main has the same merge in packages/client/src/client/stdio.ts. Happy to send a port there as well if you want it.
🤖 Generated with Claude Code