# Release script safety checklist for MCP connectors and small sites Version 1.1, November 25, 2026 (1.1 adds "After the release: real clients" to section 1). Companion guide: https://jwatte.com/blog/change-live-mcp-connector-without-breaking-it/ Written by J.A. Watte, jwatte.com. Free to copy, adapt and ship. No attribution required. A one-command publish script is only as safe as its worst interruption. Use this file to write or review one. Hand it to your developer, or paste it to an AI coding agent with your current script and ask it to report every requirement below as MET, NOT MET or NOT APPLICABLE, with the line that proves it. Replace every ALL-CAPS placeholder. Every failure case in section 3 happened to us, in scripts whose own tests passed. Independent reviewers found all of them with harnesses of their own. ## 1. Requirements **Modes** - [ ] `--check` is truly read-only: it creates no file, writes no evidence file, takes no lock and changes nothing. A check mode that writes evidence files is not read-only. Read the lock with a shared, non-blocking attempt, and only if the lock file already exists. - [ ] `--publish` does the release. Optional `--finish` repeats only the steps after a passed live check. - [ ] Refuse to run during windows when a scheduled job regenerates what the checks compare: BLOCKED_HOURS_UTC. **Guards before anything changes** - [ ] Take an exclusive lock (`flock -n` or `flock -w SECONDS`) on LOCK_FILE that every release script for this site shares. - [ ] Refuse while another deploy or release is running. Find it by process id and working directory, and never kill a process you did not start. - [ ] Read what is published now and record it as the base. Refuse if it is not what you tested against. - [ ] Refuse if the source branch moved since you tested. Print how to rebase. - [ ] Compare dated documents, not "latest" ones, when a check reads something a scheduled job can regenerate between two reads. **Publish** - [ ] Publish the artifact you tested, or rebuild it from the tested commit and prove it answers the same before deploying. - [ ] If the host has deploy contexts with different environment variables, publish in the context the functions need. See netlify-published-preview-env-check.md. - [ ] Record your deploy's id in the journal as soon as it is known. - [ ] Run a live check first after publishing, including anything that reads the environment. Retry it with a pause that respects the site's rate limit. **Rollback** - [ ] Restore the base only while the published deploy is still your own. If someone else's deploy is live, touch nothing and say so. - [ ] The exit handler ignores INT, TERM, HUP and PIPE before it does anything else. A second Ctrl-C must not abort a restore. - [ ] The rollback never needs stdout. It writes to the log file directly and ignores write errors. - [ ] Retry the restore and confirm it by reading what is published. Node child processes reset signal dispositions, so a shell-level ignore does not protect a restore made through node. - [ ] Print the one restore command a person can run by hand if the automatic restore fails. - [ ] After an interrupted deploy, do not trust the first read. The host can finish and publish a deploy after your client is gone. Watch the published deploy for longer than your host's processing time, or cancel the deploy by id, before reporting that no rollback is needed. - [ ] On a site where a push to main is itself the release, a rollback must also revert main, or the next push republishes the release. **Records** - [ ] A small journal of your own attempt (key=value lines). Never use a guard such as "this draft was never published": after any rollback the host keeps the publish date, so one transient failure would disable the script for good. - [ ] Set a "pushed" marker only after the remote confirms the new commit, never before `git push` runs. - [ ] A status file with one final line: OK, FAILED with the stage, or STOPPED before any deploy. - [ ] Order the final steps so each check can pass when it runs. A suite that checks "registry version equals live version" cannot pass before the registry record is published. - [ ] Registry search answers can lag a confirmed publish. We saw more than 65 seconds once. Re-run a version-drift check before treating it as a fault. **After the release: real clients** (a person does these; a script cannot) - [ ] Ask real questions through each published assistant, in each language you serve, in a fresh chat, and open every link in the answers. Our connectors had passed more than 1,600 scenario checks with 0 failures, and this walk still found twelve things. The steps are in https://jwatte.com/downloads/mcp-real-client-walk-checklist.md - [ ] Validate live answers against the previous release's output schemas. A chat session that loaded the old tool list keeps it. See https://jwatte.com/downloads/mcp-model-in-the-loop-test.md, section 10. - [ ] Every probe in the live check sends the `MCP-Protocol-Version` header that real clients send. A server that declares output schemas only with the header looks schema-less to a probe without it. - [ ] Live data tools (availability, status, queues): every size or type is listed, with an explicit zero when nothing is open; times come with a ready-made local-time string for the business next to the UTC value; a one-off read failure is retried once and then answered with a clearly labeled last-good snapshot, not a bare error. **Running it** - [ ] Run the publish detached from your terminal, for example `setsid nohup bash SCRIPT --publish >/dev/null 2>&1 &` or inside `tmux`, then read its log. Output still goes through `tee` to the log. **Push-to-deploy sites** (where a push to main publishes): stop auto publishing first, push, test the production build through its own deploy address, publish that build, then turn auto publishing back on. ## 2. The SIGPIPE trap, in one paragraph When a script sends its output through `tee` and the terminal goes away (a dropped SSH session, or TERM or HUP to the process group), the next write to stdout raises SIGPIPE. Its default action is to terminate the process (signal(7)). If the first thing your exit trap does is `echo`, bash dies there, before the rollback, and the new deploy stays live. In our old script, 7 of 11 interruption cases ended that way. The fix: `trap '' PIPE` right after the `exec` and `tee` line, `PIPE` in the ignore list at the top of the exit handler, and a rollback that logs to a file descriptor of its own. After the fix, none of the 11 cases left the new deploy live. GNU tee's `--output-error=warn` keeps it writing the log after stdout is gone. ## 3. Failure cases to simulate before the first real release | # | Simulate | Expected | |---|---|---| | 1 | Normal run | Our deploy is live; status OK | | 2 | Live check fails | Base restored; status FAILED | | 3 | Stdout closed at once (`bash SCRIPT --publish \| head -c 0`) with a failing live check | Base restored; the rollback is in the log | | 4 | HUP to the process group during the deploy | Base restored | | 5 | TERM to the process group during the deploy | Base restored | | 6 | INT (Ctrl-C) during the deploy | Base restored | | 7 | A second INT while the restore runs | Restore completes | | 8 | Someone else publishes during the run, then the live check fails | Their deploy stays live, untouched | | 9 | A retry after a rolled-back run | Works; no guard stays tripped | | 10 | Another deploy already running | Refuses before any change | | 11 | `--check` | Creates and changes no file | | 12 | `git push` rejected | No restore is triggered by a stale marker | | 13 | Registry search lags the publish | Drift check re-runs before failing | | 14 | A restore call made through node is interrupted | The script retries and confirms | | 15 | The deploy is interrupted and the host publishes it a few seconds later | Base restored; never "not needed" | | 16 | A colleague publishes again a deploy that an earlier run of yours created, then your live check fails | Their publish stays live: only ids recorded by this run count as yours | ## 4. Skeleton: release.sh Every call that touches the host goes through an `ext_*` function, so a harness can replace them. Fill in the bodies for your host. Bash 4 or later, util-linux `flock` and GNU coreutils `tee` 8.24 or later. ```bash #!/bin/bash # release.sh: skeleton of a guarded publish script. Modes: --check (read-only) and --publish. # Replace every ext_* body with your host's real calls. A harness can replace them by setting HARNESS=file. set -euo pipefail MODE=${1:---check} STATE_DIR=${STATE_DIR:-$HOME/release-state} LOG=$STATE_DIR/release.log JOURNAL=$STATE_DIR/release.journal STATUS=$STATE_DIR/release.status LOCK=$STATE_DIR/release.lock # ---- output. say: normal output (through tee in --publish). hlog: exit handler and rollback ONLY. # hlog writes the log file directly (fd 3) and the original stdout (fd 4); every write error is ignored. hlog() { { printf '%s %s\n' "$(date -u +%H:%M:%SZ)" "$*" >&3; } 2>/dev/null || true; { printf '%s\n' "$*" >&4; } 2>/dev/null || true; } say() { printf '%s\n' "$*"; } die() { say "STOP: $*"; exit 1; } jset() { { printf '%s=%s\n' "$1" "$2" >>"$JOURNAL"; } 2>/dev/null || hlog "WARNING: journal write failed"; } jlast() { [ -f "$JOURNAL" ] && grep "^$1=" "$JOURNAL" | tail -1 | cut -d= -f2- || true; } status() { { printf '%s %s\n' "$(date -u +%FT%TZ)" "$*" >"$STATUS"; } 2>/dev/null || true; } # ---- external effects (the only functions that touch the host, the repository or the live site) ext_published() { echo "PUBLISHED_DEPLOY_ID"; } # print the id of the deploy that is live now ext_deploy() { echo "DEPLOY THE TESTED ARTIFACT"; } # deploy the artifact you tested; jset ours as soon as the id is known ext_restore() { echo "RESTORE $1"; } # publish deploy $1 again ext_is_ours() { return 1; } # host-specific: was deploy $1 created by this run? ext_live_check() { true; } # check the live site, including anything that reads the environment ext_other_deploy_running() { return 1; } # another release or deploy in progress? [ -n "${HARNESS:-}" ] && . "$HARNESS" BASE=""; OURS=""; STAGE=guards; DEPLOY_STARTED=0; LIVE_OK=0; DEPLOY_PID="" is_ours() { # only an id recorded since this run's own "run=" line counts [ -n "$1" ] && { awk -v want="ours=$1" '/^run=/{f=0} $0==want{f=1} END{exit !f}' "$JOURNAL" 2>/dev/null || ext_is_ours "$1"; } } rollback() { # restore BASE only while the published deploy is still OURS local pub="" i for i in 1 2 3; do pub=$(ext_published 2>/dev/null) && [ -n "$pub" ] && break; sleep 2; done if [ -z "$pub" ]; then hlog "ROLLBACK: cannot read the published deploy; restore $BASE by hand only if ours is live"; return 3; fi if [ "$pub" = "$BASE" ]; then # an interrupted deploy can still be finished by the host: watch before trusting it for i in $(seq 1 "${SETTLE_TRIES:-6}"); do sleep "${SETTLE_PAUSE:-10}"; pub=$(ext_published 2>/dev/null) || pub="" [ "$pub" = "$BASE" ] || break done if [ "$pub" = "$BASE" ]; then hlog "ROLLBACK: not needed, $BASE is still live after the settle wait"; jset rolled_back "none"; return 0; fi if [ -z "$pub" ]; then hlog "ROLLBACK: cannot read the published deploy; restore $BASE by hand only if ours is live"; return 3; fi fi if ! is_ours "$pub"; then hlog "ROLLBACK: someone else's deploy $pub is live; NOT TOUCHED"; jset rolled_back "foreign:$pub"; return 3; fi for i in 1 2 3; do # retry: a restore made through a child process can still be cut short ext_restore "$BASE" >/dev/null 2>&1 || hlog " restore call failed (try $i)" sleep 2 pub=$(ext_published 2>/dev/null) || pub="" if [ "$pub" = "$BASE" ]; then hlog "ROLLBACK: restored $BASE"; jset rolled_back "$BASE"; return 0; fi if [ -n "$pub" ] && ! is_ours "$pub"; then hlog "ROLLBACK: someone else's deploy $pub became live; NOT TOUCHED"; return 3; fi done hlog "ROLLBACK FAILED: live is $pub. Restore by hand: RESTORE_COMMAND $BASE"; return 4 } on_signal() { trap '' INT TERM HUP; hlog "INTERRUPTED by SIG$1 (stage: $STAGE)"; exit 130; } on_exit() { local rc=$? r=0 trap '' INT TERM HUP PIPE # nothing may interrupt the rollback set +e if [ -n "$DEPLOY_PID" ]; then kill -TERM "$DEPLOY_PID" 2>/dev/null; wait "$DEPLOY_PID" 2>/dev/null; fi # our own child only if [ "$DEPLOY_STARTED" = 1 ] && [ "$LIVE_OK" != 1 ]; then hlog "FAILED after the deploy started (stage: $STAGE, exit $rc): rolling back" rollback; r=$? status "FAILED stage=$STAGE rollback=$r live=$(ext_published 2>/dev/null)" exit $(( rc ? rc : 1 )) fi if [ "$LIVE_OK" = 1 ]; then status "OK published=$OURS" elif [ "$MODE" = --publish ]; then status "STOPPED before any deploy (stage: $STAGE, exit $rc)"; fi exit "$rc" } check() { # read-only: creates and writes no file at all say "published now: $(ext_published)" ext_other_deploy_running && say "another deploy is running: --publish would refuse" || say "no other deploy running" if [ ! -e "$LOCK" ] || flock -n -s "$LOCK" true 2>/dev/null; then say "lock: free"; else say "lock: HELD"; fi # never creates the file say "CHECK OK" } publish() { mkdir -p "$STATE_DIR" exec 9>"$LOCK"; flock -n 9 || die "another release holds $LOCK" exec 3>>"$LOG" 4>&1 exec > >(trap '' INT TERM HUP PIPE; exec tee --output-error=warn -a "$LOG" 2>/dev/null) 2>&1 trap '' PIPE trap on_exit EXIT; trap 'on_signal INT' INT; trap 'on_signal TERM' TERM; trap 'on_signal HUP' HUP status "RUNNING pid $$" jset run "$(date -u +%FT%TZ) pid $$" ext_other_deploy_running && die "another deploy is running" BASE=$(ext_published); [ -n "$BASE" ] || die "cannot read the published deploy" jset base "$BASE" STAGE=deploy; DEPLOY_STARTED=1 ext_deploy & DEPLOY_PID=$! # in the background, so a signal is handled at once wait "$DEPLOY_PID" || { DEPLOY_PID=""; die "deploy failed"; } DEPLOY_PID="" OURS=$(jlast ours) [ -n "$OURS" ] && [ "$(ext_published)" = "$OURS" ] || die "our deploy is not the published one" STAGE="live check" ext_live_check "$OURS" || die "live check failed" LIVE_OK=1; jset live_ok "$OURS" say "published $OURS (previous $BASE)" exit 0 } case "$MODE" in --check) check ;; --publish) publish ;; *) echo "use --check or --publish" >&2; exit 2 ;; esac ``` Started with stdout already closed (`>&-`), the skeleton exits 1 before any deploy and writes no status file. ## 5. Harness that needs no external effects `fake-host.sh` replaces the `ext_*` functions with a folder that plays the host. `harness.sh` runs cases 1 to 11, 15 and 16 from section 3 and checks what is "live" afterwards. It needs bash, util-linux and python3 (only to start the script with default signal handling). ```bash # fake-host.sh: harness stubs for release.sh. No network, no real host: the "host" is a folder. # Knobs: FAKE (folder), DEPLOY_SLEEP, FAIL_LIVE=1, FOREIGN=1 (someone else publishes during the run), RESTORE_SLEEP, # HOST_LATE=N (the host publishes our deploy N seconds later, even if the client is gone), # COLLEAGUE=ID (a colleague publishes deploy ID during the run) ext_published() { cat "$FAKE/published"; } ext_deploy() { local id="d$RANDOM$RANDOM"; jset ours "$id" if [ -n "${HOST_LATE:-}" ]; then setsid bash -c "sleep $HOST_LATE; echo $id >'$FAKE/published'" >/dev/null 2>&1 & else echo "$id" >"$FAKE/published"; fi sleep "${DEPLOY_SLEEP:-0}" [ "${FOREIGN:-0}" = 1 ] && echo other-person >"$FAKE/published" [ -n "${COLLEAGUE:-}" ] && echo "$COLLEAGUE" >"$FAKE/published" true } ext_restore() { sleep "${RESTORE_SLEEP:-0}"; echo "$1" >"$FAKE/published"; } ext_live_check() { [ "${FAIL_LIVE:-0}" != 1 ]; } ext_other_deploy_running() { [ -f "$FAKE/other-running" ]; } ``` ```bash #!/bin/bash # harness.sh: runs release.sh against fake-host.sh in throwaway folders and checks what is "live" afterwards. set -u export SETTLE_TRIES=3 SETTLE_PAUSE=1 cd "$(dirname "$0")" pass=0; fail=0 setup() { T=$(mktemp -d); export FAKE=$T STATE_DIR=$T/state HARNESS=$PWD/fake-host.sh; echo base >"$T/published"; } expect() { local want=$1 got; got=$(cat "$FAKE/published"); if [ "$got" = "$want" ] || { [ "$want" = OURS ] && [ "$got" = "$(grep '^ours=' "$STATE_DIR/release.journal" | tail -1 | cut -d= -f2)" ]; }; then pass=$((pass+1)); echo "PASS $2 (live: $got)"; else fail=$((fail+1)); echo "FAIL $2 (live: $got, wanted $want)"; fi; } # Start release.sh in its own process group with default signal handling. A plain "cmd &" from a # script starts it with SIGINT ignored, and bash cannot trap a signal ignored on entry, so INT tests would prove nothing. launch() { python3 -c 'import os,signal,sys; signal.signal(signal.SIGINT,signal.SIG_DFL); os.setsid(); os.execvp("bash",["bash","release.sh","--publish"])' >"$FAKE/out" 2>&1 & PID=$!; } setup; bash release.sh --publish >/dev/null 2>&1; expect OURS "success leaves our deploy live" setup; FAIL_LIVE=1 bash release.sh --publish >/dev/null 2>&1; expect base "failed live check restores the base" setup; FAIL_LIVE=1 bash release.sh --publish 2>&1 | head -c 0; sleep 3; expect base "stdout closed at once (dropped terminal), still rolls back" grep -q 'ROLLBACK: restored base' "$STATE_DIR/release.log" && { pass=$((pass+1)); echo "PASS rollback is in the log with no stdout"; } || { fail=$((fail+1)); echo "FAIL rollback missing from log"; } for sig in HUP TERM INT; do setup; DEPLOY_SLEEP=4 launch; sleep 1.5 kill -"$sig" -- -"$PID" 2>/dev/null; wait "$PID" 2>/dev/null; sleep 1; expect base "SIG$sig to the process group during the deploy rolls back" done setup; FAIL_LIVE=1 RESTORE_SLEEP=2 launch; sleep 1.2 kill -INT -- -"$PID" 2>/dev/null; sleep 0.5; kill -INT -- -"$PID" 2>/dev/null; wait "$PID" 2>/dev/null; sleep 5; expect base "second Ctrl-C during the rollback does not abort it" setup; FOREIGN=1 FAIL_LIVE=1 bash release.sh --publish >/dev/null 2>&1; expect other-person "someone else's publish is never overwritten" setup; FAIL_LIVE=1 bash release.sh --publish >/dev/null 2>&1; bash release.sh --publish >/dev/null 2>&1; expect OURS "a retry after a rollback still works" setup; touch "$FAKE/other-running"; bash release.sh --publish >/dev/null 2>&1; expect base "refuses while another deploy runs" setup; before=$(find "$FAKE" | wc -l); bash release.sh --check >/dev/null; after=$(find "$FAKE" | wc -l) [ "$before" = "$after" ] && { pass=$((pass+1)); echo "PASS --check writes no files"; } || { fail=$((fail+1)); echo "FAIL --check wrote files"; } setup; bash release.sh --publish >/dev/null 2>&1; grep -q '^.* OK published=' "$STATE_DIR/release.status" && { pass=$((pass+1)); echo "PASS status file records the outcome"; } || { fail=$((fail+1)); echo "FAIL status file"; } setup; HOST_LATE=2 DEPLOY_SLEEP=5 launch; sleep 1 kill -INT -- -"$PID" 2>/dev/null; wait "$PID" 2>/dev/null; sleep 4; expect base "case 15: the host publishes an interrupted deploy later, base still restored" grep -q 'ROLLBACK: restored base' "$STATE_DIR/release.log" && { pass=$((pass+1)); echo "PASS case 15 reports a restore, not \"not needed\""; } || { fail=$((fail+1)); echo "FAIL case 15 log"; } setup; bash release.sh --publish >/dev/null 2>&1; A=$(cat "$FAKE/published"); echo colleague-c >"$FAKE/published" COLLEAGUE=$A FAIL_LIVE=1 bash release.sh --publish >/dev/null 2>&1; expect "$A" "case 16: an id from an earlier run is not treated as ours" echo "harness: $pass passed, $fail failed"; [ "$fail" = 0 ] ``` Run it with `bash harness.sh` in a folder holding all three files. Add cases 12 to 14 with stubs for your own push, registry and restore calls. A useful test of the harness itself: delete `PIPE` from the `trap` line at the top of `on_exit` and from `trap '' PIPE` in `publish`, then run it again. Case 3 must now fail with the new deploy left live. If it still passes, your harness is not testing the SIGPIPE path. ## Sources and what was checked - Bash `trap`: a null action makes the shell and the commands it invokes ignore the signal; signals ignored on entry to a non-interactive shell cannot be trapped or reset: https://www.gnu.org/software/bash/manual/bash.html (read November 24, 2026). This is why the harness starts the script with python3: a plain `cmd &` in a script starts it with SIGINT ignored. - SIGPIPE default action Term: https://man7.org/linux/man-pages/man7/signal.7.html. flock options `-n`, `-w`, `-s`: https://man7.org/linux/man-pages/man1/flock.1.html. setsid: https://man7.org/linux/man-pages/man1/setsid.1.html (all read November 24, 2026). - `tee --output-error=warn`: checked with `tee --help` from GNU coreutils on Ubuntu, November 24, 2026. - The skeleton and harness were run on November 24, 2026 with bash 5 on Linux: 16 of 16 harness checks passed, including cases 15 and 16. With the PIPE guards removed, case 3 failed and left the new deploy live, as described above. With the earlier `is_ours` (any id ever recorded) and an immediate "not needed" when the base still read as live, cases 15 and 16 failed. The harness first caught two faults in an earlier draft of this skeleton: its `--check` created the lock file, and its INT tests passed only because the script had been started with SIGINT ignored. - The failure cases come from our own MCP releases of November 23 and 24, 2026, described in the companion guide. The "After the release: real clients" items come from our own walk through ChatGPT and Claude on November 25, 2026 (UTC). *Informational only. Run a release script against a real host only after the harness passes, and only on sites you operate.*