Fix Windows PATH registry reading and cmd.exe escaping for Issue #302#304
Open
Fix Windows PATH registry reading and cmd.exe escaping for Issue #302#304
Conversation
Closes #303 — documents the key difference that Antigravity uses `serverUrl` instead of `url` for HTTP MCP servers, with config paths for Windows, macOS, and Linux. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Problem: MCP servers fail on Windows with 'uv is not recognized' when launched via installer without inheriting user's PATH. Solution 1 - Registry PATH Reading: - Read HKEY_CURRENT_USER\Environment\Path (user PATH) - Read HKEY_LOCAL_MACHINE\...\Environment\Path (system PATH) - Expand variables (%USERPROFILE%, %APPDATA%, etc.) - Recovers 28-34 directories vs 4-7 before Solution 2 - Spaces in Paths: - Fixed cmd.exe escaping (removed incorrect backslash escaping) - Auto-strips user-added quotes from paths - Paths with spaces now work correctly Files: - internal/secureenv/manager_windows.go (NEW) - internal/secureenv/manager_unix.go (NEW) - internal/secureenv/manager_windows_test.go (NEW) - internal/secureenv/manager.go (MODIFIED) - internal/upstream/core/connection_stdio.go (MODIFIED) Test Results: - TestReadWindowsRegistryPath: 34 directories from registry - TestDiscoverWindowsPathsWithEmptyEnvironment: 28 paths - All unit tests passing Fixes #302 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ExpandEnv
os.ExpandEnv only handles $VAR/${VAR} syntax, not Windows %VAR%.
Registry PATH entries use %USERPROFILE%, %APPDATA% etc. which were
left unexpanded, causing os.Stat to fail and paths to be filtered out.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Deploying mcpproxy-docs with
|
| Latest commit: |
9a7bb08
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://18b90941.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-windows-path-registry-is.mcpproxy-docs.pages.dev |
On Windows, installer/service launches inherit minimal PATH (just System32). The registry-discovered paths should always be used to enhance the PATH in this scenario, without requiring the explicit EnhancePath opt-in that was designed for macOS Launchd. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The TestManagerBuildSecureEnvironmentWithRegistryPaths test was using default config (EnhancePath=false) but expected PATH enhancement. In production, core/client.go always sets EnhancePath=true. Reverted the blanket Windows enhancement and fixed the test to match production. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 22021452480 --repo smart-mcp-proxy/mcpproxy-go
|
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.
Problem
MCP servers fail on Windows with
'uv' is not recognized as an internal or external commandwhen mcpproxy is launched via installer/auto-start without inheriting the user's PATH environment variable.Reported in: #302
Root Cause
mcpproxy-traywith minimal PATH (C:\Windows\System32).cargo\bin,go\bin, etc.) were not foundSolution
1. Windows Registry PATH Reading ✅
Implemented automatic reading of user PATH from Windows registry:
HKEY_CURRENT_USER\Environment\Path(user-specific PATH)HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path(system PATH)%USERPROFILE%,%APPDATA%, etc.)2. cmd.exe Escaping Fix ✅
Fixed command escaping for paths with spaces:
\") which doesn't work in cmd.exeChanges
New Files
internal/secureenv/manager_windows.go- Windows registry PATH reading (89 lines)internal/secureenv/manager_unix.go- Unix stub (11 lines)internal/secureenv/manager_windows_test.go- Unit tests (201 lines)Modified Files
internal/secureenv/manager.go- Registry reading integrationinternal/upstream/core/connection_stdio.go- cmd.exe escaping fixTotal: 351 lines added/modified across 5 files
Test Results
Unit Tests ✅
Impact
uvnot found ❌uvfound in.cargo\bin✅.cargo\binnever found ❌Platform Compatibility
-lflag ✅Performance
This PR makes Windows a first-class citizen for mcpproxy! 🎉
Windows users can now use MCP servers with tools in user directories (Rust, Go, Python, Node.js) without manual PATH configuration.
Fixes #302