@@ -3,8 +3,12 @@ set -euo pipefail
33
44# devcontainer-mcp installer
55# Downloads the latest release binary.
6- # Backend CLIs (devpod, devcontainer, gh) are detected at runtime —
7- # if missing, the MCP server returns a helpful error message.
6+ # Backend CLIs:
7+ # - devcontainer (@devcontainers/cli) is auto-installed via the official
8+ # standalone installer (bundles its own Node.js runtime) into
9+ # ~/.local/share/devcontainer-mcp/devcontainers/ when missing.
10+ # - devpod and gh are detected only; if missing, the MCP server returns
11+ # a helpful error message and the installer prints install URLs.
812#
913# Usage:
1014# curl -fsSL https://raw.githubusercontent.com/aniongithub/devcontainer-mcp/main/install.sh | bash
@@ -295,7 +299,35 @@ configure_copilot_hook
295299echo " "
296300echo " Backend CLIs detected (install as needed — MCP server gives helpful errors if missing):"
297301command -v devpod > /dev/null 2>&1 && echo " ✓ devpod" || echo " ✗ devpod — https://devpod.sh/docs/getting-started/install"
298- command -v devcontainer > /dev/null 2>&1 && echo " ✓ devcontainer" || echo " ✗ devcontainer — https://github.com/devcontainers/cli#install-script"
302+
303+ # devcontainer CLI: auto-install via the official standalone installer
304+ # (bundles its own Node.js runtime — no system Node required) into a
305+ # folder we own, then symlink the binary into INSTALL_DIR so it picks
306+ # up the same PATH guidance the script gives for the main binary.
307+ install_devcontainer_cli () {
308+ local cli_prefix=" ${HOME} /.local/share/devcontainer-mcp/devcontainers"
309+ local installer_url=" https://raw.githubusercontent.com/devcontainers/cli/main/scripts/install.sh"
310+ echo " … devcontainer CLI not found — installing standalone bundle into ${cli_prefix} "
311+ mkdir -p " $( dirname " $cli_prefix " ) "
312+ if ! curl -fsSL " $installer_url " | sh -s -- --prefix " $cli_prefix " > /dev/null 2>&1 ; then
313+ echo " ✗ devcontainer — standalone install failed; see https://github.com/devcontainers/cli#install-script"
314+ return 1
315+ fi
316+ local shim=" ${cli_prefix} /bin/devcontainer"
317+ if [ ! -x " $shim " ]; then
318+ echo " ✗ devcontainer — install completed but ${shim} is missing"
319+ return 1
320+ fi
321+ ln -sf " $shim " " ${INSTALL_DIR} /devcontainer"
322+ echo " ✓ devcontainer (auto-installed → ${INSTALL_DIR} /devcontainer)"
323+ }
324+
325+ if command -v devcontainer > /dev/null 2>&1 ; then
326+ echo " ✓ devcontainer"
327+ else
328+ install_devcontainer_cli || true
329+ fi
330+
299331command -v gh > /dev/null 2>&1 && echo " ✓ gh (codespaces)" || echo " ✗ gh (codespaces) — https://cli.github.com/"
300332
301333# ---------------------------------------------------------------------------
0 commit comments