From c49fe82ea8ba6bd6e58e66c46b1aef63f471503d Mon Sep 17 00:00:00 2001 From: Sam & Claude Date: Sun, 21 Jun 2026 19:30:40 +0200 Subject: [PATCH] feat(enable-mother): jq-merge the mother entry instead of overwriting Track C's enable-mother overwrote external-mcp.json with a single mother server. Use jq to merge the mother entry into the existing registry so other configured servers are preserved, written atomically (mktemp in same dir + mv). This is the concrete consumer that makes jq a real dependency of the MCP path; fails loudly if jq is absent. (Re-applied: the original commit was lost to a branch-recreation race when #97 merged at the packages-only commit.) Co-Authored-By: Claude Opus 4.8 --- .../operator-session/clawdie-enable-mother.sh | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/live/operator-session/clawdie-enable-mother.sh b/live/operator-session/clawdie-enable-mother.sh index a53d83fa..ed29bcd1 100755 --- a/live/operator-session/clawdie-enable-mother.sh +++ b/live/operator-session/clawdie-enable-mother.sh @@ -62,17 +62,26 @@ mdo -u root sh -c ' fi ' sh "$COLIBRI_HOME" "$SSH_KEY" -# 3. Write the mother entry into the external MCP registry. +# 3. Merge the mother entry into the external MCP registry. Use jq so existing +# server entries are preserved (not overwritten), and write atomically. echo "[2/4] Registering mother in ${EXTERNAL_MCP}..." -printf '%s\n' "{ - \"servers\": { - \"mother\": { - \"command\": \"ssh\", - \"args\": [\"-i\", \"${SSH_KEY}\", \"-o\", \"BatchMode=yes\", \"-o\", \"StrictHostKeyChecking=accept-new\", \"${MOTHER_HOST}\", \"${MOTHER_CMD}\"], - \"env\": {} - } - } -}" | mdo -u root sh -c 'cat > "$1"; chmod 0644 "$1"' sh "$EXTERNAL_MCP" +if ! have jq; then + echo " ERROR: jq is required to merge the mother entry into ${EXTERNAL_MCP}." + finish 1 +fi +existing="$(mdo -u root cat "$EXTERNAL_MCP" 2>/dev/null || echo '{}')" +[ -n "$existing" ] || existing='{}' +printf '%s\n' "$existing" | + jq --arg host "$MOTHER_HOST" --arg cmd "$MOTHER_CMD" --arg key "$SSH_KEY" \ + '.servers = ((.servers // {}) + {mother: {command: "ssh", args: ["-i", $key, "-o", "BatchMode=yes", "-o", "StrictHostKeyChecking=accept-new", $host, $cmd], env: {}}})' | + mdo -u root sh -c ' + set -eu + f="$1" + tmp="$(mktemp "$(dirname "$f")/external-mcp.XXXXXX")" + cat >"$tmp" + chmod 0644 "$tmp" + mv "$tmp" "$f" + ' sh "$EXTERNAL_MCP" # 4. Allow external MCP calls: upsert COLIBRI_MCP_EXTERNAL_CALL=1 into provider.env. echo "[3/4] Enabling external MCP calls..." -- 2.45.3