feat(enable-mother): jq-merge the mother entry instead of overwriting #98
1 changed files with 19 additions and 10 deletions
|
|
@ -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..."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue