#!/bin/sh # CommunityCAD MCP installer for macOS and Linux. # # curl -LsSf https://communitycad.dev/mcp/install.sh | sh # # What it does: # 1. If uv isn't installed, installs it with uv's official installer # (https://docs.astral.sh/uv/). No sudo: uv goes in your home folder. # 2. Runs `uvx communitycad-mcp@latest install`, which adds the CommunityCAD # MCP server to the AI apps it finds on this computer (OpenCode, # Claude Desktop, Claude Code, Cursor, Codex, Gemini CLI, GitHub Copilot, # Windsurf, Zed, VS Code). # # Options after `sh -s --` go to `communitycad-mcp install`, for example: # curl -LsSf https://communitycad.dev/mcp/install.sh | sh -s -- --help # # To remove it later: uvx communitycad-mcp uninstall # Docs: https://communitycad.dev/docs/mcp/installing set -eu DOCS_URL="https://communitycad.dev/docs/mcp/installing" UV_DOCS_URL="https://docs.astral.sh/uv/" UV_INSTALLER_URL="https://astral.sh/uv/install.sh" say() { printf '%s\n' "$*"; } step() { printf '\n==> %s\n' "$*"; } fail() { printf '\nError: %s\n' "$1" >&2 printf 'Manual steps and help: %s\n' "$DOCS_URL" >&2 exit 1 } # uv's installer puts uvx in one of these folders. Add them to PATH for this # run, in case uv is installed but this shell doesn't know about it yet. add_uv_dirs_to_path() { for dir in "${XDG_BIN_HOME:-}" "${HOME}/.local/bin" "${HOME}/.cargo/bin"; do if [ -n "$dir" ] && [ -x "$dir/uvx" ]; then case ":$PATH:" in *":$dir:"*) ;; *) PATH="$PATH:$dir" ;; esac fi done export PATH } install_uv() { step "Installing uv (a small tool that runs Python apps; no sudo needed)" if command -v curl >/dev/null 2>&1; then curl -LsSf "$UV_INSTALLER_URL" | sh || fail "uv didn't install. Install it from $UV_DOCS_URL and run this again." elif command -v wget >/dev/null 2>&1; then wget -qO- "$UV_INSTALLER_URL" | sh || fail "uv didn't install. Install it from $UV_DOCS_URL and run this again." else fail "downloading uv needs curl or wget. Install one of them, or install uv from $UV_DOCS_URL, then run this again." fi add_uv_dirs_to_path command -v uvx >/dev/null 2>&1 || fail "uv was installed, but uvx isn't on PATH. Open a new terminal and run: uvx communitycad-mcp@latest install" say "uv installed." } # Everything runs from main, so the whole script is read before anything # runs: with `curl ... | sh`, the script itself arrives on stdin. main() { say "CommunityCAD MCP installer" if [ "$(id -u)" = "0" ]; then say "Note: you're running this as root. Your AI apps run as your own user," say "so it's usually better to run it without sudo." fi add_uv_dirs_to_path if command -v uvx >/dev/null 2>&1; then step "uv is already installed ($(command -v uvx))" else install_uv fi step "Adding CommunityCAD to your AI apps" # stdin is this script's pipe; give the installer the terminal instead, so # it can ask questions when there's someone to answer them. if (: /dev/null; then uvx communitycad-mcp@latest install "$@"