Repository navigation
fix(installer+docker): launch tray with clean env, harden docker probe - #420
Merged
Merged
Conversation
The PKG postinstall script ran `open -a /Applications/MCPProxy.app` which
propagated the entire PKInstallSandbox environment (PATH=/bin:/sbin:/usr/bin:
/usr/sbin:/usr/libexec, SHELL=/bin/sh, INSTALLER_*) into the launched tray
and every child process it spawned, including the long-running mcpproxy core.
With no Docker locations on PATH, the core's docker probe failed; sync.Once
then permanently cached that failure for the lifetime of the daemon — so
the Web UI's "Scan Now" button stayed disabled, the security scan CLI
returned "all scanners failed" with "Docker image is not available locally"
even when every image was present, and `docker_status.error` showed `exec:
"docker": executable file not found in $PATH`.
Apple's recommended fix (per launchctl docs and packaging guidelines) is to
launch the app in the user's GUI bootstrap context with a clean env. Both
postinstall scripts now use:
/bin/launchctl asuser <uid> /usr/bin/env -i \
HOME=... USER=... LOGNAME=... \
PATH=/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin \
/usr/bin/open -a "$APP" --env MCPPROXY_LAUNCHED_BY=installer
This mirrors what users get when they double-click the app from Finder.
Defense-in-depth in shellwrap.ResolveDockerPath:
- Replace sync.Once with a TTL'd cache. Successful resolutions still
cache forever; failures cache only 60s so a transient install-time
failure self-heals instead of poisoning the daemon.
- Add well-known-paths probe between the exec.LookPath fast path and
the login-shell slow path. Probes the canonical Docker Desktop bundle
binary first (always present when Docker Desktop is installed),
/usr/local/bin/docker, ~/.docker/bin/docker (Docker's documented
fallback when /usr/local/bin is not writable), Apple Silicon Homebrew,
OrbStack, snap. Cheap (just os.Stat) and bypasses the fragile
login-shell dance entirely for the common case.
Web UI: revert the tooltip-left fix from #407 to tooltip-bottom. The Scan
Now button sits on the LEFT of the security tab content (`flex sm:justify-
between`) inside drawer-content with `lg:pl-64`, so tooltip-left pushed
the long tooltip text under the sidebar. Bottom orientation has plenty of
vertical room and is free of horizontal viewport edges.
Tests: TestResolveDockerPath_NegativeTTLRetry covers the self-heal path,
TestResolveDockerPath_WellKnownPathFallback covers the new probe.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Deploying mcpproxy-docs with
|
| Latest commit: |
60d3bb8
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://18effbfa.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-installer-clean-env-dock.mcpproxy-docs.pages.dev |
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 24958550571 --repo smart-mcp-proxy/mcpproxy-go
|
5 tasks done
Dumbris
added a commit
that referenced
this pull request
Apr 26, 2026
…421) When mcpproxy is launched from a sandboxed PATH (PKInstallSandbox or a GUI launchd context that strips /usr/local/bin), the source resolver's bare exec.CommandContext("docker", ...) fails silently. The resolver returns "no Docker container found" with no diagnostic logging, and the scan falls through to SourceMethod=tool_definitions_only. That makes the Web UI render the misleading "Local (no Docker)" badge for servers that ARE running in Docker, and triggers MCP-MC-001 false positives because the scanner sees only the synthetic tools.json instead of real source. PR #420 fixed the same class of bug for the docker IMAGE probe in internal/security/scanner/docker.go but missed source_resolver.go, which has 15 separate bare "docker" invocations (ps/diff/cp/exec). This commit: - Adds (*SourceResolver).dockerCmd that resolves the binary via shellwrap.ResolveDockerPath, mirroring the helper already used in scanner/docker.go. - Routes all 15 docker invocations (including dockerExecCapture, converted to a method) through the helper. - Adds a Warn log when findServerContainer fails so users can see why source extraction fell back to tool_definitions_only — previously this was a silent path that produced misleading UI. Verified manually against the running mcpproxy-obsidian-pilot-9179 container with PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec": the resolver now finds docker at /Applications/Docker.app/Contents/ Resources/bin/docker, returns Method=docker_extract, ContainerID set, and extracts 21 files of obsidianpilot source. Previously this exact scenario produced "could not resolve source... no Docker container found" and SourceMethod=tool_definitions_only. Tests: - TestDockerCmdUsesResolvedBinary: dockerCmd produces *exec.Cmd with absolute resolved Path, never a bare relative "docker" that would silently rely on $PATH. - TestDockerCmdFallbackWhenShellwrapFails: helper never returns nil or empty Path, mirroring the documented fallback in docker.go. Co-authored-by: Claude Code <[email protected]>
Merged
5 tasks done
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.
Summary
launchctl asuser <uid> env -i …so the app starts in the user's GUI bootstrap with a clean PATH instead of inheriting the PKInstallSandbox env (PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/libexec, SHELL=/bin/sh, INSTALLER_*).shellwrap.ResolveDockerPathreplacessync.Oncewith a TTL'd cache (success cached forever, failure 60s) so a transient install-time failure self-heals instead of poisoning the daemon for its lifetime./usr/local/bin/docker,~/.docker/bin/docker, Apple Silicon Homebrew, OrbStack, snap.Why this matters
Users installing v0.26.x via the PKG were ending up with a long-running mcpproxy core that could not find Docker even though Docker Desktop was running. Symptoms:
mcpproxy security scan <server>returnedall scanners failedin ~1s with per-scanner errorDocker image ... is not available locally— even when every image was present indocker images./api/v1/diagnosticsshoweddocker_status.error: exec: "docker": executable file not found in $PATH.Root cause was a chain: PKG postinstall →
open -a MCPProxy.apppropagated installer env → tray app → forkedmcpproxy servewith no Docker locations on PATH → firstResolveDockerPathcall failed →sync.Oncecached the failure for the lifetime of the daemon. Restarting via the tray (normal user session) fixed it but the user shouldn't have to know that.Apple's recommended pattern (per
launchctl(1), packaging guidelines, and prior art in Tailscale / Colima / OrbStack) is to launch underlaunchctl asuserwithEnvironmentVariables.PATHset explicitly so children never inherit the sandbox env. That's what this PR does for the postinstall path; the Go-side TTL cache + well-known-paths probe is defense-in-depth in case any other context (LaunchAgent, manual launchctl, etc.) ends up with a similarly minimal PATH.Files
frontend/src/views/ServerDetail.vue— tooltip-left → tooltip-bottominternal/shellwrap/shellwrap.go— TTL cache + well-known-paths probeinternal/shellwrap/shellwrap_test.go— new tests for retry + well-known fallbackpackaging/macos/postinstall.sh— clean-env launch via launchctl asuserscripts/postinstall.sh— clean-env launch via launchctl asuserTest plan
go test ./internal/shellwrap/... -count=1 -race— all tests pass including newTestResolveDockerPath_NegativeTTLRetryandTestResolveDockerPath_WellKnownPathFallbackgo build ./cmd/mcpproxy(personal) andgo build -tags server ./cmd/mcpproxy(server) — both cleanbash -nsyntax check on both postinstall scriptsmcpproxy security scanworks immediately and Web UI's "Scan Now" is enabled🤖 Generated with Claude Code