Repository navigation
mcp: use URI-backed defaultCwd for home-directory discovery adapters - #345650
Merged
Connor Peet (connor4312) merged 1 commit intoNov 5, 2026
Merged
Connor Peet (connor4312) merged 1 commit into
Connor Peet (connor4312) merged 1 commit into
Conversation
The Claude Desktop, Copilot, Cursor and Windsurf discovery adapters set the stdio launch cwd from homedir.fsPath on the client. On a Windows client connected to a Linux remote this produced a Windows-style path, making spawn fail with ENOENT. Pass the home directory as defaultCwd instead so the extension host resolves it; the cache nonce is unchanged so existing trust is preserved. Fixes microsoft#345646
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change preserving remote home-directory URIs during MCP discovery.
No open issues 🎉
What changed in this PR
Fixes home-directory MCP discovery on Windows clients connected to Linux remotes by preserving the default working directory as a URI until the extension host resolves it.
Changes:
- Uses
defaultCwdfor Claude Desktop, Copilot, Cursor, and Windsurf discovery, following the existing workspace discovery approach. - Adds regression coverage for all four adapters, checking URI preservation, unchanged trust nonces, and unaffected HTTP definitions.
| File | Description |
|---|---|
src/vs/workbench/contrib/mcp/test/common/nativeMcpDiscoveryAdapters.test.ts |
Tests remote home-directory handling and trust nonce compatibility across all four adapters. |
src/vs/workbench/contrib/mcp/common/discovery/nativeMcpDiscoveryAdapters.ts |
Replaces client-resolved cwd with URI-backed defaultCwd. |
Review effort: Balanced
Connor Peet (connor4312)
approved these changes
Nov 5, 2026
Connor Peet (connor4312)
enabled auto-merge
November 5, 2026 21:37
Vijay Upadya (vijayupadya)
approved these changes
Nov 5, 2026
Ben Villalobos (benvillalobos)
approved these changes
Nov 5, 2026
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 #345646
The Claude Desktop, Copilot, Cursor and Windsurf native discovery adapters passed
{ cwd: homedir }toclaudeConfigToServerDefinition, which sets the stdiolaunch.cwdtohomedir.fsPathon the client. On a Windows client connected to a Linux remote (e.g. WSL), this yields a Windows-style path (\home\<user>), andspawnon the Linux extension host fails withENOENT.This passes
{ defaultCwd: homedir }instead, the same approach #330223 took for workspace.mcp.json. The cwd stays a URI and is resolved by the extension host. The cache nonce is still computed fromdefaultCwd.fsPath, so existing trust decisions are preserved.A per-entry
cwdin these files is still not read; that's unchanged and out of scope.Testing
vscode-remote://home: stdio servers get nolaunch.cwd,defaultCwdis the home URI, and the nonce matches the previous behavior. The test fails without the fix.node test/unit/node/index.js --run src/vs/workbench/contrib/mcp/test/common/nativeMcpDiscoveryAdapters.test.ts: 13 passing.