#!/usr/bin/env bash # # Baylor Family research assistant — one-run setup for macOS. # Connects your Claude to the family's private search hub. # Nothing here is secret; you log in with your own family account. # set -uo pipefail HUB_URL="https://mcp.thebaylors.org/mcp" SERVER_NAME="baylor-search" CLAUDE_INSTALL="https://claude.ai/install.sh" bold=$'\033[1m'; grn=$'\033[32m'; ylw=$'\033[33m'; red=$'\033[31m'; dim=$'\033[2m'; rst=$'\033[0m' say() { printf "%s\n" "$*"; } ok() { printf "%s✓%s %s\n" "$grn" "$rst" "$*"; } warn() { printf "%s!%s %s\n" "$ylw" "$rst" "$*"; } err() { printf "%s✗%s %s\n" "$red" "$rst" "$*"; } step() { printf "\n%s%s%s\n" "$bold" "$*" "$rst"; } # read a keypress from the real terminal even when run via `curl | bash` ask() { local a; read -r -p "$1 " a /dev/null || a="$2"; echo "${a:-$2}"; } printf "\n%s┌───────────────────────────────────────────┐%s\n" "$bold" "$rst" printf "%s│ Baylor Family — Research Assistant setup │%s\n" "$bold" "$rst" printf "%s└───────────────────────────────────────────┘%s\n" "$bold" "$rst" # 1) sanity: macOS step "1. Checking your Mac" if [ "$(uname -s)" != "Darwin" ]; then err "This installer is for macOS only."; exit 1; fi ok "macOS $(sw_vers -productVersion 2>/dev/null) on $(uname -m)" # 2) can we reach the hub? step "2. Checking the family hub is reachable" code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 12 "$HUB_URL" 2>/dev/null || echo 000) if [ "$code" = "401" ]; then ok "Hub is up (a login will be required — that's expected)." elif [ "$code" = "000" ]; then err "Couldn't reach $HUB_URL. Check your internet connection and try again."; exit 1 else warn "Hub responded with HTTP $code (expected 401). Continuing anyway." fi # 3) detect existing Claude step "3. Looking for Claude on this Mac" HAS_CLI=0; HAS_APP=0 command -v claude >/dev/null 2>&1 && HAS_CLI=1 [ -d "/Applications/Claude.app" ] && HAS_APP=1 [ "$HAS_CLI" = 1 ] && ok "Found Claude Code (command line)." [ "$HAS_APP" = 1 ] && ok "Found the Claude desktop app." [ "$HAS_CLI" = 0 ] && [ "$HAS_APP" = 0 ] && warn "No Claude found yet." configure_cli() { step "Connecting Claude Code to the family hub" if claude mcp list 2>/dev/null | grep -q "$SERVER_NAME"; then ok "Already connected ('$SERVER_NAME' is configured)." else if claude mcp add --transport http -s user "$SERVER_NAME" "$HUB_URL" 2>/dev/null; then ok "Added '$SERVER_NAME'." else warn "Couldn't add automatically. Run this yourself:" say " ${dim}claude mcp add --transport http -s user $SERVER_NAME $HUB_URL${rst}" fi fi step "Last step — log in" say "Open Claude Code (type ${bold}claude${rst} in a Terminal), then:" say " • A browser window opens → sign in with your ${bold}family account${rst} → Allow." say " • If it says ${dim}\"Needs authentication\"${rst} without opening a browser," say " type ${bold}/mcp${rst} inside Claude and choose ${bold}$SERVER_NAME${rst} → Authenticate." say "Then just ask Claude to search the web — you're done. 🎉" } guide_desktop() { step "Connecting the Claude desktop app to the family hub" printf "%s" "$HUB_URL" | pbcopy 2>/dev/null && ok "Copied the hub address to your clipboard." \ || warn "Hub address: $HUB_URL" open -a "Claude" 2>/dev/null || true say "In the Claude app:" say " 1. Open ${bold}Settings → Connectors${rst}." say " 2. Click ${bold}Add custom connector${rst}." say " 3. Paste the address (already copied): ${bold}$HUB_URL${rst}" say " 4. Click through → sign in with your ${bold}family account${rst} → Allow." say "Then ask Claude to search the web — you're done. 🎉" } install_claude_code() { step "Installing Claude Code" say "This installs Anthropic's official Claude Code (no admin password needed)." ans=$(ask "Install it now? [Y/n]" "Y") case "$ans" in [nN]*) warn "Skipped. You can install later from https://claude.ai/download"; return 1 ;; esac if curl -fsSL "$CLAUDE_INSTALL" | bash; then export PATH="$HOME/.local/bin:$PATH" hash -r 2>/dev/null || true if command -v claude >/dev/null 2>&1; then ok "Claude Code installed."; return 0 else warn "Installed, but 'claude' isn't on PATH yet — open a new Terminal and re-run me."; return 1; fi fi err "Install failed. Try the desktop app instead: https://claude.ai/download"; return 1 } # 4) act on what we found if [ "$HAS_CLI" = 1 ]; then configure_cli elif [ "$HAS_APP" = 1 ]; then guide_desktop else if install_claude_code; then configure_cli; else warn "No Claude client configured. Install the desktop app or Claude Code, then re-run:" say " ${dim}curl -fsSL https://setup.thebaylors.org | bash${rst}" exit 1 fi fi step "Heads up" say "• You need a family account (ask Dad if you're not sure) to log in." say "• You need a paid Claude plan for Claude Code; the desktop app works with your Claude plan's connectors." say "" ok "Setup complete."