Skip to content

feat(doctor): surface snap-docker override hint when host needs it - #460

Merged
Dumbris merged 1 commit into
mainfrom
feat/doctor-snap-docker-check
May 13, 2026
Merged

Dumbris merged 1 commit into
mainfrom
feat/doctor-snap-docker-check

Conversation

@Dumbris

@Dumbris Dumbris commented May 13, 2026

Copy link
Copy Markdown
Member

Summary

  • mcpproxy doctor gains a host-environment check that detects the snap-docker × deb-hardened-unit incompatibility (issue doctor: detect snap-docker on host and surface the systemd drop-in needed when the deb runs alongside it #457)
  • When all three signals fire (snap docker present, systemd service HOME outside /home/, at least one upstream uses docker), pretty output prints a new 🌐 Environment section with the exact override drop-in plus one-time host commands
  • JSON output (--output=json) gains an environment_warnings array — consistent with the existing runtime_warnings shape

Why

Migrating to the deb on an Ubuntu host with snap docker produces stderr like:

snap-confine ... required permitted capability cap_dac_override not found
cannot create XDG_RUNTIME_DIR folder "/run/user/996/snap.docker"

…which is hard to map back to "you need a ~10-line systemd drop-in". This makes mcpproxy doctor print the snippet directly so the user can copy-paste it. Same class of help as the existing ClassifyScannerExecFailure for scanner containers.

Design

Pure decision (snapDockerEnvInputs.ShouldWarn) is split from the host probes so the test matrix doesn't depend on running on a real snap-docker host:

  • hasDockerUpstream(servers) — matches command: docker, shell wrappers whose args contain docker, and docker_isolation: true
  • homeOutsideHome(path) — treats empty HOME as "inside" so we don't false-positive when we can't read service env
  • detectSnapDockerPresent(ctx) — /snap/bin/docker stat, falls back to docker version --format parse
  • detectServiceHome(ctx) — systemctl show mcpproxy.service --property=Environment, parses HOME=...
  • Both host probes no-op on non-Linux

Test plan

  • go test ./cmd/mcpproxy/ passes (16 new sub-tests across 4 functions)
  • go test -race ./cmd/mcpproxy/ clean
  • go vet ./cmd/mcpproxy/ clean
  • Existing doctor tests updated to the new outputDiagnostics signature
  • Reviewer: try ./mcpproxy doctor on a snap-docker host with a docker-based upstream and confirm the Environment block renders. Also try on macOS / non-snap-docker Linux and confirm it's silent (no false positives).

Closes #457.

🤖 Generated with Claude Code

When the mcpproxy deb is installed on a host whose Docker came from snap
and the systemd service runs as a system user with HOME outside /home/,
every docker-based upstream MCP server fails with multi-paragraph snap-
confine stderr that's hard to map back to a fix. The override is ~10
lines; finding it from scratch is ~30 min.

`mcpproxy doctor` now checks all three signals (snap docker present,
service HOME outside /home/, at least one upstream uses docker) and,
when all true, prints the exact `/etc/systemd/system/mcpproxy.service.d/
snap-docker.conf` snippet plus the one-time host commands (`loginctl
enable-linger`, `snap set system homedirs=/var/lib`, `snap restart docker`).

Decision split from detection so the test matrix doesn't depend on
running on a real snap-docker host:
  - snapDockerEnvInputs.ShouldWarn() — pure decision
  - hasDockerUpstream(servers) — pattern-match daemon's server list
  - homeOutsideHome(path) — string predicate
  - detect{SnapDockerPresent,ServiceHome} — Linux-only probes, no-op
    elsewhere

Hint included in --output=json as `environment_warnings` (consistent
with the existing `runtime_warnings` shape). The Environment section
renders even when no per-server diagnostics fired because the upstreams
may still be in retry — preempt the next failure instead of waiting for
it to surface.

Closes #457

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: feat/doctor-snap-docker-check

Available Artifacts

  • archive-darwin-amd64 (26 MB)
  • archive-darwin-arm64 (23 MB)
  • archive-linux-amd64 (15 MB)
  • archive-linux-arm64 (13 MB)
  • archive-windows-amd64 (26 MB)
  • archive-windows-arm64 (23 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (20 MB)
  • installer-dmg-darwin-arm64 (18 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 25781970489 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@Dumbris
Dumbris merged commit 9b79254 into main May 13, 2026
23 checks passed
@Dumbris
Dumbris deleted the feat/doctor-snap-docker-check branch May 13, 2026 06:41
electrolobzik added a commit to HaloCollar/mcpproxy-go that referenced this pull request May 16, 2026
Brings in upstream's 9 commits since 2b9b5f9:
- 0597762 fix(upstream): stop misclassifying transport errors as auth failures (smart-mcp-proxy#464)
- aaec117 fix(diagnostics): correct bug-report URL (smart-mcp-proxy#465)
- d27fa38 feat(server-detail): display + edit headers/env, with reveal & convert-to-secret (smart-mcp-proxy#466)
- c086770 feat(webui): per-tool enable/disable + bulk Enable All/Disable All (smart-mcp-proxy#463)
- 0ef75a8 chore(docs): remove stale root-level docs
- 4b4b62a fix(ui): respect engaged flag in sidebar Setup pulse (smart-mcp-proxy#462)
- 24aab3d docs(installation): add migrating-from-manual-install section (smart-mcp-proxy#459)
- 9b79254 feat(doctor): surface snap-docker override hint when host needs it (smart-mcp-proxy#460)
- be927b6 packaging(deb): ship unattended-upgrades whitelist so installs auto-update (smart-mcp-proxy#458)

Conflicts resolved:

1. internal/management/service_test.go — purely additive on upstream's
   side (3 new headers/env t.Run blocks). Halo-main had no overlapping
   test work. Took upstream's additions verbatim.

2. oas/docs.go + oas/swagger.yaml — auto-generated by swaggo from Go
   annotations in source. Took --theirs on the conflict then regenerated
   with `make swagger` against the merged source so both halo-main- and
   upstream-introduced REST endpoints are reflected.

Note on upstream's c086770 (per-tool enable/disable, upstream's version
of smart-mcp-proxy#463): halo-main already has its own per-tool enable/disable work
(via feat/per-tool-enable-disable + the security-hardening stack on
top — admin gating, isToolCallable fail-closed, sentinel-error
quarantine synthesis, etc.). The upstream version produced no merge
conflicts because the file-level diffs aligned cleanly — the fork's
hardening sits atop the same surface upstream landed.

Sanity-checked:
- `go build ./...` succeeds.
- `go test -short ./internal/management/ ./internal/runtime/
  ./internal/httpapi/ ./internal/storage/ ./cmd/generate-types/` passes.
- internal/server pre-existing sandbox-environment flake
  (TestBinaryAPIEndpoints/GET_/servers) was verified to fail on
  pre-merge halo-main (ad31fde) too — not a regression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doctor: detect snap-docker on host and surface the systemd drop-in needed when the deb runs alongside it

2 participants