From 8f76338b056ac7b7f8fcc89f8b43966e990f51d3 Mon Sep 17 00:00:00 2001 From: dtoro Date: Thu, 21 May 2026 09:25:58 +0200 Subject: [PATCH] bootstrap: install mcp CLI via pipx on workstation enrollment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit G1 from the apt-sweep backlog. After ssh ControlMaster setup, install the `mcp[cli]` python package via pipx so `homelab mcp ` works out-of-the-box on new workstations. Skipped on LXCs / VMs. Idempotent (`command -v mcp` guard), respects --dry-run, falls back through brew (Darwin) → dnf → apt for pipx itself if not already installed. Runs the install as $SUDO_USER (not root) so the binary lands in the user's pipx env. This closes one of the "discovered missing dep" gaps from the 2026-05-21 fleet sweep: republic-laptop had pipx-installed homelab CLI but no `mcp` binary, so `homelab mcp ` died with an instructional message instead of just working. Co-Authored-By: Claude Opus 4.7 (1M context) --- bootstrap.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/bootstrap.sh b/bootstrap.sh index b66952a..e0cfe45 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -390,6 +390,36 @@ SSHEOF fi fi +# -------- mcp CLI install (workstations) -------- +# `homelab mcp ` shells out to the `mcp` python CLI. Install it via +# pipx for the enrolling user. Skip on LXCs / VMs. +if [ "$HKIND" != "lxc" ] && [ "$HKIND" != "vm" ]; then + if [ "$DRY_RUN" -eq 1 ]; then + echo "+ would install 'mcp[cli]' via pipx for the enrolling user" + elif command -v mcp >/dev/null 2>&1; then + echo "[bootstrap] mcp CLI already on PATH (skip)" + else + # Make sure pipx is available; OS-specific install. + if ! command -v pipx >/dev/null 2>&1; then + if [ "$OS" = "Darwin" ] && command -v brew >/dev/null 2>&1; then + sudo -u "${SUDO_USER:-$USER}" brew install pipx 2>&1 | tail -2 || true + elif command -v dnf >/dev/null 2>&1; then + dnf install -y pipx 2>&1 | tail -2 || true + elif command -v apt-get >/dev/null 2>&1; then + DEBIAN_FRONTEND=noninteractive apt-get install -y pipx 2>&1 | tail -2 || true + fi + fi + if command -v pipx >/dev/null 2>&1; then + INVOKING_USER="${SUDO_USER:-$USER}" + sudo -u "$INVOKING_USER" -- bash -lc "pipx install 'mcp[cli]'" 2>&1 | tail -3 || true + sudo -u "$INVOKING_USER" -- bash -lc "pipx ensurepath" >/dev/null 2>&1 || true + echo "[bootstrap] mcp CLI installed for $INVOKING_USER via pipx" + else + echo "[bootstrap] WARNING: pipx unavailable; install manually: pipx install 'mcp[cli]'" >&2 + fi + fi +fi + # -------- done -------- cat <