Repository navigation
fix(config): drop blocking uvx preflight and realign fork-only helpers with upstream - #11
Conversation
…s with upstream - Replace the stdio preflight (a synchronous `uvx ... --help` run with a 60s timeout on the main thread) with a path-only check for Windows .bat/.cmd shims. Upstream's StartupConfigRewrite calls the config write path for every stale client on Editor startup, so the probe could stall startup by up to 60s per client. - Remove the auto-injected `uvx --system-certs` flag and its UseSystemCertificates pref. The pref had no UI, the decision depended on the Editor's environment at configure time, and uv builds that predate the flag reject it outright. UV_SYSTEM_CERTS covers the same need and older uv ignores it. - Fix QuoteCommandLineArg doubling every backslash; only runs before a quote are escaped under Windows argv rules. - Restore upstream PathResolverService/IPathResolverService: shim discovery, the unused ResolvedUvxIsShim/IsShimPath members and the uncalled IsPythonDetected change are gone (upstream CoplayDev#1324 covers pyenv-win). - Remove BackupStaleClientConfigIfNeeded and the duplicate shim guard in RegisterWithCapturedValues (its only caller already checks). - Skill sync reads .claude/skills/unity-mcp-skill again, matching upstream now that CoplayDev#1442 merged the two skill copies; drop the fallback directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3ef3398084
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| string[] commandNames = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) | ||
| ? new[] { "uvx.exe", "uv.exe", "uvx.bat", "uvx.cmd", "uv.bat", "uv.cmd" } | ||
| ? new[] { "uvx.exe", "uv.exe" } | ||
| : new[] { "uvx", "uv" }; |
There was a problem hiding this comment.
Preserve batch shim paths so the safety check can reject them
On Windows installations where uv is available only through a pyenv-style uvx.bat/uv.cmd, restricting discovery to .exe files makes ResolveUvxFromSystem return null, after which GetUvxPath falls back to the bare string uvx. GetStdioShimError cannot recognize that bare command as a shim, so stdio configurators accept and persist it; the MCP client then resolves the same batch shim at launch and can misinterpret the mcpforunityserver>=0.0.0a0 argument. Continue resolving batch paths so they can be explicitly rejected, or avoid returning a bare command when only a shim is present.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 759f3c0. When no uvx.exe/uv.exe is found and pyenv-win cannot resolve the real executable, the resolver now returns the first uvx/uv .bat/.cmd shim on PATH (or in pyenv-win's shims folder) instead of letting GetUvxPath fall back to bare uvx, so GetStdioLauncherError rejects it explicitly. The lookup is a plain File.Exists scan, cached per domain together with the pyenv result. Covered by PathResolverPyenvTests.FindUvShim_*.
- Restore automatic TLS handling behind corporate proxies: when SSL_CERT_FILE, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE or NODE_EXTRA_CA_CERTS is set, the uvx launch args include --native-tls. The old flag name is used on purpose: current uv still accepts it (verified on 0.12.19), while uv builds that predate the --system-certs rename reject the new name. - On Windows, when no uvx.exe/uv.exe is found, resolve pyenv-win's uvx.bat / uv.bat shim to the real executable via `pyenv which` (cached per domain), so stdio configs get a launchable .exe instead of the bare "uvx" fallback. - The shim error now also suggests clearing an override that points at a pyenv-win shim. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 868cf8ef71
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!useStdio || !IsWindowsShellShimCommand(uvxPath)) | ||
| return null; |
There was a problem hiding this comment.
Reject null uvx paths before registering Claude
When an invalid uvx override is set and no system fallback exists, GetUvxPath() returns null, but this condition now returns no error. Both Claude registration paths therefore continue with an empty command; RegisterWithCapturedValues first removes registrations from every scope and then invokes claude mcp add ... -- "", which either leaves no registration or persists a broken one. Preserve the former missing-uvx check before allowing stdio registration.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 759f3c0. GetStdioShimError is now GetStdioLauncherError and returns "uv package manager not found" for a null/blank uvx path when writing stdio, so both Claude registration paths (the synchronous Register() and the UI pre-check before RegisterWithCapturedValues) stop before removing existing registrations. Covered by UvxLaunchArgsTests.GetStdioLauncherError_RejectsMissingUvx.
| // .claude/skills can drift (fewer reference files, stale SKILL.md) and is only a fallback. | ||
| private const string SkillSubdir = "unity-mcp-skill"; | ||
| private const string FallbackSkillSubdir = ".claude/skills/unity-mcp-skill"; | ||
| private const string SkillSubdir = ".claude/skills/unity-mcp-skill"; |
There was a problem hiding this comment.
Retain the top-level skill fallback for custom repositories
The installer exposes an editable Repo URL, so users can sync forks whose main or beta branch still contains only the previously canonical top-level unity-mcp-skill directory. Hard-coding the nested .claude copy makes both the GitHub API and sparse-clone paths report “Remote directory not found” for those otherwise compatible repositories; upstream merging the two copies does not update existing forks. Prefer the nested source if desired, but retain the top-level fallback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not adopting this one. .claude/skills/unity-mcp-skill was added on 2026-02-10 (CoplayDev#707), three weeks before SkillSyncService itself existed (2026-03-02, CoplayDev#845), and upstream has never had a top-level fallback in either the GitHub API or the sparse-clone path. A repo that has only the top-level copy would have to be a snapshot from the 2026-02-03..02-10 window, or a fork that deleted the nested copy. Re-adding a fallback to both paths for that case is not worth diverging from upstream again; the "Remote directory not found" error already names the missing path.
…"uvx" Addresses Codex review on #11: - When no uvx.exe/uv.exe is found and pyenv-win can't resolve one, return the first uvx/uv .bat/.cmd shim on PATH (or in pyenv-win's shims folder) instead of letting GetUvxPath fall back to bare "uvx". Stdio configurators then reject it with a clear message rather than persisting a command the MCP client would resolve to the same shim and run through cmd.exe. - GetStdioShimError -> GetStdioLauncherError, which also rejects a missing uvx (invalid override, no system fallback). Previously Claude registration removed existing registrations and then ran `claude mcp add ... -- ""`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 759f3c0ddb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| foreach (string name in CorporateCaEnvVars) | ||
| { | ||
| try | ||
| { | ||
| string value = Environment.GetEnvironmentVariable(name); | ||
| if (!string.IsNullOrEmpty(value)) | ||
| return true; | ||
| } | ||
| catch { } | ||
| if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(name))) | ||
| return new[] { "--native-tls" }; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the uvx system-cert flag arguments as a list. Empty when disabled. | ||
| /// </summary> | ||
| public static IReadOnlyList<string> GetSystemCertsArgsList() | ||
| { | ||
| return ShouldUseSystemCerts() ? new[] { "--system-certs" } : Array.Empty<string>(); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Returns the uvx system-cert flag as a trailing-space string, suitable for | ||
| /// concatenation into command-line builders (mirrors <see cref="GetUvxDevFlags()"/>). | ||
| /// </summary> | ||
| public static string GetSystemCertsArgs() | ||
| { | ||
| return ShouldUseSystemCerts() ? "--system-certs " : string.Empty; | ||
| return Array.Empty<string>(); |
There was a problem hiding this comment.
Preserve the explicit native-TLS override
When a corporate proxy's CA is installed only in the OS trust store, none of these environment variables is necessarily set. Users who previously selected MCPForUnity.UseSystemCertificates=always then lose their explicit override because this commit removes that preference and emits --native-tls only after environment-variable detection, causing uv package downloads to fail again in that environment. Retain the always/never preference behavior while emitting the backward-compatible flag.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 918e607. MCPForUnity.UseSystemCertificates is read again: always forces --native-tls, never suppresses it, anything else keeps the environment-variable auto-detection. The key name is unchanged so existing overrides keep working, and the emitted flag stays the backward-compatible --native-tls. Covered by UvxLaunchArgsTests.BuildUvxServerLaunchArgs_AlwaysOverride_* / _NeverOverride_*.
There was a problem hiding this comment.
Follow-up in 12a3d75: the flag is now chosen by uv version. uv 0.11 renamed --native-tls to --system-certs (deprecated alias, identical behavior per the 0.11.0 changelog). Users already running with --system-certs have uv >= 0.11, so they keep getting exactly --system-certs (configs stay byte-identical and survive the alias's eventual removal); only uv < 0.11 gets --native-tls. The version comes from TryValidateUvxExecutable, probed only when the flag is needed and cached per uvx path.
Addresses Codex review on #11: when a corporate proxy's CA lives only in the OS trust store, no environment variable reveals it, so auto-detection alone misses it. Read MCPForUnity.UseSystemCertificates again ("always"/"never", default auto-detect) and keep emitting the backward-compatible --native-tls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 918e607e16
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (string.IsNullOrWhiteSpace(uvxPath)) | ||
| return "uvx not found. Install uv/uvx or set the override in Advanced Settings."; | ||
|
|
||
| if (IsWindowsShellShimCommand(uvxPath)) | ||
| { | ||
| return "Refusing to write Unity MCP stdio config with a Windows batch shim. " + | ||
| $"Detected '{uvxPath}', which can corrupt arguments such as mcpforunityserver>=0.0.0a0. " + | ||
| "Install uv so a real uvx.exe/uv.exe is available, or set the uvx path override to the real executable."; | ||
| } | ||
|
|
||
| var args = new List<string>(AssetPathUtility.BuildUvxServerLaunchArgs(packageName, includeTransportStdio: false)) | ||
| { | ||
| "--help" | ||
| }; | ||
| string argsString = string.Join(" ", args.ConvertAll(AssetPathUtility.QuoteCommandLineArg)); | ||
|
|
||
| if (ExecPath.TryRun(uvxPath, argsString, null, out _, out string stderr, timeoutMs: 60000)) | ||
| return "uv package manager not found. Please install uv first."; | ||
| if (!IsWindowsShellShimCommand(uvxPath)) | ||
| return null; |
There was a problem hiding this comment.
Reject the unresolved bare uvx fallback
When no override is configured and system discovery finds neither uvx nor uv, PathResolverService.GetUvxPath() returns the bare string "uvx". This value is nonblank and is not a Windows shim, so this replacement for the executable preflight returns no error and stdio configurators persist a command that cannot launch; this can also overwrite an existing config during startup rewriting after uv has been removed. Treat the resolver's unresolved bare fallback as missing, or have the resolver return null when discovery fails.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not adopting this one. The bare uvx fallback is deliberate upstream behavior: Unity launched from the Hub/Dock often has a much narrower PATH than the MCP client, so discovery can miss a uv the client resolves fine (e.g. ~/.pyenv/shims/uvx on macOS, which EnumerateCommandCandidates does not probe). Rejecting the fallback would stop those currently working users from configuring at all. The fork only rejected it before as a side effect of the blocking uvx --help probe that this PR removes on purpose; a truly absent uv still fails visibly in the client.
… uv version uv 0.11 renamed --native-tls to --system-certs; the old name is deprecated but behaves identically (uv 0.11.0 changelog). Users already running this fork with corporate CAs have uv >= 0.11, since their --system-certs configs work. Emitting --native-tls would rewrite those configs and break them once uv drops the deprecated name. Probe the uv version (TryValidateUvxExecutable, cached per uvx path, only when the flag is needed) and emit --system-certs on uv >= 0.11 or an unknown version, --native-tls only on older uv. Configs for deployed users stay byte-identical to what earlier builds wrote. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12a3d75468
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| _windowsShimFallback = ResolveUvxBehindPyenvShim(pyenvRoot) ?? FindUvShim(shimDirs); | ||
| _windowsShimFallbackResolved = true; |
There was a problem hiding this comment.
Do not cache a failed shim lookup for the whole domain
When the first Windows lookup occurs before uv has been installed into pyenv, this sets _windowsShimFallbackResolved even though _windowsShimFallback is null. If the user then installs uv or changes pyenv versions without restarting Unity, every subsequent lookup skips shim resolution; because the real executable normally is not on PATH, GetUvxPath() falls back to bare uvx, which the MCP client resolves to the newly created batch shim and launches with corrupted metacharacter arguments. This differs from the deliberate narrow-PATH fallback because discovery already ran and permanently cached an absence; cache only successful results or provide invalidation when dependencies are refreshed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9396737. A miss is no longer cached: it never runs pyenv (pyenv which only runs when a uv shim exists, and then the shim itself is returned), so repeating it is just a few File.Exists checks and uv installed into pyenv later is found on the next lookup. A resolved .exe is reused only while it still exists, and a bare shim result (pyenv could not resolve it) is re-checked after 30 seconds, so fixing pyenv is picked up without a domain reload. Verified the install-after-miss, deleted-exe and shim-recheck sequences against the extracted code with a fake pyenv.
Addresses Codex review on #11: a miss before uv was installed into pyenv was cached until the next domain reload, so a later install was ignored and GetUvxPath fell back to bare "uvx", which the client resolves to the new batch shim. A miss never runs pyenv and is cheap to repeat, so it is no longer cached. A resolved .exe is reused while it still exists; a bare shim (pyenv could not resolve it) is re-checked after 30 seconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Cleans up fork-only changes that either regressed after merging upstream or are now covered by upstream, while keeping the two automatic behaviors users rely on.
Regressions / bugs
uvx ... mcp-for-unity --helpsynchronously on the main thread with a 60s timeout. Upstream'sStartupConfigRewrite(added 2026-05-18) calls the config write path for every stale client on Editor startup, so after a package upgrade stdio users could see the Editor stall for up to 60s per client. The probe is replaced by a cheap check (McpConfigurationHelper.GetStdioLauncherError) that rejects a missing uvx (invalid override with no system fallback; previously Claude registration removed existing registrations and then ranclaude mcp add ... -- "") and Windows.bat/.cmdshims.SSL_CERT_FILE,REQUESTS_CA_BUNDLE,CURL_CA_BUNDLE,NODE_EXTRA_CA_CERTS) and theMCPForUnity.UseSystemCertificatesoverride (always/never, unchanged key) are kept. uv 0.11 renamed--native-tlsto--system-certs(deprecated alias, identical behavior per the 0.11.0 changelog), and older uv rejects the new name outright. The uv version is probed (only when the flag is needed, cached per uvx path): uv >= 0.11 or unknown gets--system-certs, so configs for users already running this fork stay byte-identical; only uv < 0.11 gets--native-tls.QuoteCommandLineArgdoubled every backslash (C:\My Path\Server→"C:\\My Path\\Server"). It now follows Windows argv rules: only backslash runs before a quote are escaped.pyenv-win shims resolved automatically
uvx.exe/uv.exeis found on Windows, the resolver asks pyenv-win (pyenv which uvx, thenuv) for the real executable behindshims\uvx.batand writes that.exeinto client configs. The answer is cached for the domain because pyenv-win is slow to start.pyenv whichoutput format was checked against pyenv-win'spyenv.vbs(CommandWhichechoes the full path, exits 1 on failure).uvx/uv.bat/.cmdshim on PATH (or in pyenv-win'sshimsfolder) is returned instead of the bareuvxfallback, so stdio configs reject it with a clear message rather than persisting a command the client would run through cmd.exe..bat/.cmdshim is still rejected for stdio configs; the message now suggests clearing it so the shim is resolved automatically.Realigned with upstream
PathResolverService/IPathResolverServicestart from upstream again: the fork's.bat/.cmddiscovery, the never-readResolvedUvxIsShim/IsShimPathmembers and the change to the uncalledIsPythonDetectedare gone (upstream [Bug]: Python not detected when it lives behind a Store App Execution Alias (pyenv-win, and others) CoplayDev/unity-mcp#1324 already handles pyenv-win interpreter detection). The pyenv-win uv resolution above is the only addition.BackupStaleClientConfigIfNeeded(migration for configs only this fork wrote) and the duplicate shim guard inRegisterWithCapturedValues(its only caller already checks)..claude/skills/unity-mcp-skillagain, matching upstream now that docs + cli + ci: correct the CLI reference and guides, fix 3 broken CLI commands, sync the skill copies, restore the release-notes sync CoplayDev/unity-mcp#1442 merged the two skill copies; the fallback directory logic is dropped.Behavior changes to note
Test plan
QuoteCommandLineArgcases verified against a CommandLineToArgvW round-trip simulationResolveUvxBehindPyenvShim+ExecPath.TryRun, extracted verbatim, run against a fake pyenv on macOS: all 7PathResolverPyenvTestsscenarios (includingFindUvShim) passTestProjects/UnityMCPTests): 1591 cases, 1513 passed, 0 failed, 78 skipped (Windows-only).UvxLaunchArgsTests22/22,PathResolverPyenvTests7/7,WriteToConfigTests10/10BuildUvxServerLaunchArgswithREQUESTS_CA_BUNDLEset produces byte-identical args on this branch and on forkbeta(dabf4699):--system-certs --prerelease explicit --from mcpforunityserver>=0.0.0a0 mcp-for-unity --transport stdio(uv 0.12.19); identical without the CA variable tooversions\<ver>\Scripts\uvx.exeNo Windows machine was available, so the pyenv-win path is covered only by the cross-platform fake-pyenv tests.
🤖 Generated with Claude Code