# CommunityCAD MCP installer for Windows (Windows PowerShell 5.1 and PowerShell 7). # # irm https://communitycad.dev/mcp/install.ps1 | iex # # What it does: # 1. If uv isn't installed, installs it with uv's official installer # (https://docs.astral.sh/uv/). No admin rights: uv goes in your user 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). # # To pass options to `communitycad-mcp install`, save the script and run it: # irm https://communitycad.dev/mcp/install.ps1 -OutFile install.ps1 # powershell -ExecutionPolicy Bypass -File .\install.ps1 --help # # To remove it later: uvx communitycad-mcp uninstall # Docs: https://communitycad.dev/docs/mcp/installing # An interactive installer talks to the person running it, so Write-Host is right here. [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '')] param() $ErrorActionPreference = 'Stop' function Write-CcStep([string]$Message) { Write-Host '' Write-Host "==> $Message" -ForegroundColor Cyan } # Rebuild this session's PATH from the registry and add the folders uv's # installer uses, so a freshly installed uv works without a new window. function Sync-CcSessionPath { $sep = [IO.Path]::PathSeparator $dirs = @() if ($env:XDG_BIN_HOME) { $dirs += $env:XDG_BIN_HOME } $dirs += Join-Path (Join-Path $HOME '.local') 'bin' $dirs += Join-Path (Join-Path $HOME '.cargo') 'bin' $dirs += ([Environment]::GetEnvironmentVariable('Path', 'User') -split $sep) $dirs += ([Environment]::GetEnvironmentVariable('Path', 'Machine') -split $sep) $dirs += ($env:PATH -split $sep) $seen = @{} $kept = foreach ($d in $dirs) { if ($d -and -not $seen.ContainsKey($d.ToLowerInvariant())) { $seen[$d.ToLowerInvariant()] = $true $d } } $env:PATH = $kept -join $sep } function Test-CcUvx { return [bool](Get-Command uvx -ErrorAction SilentlyContinue) } # Failures throw and are reported once at the end. Never `exit`: under # `irm ... | iex`, exit would close the PowerShell window. try { Write-Host 'CommunityCAD MCP installer' Sync-CcSessionPath if (Test-CcUvx) { Write-CcStep "uv is already installed ($((Get-Command uvx).Source))" } else { Write-CcStep 'Installing uv (a small tool that runs Python apps; no admin rights needed)' # uv's official installer, in its own PowerShell process so nothing it # does can close this window. $ccShell = (Get-Process -Id $PID).Path & $ccShell -NoProfile -ExecutionPolicy Bypass -Command 'irm https://astral.sh/uv/install.ps1 | iex' if ($LASTEXITCODE -ne 0) { throw "uv didn't install. Install it from https://docs.astral.sh/uv/ and run this again." } Sync-CcSessionPath if (-not (Test-CcUvx)) { throw "uv was installed, but uvx isn't on PATH yet. Open a new PowerShell window and run: uvx communitycad-mcp@latest install" } Write-Host 'uv installed.' } Write-CcStep 'Adding CommunityCAD to your AI apps' & uvx communitycad-mcp@latest install @args if ($LASTEXITCODE -ne 0) { throw "setup didn't finish. Run 'uvx communitycad-mcp doctor' to see what's wrong." } Write-Host '' Write-Host 'Done. Restart your AI app (or start a new session), then ask it:' -ForegroundColor Green Write-Host ' "What''s my CommunityCAD account status?"' Write-Host 'To remove it later: uvx communitycad-mcp uninstall' } catch { Write-Host '' Write-Host "Error: $($_.Exception.Message)" -ForegroundColor Red Write-Host 'Manual steps and help: https://communitycad.dev/docs/mcp/installing' # A terminating error, not `exit`: the window stays open under iex, and # `powershell -File install.ps1` still ends with exit code 1. throw 'CommunityCAD MCP install did not finish.' }