#!/bin/sh # Bug Dossier — connect every coding agent on this machine to Bug Dossier, in one go. # # curl -fsSL https://bugdossier.com/setup | sh # curl -fsSL https://bugdossier.com/setup | sh -s -- --dry-run # show what it would change # # For each agent that is installed it adds one MCP server named "bug-dossier" pointing at # https://bugdossier.com/api/mcp # at user scope (every project). Running it again changes nothing that is already right, and moves # an older per-workspace address (https://.bugdossier.com/api/mcp) to the one address above. # Nothing is sent anywhere; sign-in happens later, in your browser, the first time an agent uses it. main() { set -u NAME="bug-dossier" URL="${BUG_DOSSIER_MCP_URL:-https://bugdossier.com/api/mcp}" EXTENSION="https://chromewebstore.google.com/detail/nljfaocpdpoijkinipdijgdemefflnoe" DRY=0 for a in "$@"; do case "$a" in --dry-run|-n) DRY=1 ;; --help|-h) say "usage: curl -fsSL https://bugdossier.com/setup | sh [-s -- --dry-run]"; return 0 ;; esac done OS=$(uname -s 2>/dev/null || echo unknown) DONE=""; SAME=""; MANUAL=""; ABSENT=""; SIGNIN="" say "Bug Dossier → $URL" if [ "$DRY" = 1 ]; then say "(dry run: nothing will be changed)"; fi setup_claude_code setup_codex setup_gemini setup_copilot setup_vscode setup_cursor setup_windsurf setup_claude_desktop say "" if [ -n "$DONE" ]; then if [ "$DRY" = 1 ]; then say "Would connect:"; else say "Connected:"; fi printf '%b' "$DONE" fi if [ -n "$SAME" ]; then say "Already connected:"; printf '%b' "$SAME"; fi if [ -n "$MANUAL" ]; then say "Needs one step from you:"; printf '%b' "$MANUAL"; fi if [ -n "$ABSENT" ]; then say "Not found on this machine:$ABSENT"; fi if [ -z "$DONE$SAME$MANUAL" ]; then say "No coding agent found. Install one (Claude Code, Codex, Cursor, Gemini CLI, VS Code…) and run this again," say "or add an MCP server named $NAME with the URL $URL to your agent by hand." fi say "" say "Next:" say " 1. Sign in once per agent — the first time it uses Bug Dossier your browser opens; approve with your work Google account." if [ -n "$SIGNIN" ]; then printf '%b' "$SIGNIN"; fi say " 2. Try it: ask your agent \"list my Bug Dossier workspaces\" or \"read S-1 in Bug Dossier and tell me what broke\"." say " 3. Record bugs with the Chrome extension: $EXTENSION" } say() { printf '%s\n' "$1"; } have() { command -v "$1" >/dev/null 2>&1; } done_() { DONE="$DONE ✓ $1\n"; } same_() { SAME="$SAME ✓ $1\n"; } manual_() { MANUAL="$MANUAL • $1\n"; } absent_() { ABSENT="$ABSENT${ABSENT:+,} $1"; } signin_() { SIGNIN="$SIGNIN $1\n"; } run() { # run a command unless dry; stdin is closed so nothing reads this script from the pipe if [ "$DRY" = 1 ]; then say " would run: $*"; return 0; fi "$@" /dev/null 2>&1 } # json_put FILE TOP VALUE — set FILE's TOP.bug-dossier = VALUE (a JSON object), keeping everything # else. Exit 0 = changed, 3 = already so, 1 = could not (unparseable file / no JSON tool). json_put() { file=$1; top=$2; value=$3 if [ "$DRY" = 1 ]; then say " would set \"$top\".\"$NAME\" = $value in $file"; return 0; fi mkdir -p "$(dirname "$file")" 2>/dev/null || return 1 if [ ! -s "$file" ]; then printf '{\n "%s": {\n "%s": %s\n }\n}\n' "$top" "$NAME" "$value" >"$file" && return 0 return 1 fi if have node; then node -e ' const fs = require("fs"); const [file, top, name, raw] = process.argv.slice(1); let doc; try { doc = JSON.parse(fs.readFileSync(file, "utf8")); } catch { process.exit(1); } if (!doc || typeof doc !== "object" || Array.isArray(doc)) process.exit(1); const value = JSON.parse(raw); doc[top] = doc[top] && typeof doc[top] === "object" ? doc[top] : {}; if (JSON.stringify(doc[top][name]) === JSON.stringify(value)) process.exit(3); fs.copyFileSync(file, file + ".bak-bug-dossier"); doc[top][name] = value; fs.writeFileSync(file, JSON.stringify(doc, null, 2) + "\n");' "$file" "$top" "$NAME" "$value" /dev/null 2>&1; }; then python3 -c ' import json, shutil, sys file, top, name, raw = sys.argv[1:5] try: doc = json.load(open(file)) except Exception: sys.exit(1) if not isinstance(doc, dict): sys.exit(1) value = json.loads(raw) if not isinstance(doc.get(top), dict): doc[top] = {} if doc[top].get(name) == value: sys.exit(3) shutil.copyfile(file, file + ".bak-bug-dossier") doc[top][name] = value open(file, "w").write(json.dumps(doc, indent=2) + "\n")' "$file" "$top" "$NAME" "$value" /dev/null || true) if printf '%s' "$current" | grep -q "URL: $URL\$" && printf '%s' "$current" | grep -q "Scope: User"; then same_ "Claude Code (user scope)" else if printf '%s' "$current" | grep -q "Scope: User"; then run claude mcp remove "$NAME" -s user; fi if run claude mcp add --transport http -s user "$NAME" "$URL"; then done_ "Claude Code — user scope (claude mcp add --transport http -s user $NAME $URL)" else manual_ "Claude Code: run claude mcp add --transport http -s user $NAME $URL" fi if printf '%s' "$current" | grep -q "Scope: Local"; then manual_ "Claude Code: an older per-project \"$NAME\" entry overrides this one in that project — run claude mcp remove $NAME -s local there" fi fi signin_ "Claude Code: if it says \"needs authentication\", type /mcp, pick $NAME, then Authenticate." } setup_codex() { if ! have codex; then absent_ "Codex"; return; fi cfg="${CODEX_HOME:-$HOME/.codex}/config.toml" if [ -f "$cfg" ] && grep -q "^\[mcp_servers\.$NAME\]" "$cfg" && grep -q "^url = \"$URL\"" "$cfg"; then same_ "Codex ($cfg)" else # Written directly rather than with `codex mcp add`, which starts a browser sign-in on the spot # and waits for it — this script must not block on one agent. if [ -f "$cfg" ] && grep -q "^\[mcp_servers\.$NAME\]" "$cfg"; then run codex mcp remove "$NAME"; fi if [ "$DRY" = 1 ]; then say " would append [mcp_servers.$NAME] url = \"$URL\" to $cfg" done_ "Codex" elif mkdir -p "$(dirname "$cfg")" && printf '\n[mcp_servers.%s]\nurl = "%s"\n' "$NAME" "$URL" >>"$cfg"; then done_ "Codex — $cfg" else manual_ "Codex: run codex mcp add $NAME --url $URL" fi fi signin_ "Codex: run codex mcp login $NAME once." } setup_gemini() { if ! have gemini; then absent_ "Gemini CLI"; return; fi cfg="$HOME/.gemini/settings.json" if [ -f "$cfg" ] && grep -q "\"$NAME\"" "$cfg" && grep -q "\"httpUrl\": *\"$URL\"" "$cfg"; then same_ "Gemini CLI ($cfg)" return fi if [ -f "$cfg" ] && grep -q "\"$NAME\"" "$cfg"; then run gemini mcp remove -s user "$NAME"; fi if run gemini mcp add -t http -s user "$NAME" "$URL"; then done_ "Gemini CLI — user scope" else put_json_config "Gemini CLI" "$cfg" mcpServers "{\"httpUrl\": \"$URL\"}" fi signin_ "Gemini CLI: type /mcp auth $NAME if it asks." } setup_copilot() { if ! have copilot; then absent_ "GitHub Copilot CLI"; return; fi cfg="${COPILOT_HOME:-$HOME/.copilot}/mcp-config.json" if [ -f "$cfg" ] && grep -q "\"$NAME\"" "$cfg" && grep -q "$URL" "$cfg"; then same_ "GitHub Copilot CLI ($cfg)" elif run copilot mcp add --transport http "$NAME" "$URL"; then done_ "GitHub Copilot CLI" else manual_ "GitHub Copilot CLI: run copilot mcp add --transport http $NAME $URL" fi } setup_vscode() { case "$OS" in Darwin) user_dir="$HOME/Library/Application Support/Code/User" ;; *) user_dir="${XDG_CONFIG_HOME:-$HOME/.config}/Code/User" ;; esac cfg="$user_dir/mcp.json" if [ -f "$cfg" ] && grep -q "\"$NAME\"" "$cfg" && grep -q "$URL" "$cfg"; then same_ "VS Code ($cfg)" elif have code; then if run code --add-mcp "{\"name\":\"$NAME\",\"type\":\"http\",\"url\":\"$URL\"}"; then done_ "VS Code (GitHub Copilot) — user profile" else manual_ "VS Code: run code --add-mcp '{\"name\":\"$NAME\",\"type\":\"http\",\"url\":\"$URL\"}'" fi elif [ -d "$user_dir" ]; then put_json_config "VS Code (GitHub Copilot)" "$cfg" servers "{\"type\": \"http\", \"url\": \"$URL\"}" else absent_ "VS Code" fi } setup_cursor() { if [ -d "$HOME/.cursor" ] || have cursor || have cursor-agent || [ -d "/Applications/Cursor.app" ]; then put_json_config "Cursor" "$HOME/.cursor/mcp.json" mcpServers "{\"url\": \"$URL\"}" signin_ "Cursor: Settings → MCP → $NAME → Connect, if it shows \"Needs login\"." else absent_ "Cursor" fi } setup_windsurf() { found=0 if [ -d "$HOME/.codeium/windsurf" ]; then found=1 put_json_config "Windsurf" "$HOME/.codeium/windsurf/mcp_config.json" mcpServers "{\"serverUrl\": \"$URL\"}" fi devin="${XDG_CONFIG_HOME:-$HOME/.config}/devin" if [ -d "$devin" ]; then found=1 put_json_config "Devin Desktop (Cascade)" "$devin/mcp_config.json" mcpServers "{\"serverUrl\": \"$URL\"}" fi [ "$found" = 1 ] || absent_ "Windsurf" } setup_claude_desktop() { # Claude Desktop takes remote servers only through its own UI (its config file is for local ones). if [ -d "/Applications/Claude.app" ] || [ -d "$HOME/Library/Application Support/Claude" ] || [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/Claude" ]; then manual_ "Claude Desktop: Customize → Connectors → Add custom connector → name \"Bug Dossier\", URL $URL" else absent_ "Claude Desktop" fi } main "$@"