Skip to content

fix(mcp): exit 1 when JSON envelope contains ok:false#2995

Merged
code-yeongyu merged 2 commits intomainfrom
fix/mcp-ok-false-exit-code
May 4, 2026
Merged

fix(mcp): exit 1 when JSON envelope contains ok:false#2995
code-yeongyu merged 2 commits intomainfrom
fix/mcp-ok-false-exit-code

Conversation

@code-yeongyu
Copy link
Copy Markdown
Collaborator

Problem

claw mcp info --output-format json (and describe, list-filter) returns {"action":"error","ok":false,...} but exits 0. Automation callers checking exit code get a false success; they must inspect the ok field.

Fix

print_mcp now checks if the rendered JSON value has ok:false and calls process::exit(1) after printing, propagating the semantic error to the exit code.

Verification

claw mcp info             → ok:False  exit:1 ✅ (was 0)
claw mcp describe         → ok:False  exit:1 ✅ (was 0)
claw mcp list-filter      → action:help exit:0 ✅ (no ok field, unchanged)
claw mcp info bogus-server → ok:False exit:1 ✅ (was 0)
claw mcp list             → exit:0 ✅ (unchanged)
claw mcp show <server>    → exit:0 ✅ (unchanged)
claw mcp help             → exit:0 ✅ (unchanged)

Zero sessions created. All 12 resume tests pass; workspace test suite passes (1 intermittent flake in prompt_subcommand_allows_literal_typo_word due to pre-existing env var leak between parallel tests — not caused by this change).

Closes ROADMAP #68 (partial).

mcp info, mcp describe, and mcp list-filter all return
{"action":"error","ok":false,...} but previously exited 0,
requiring automation callers to inspect the envelope field.

After this fix: print_mcp detects ok:false in the rendered JSON
value and calls process::exit(1) after printing, so the exit code
reflects the semantic error in the envelope.

Unaffected: mcp list, mcp show, mcp help all have no ok field and
continue to exit 0 (they are not error paths).

Closes ROADMAP #68 (partial — agents bogus/mcp show nonexistent
found:false remain exit:0 as they use different envelope shapes).
…provenance

Builds claw from the current HEAD, then checks that the binary's
git_sha matches git rev-parse --short HEAD. Exits non-zero if the
binary is stale or provenance is opaque (git_sha: null).

Usage:
  CLAW=$(bash scripts/dogfood-build.sh)   # fail-fast if stale
  $CLAW version --output-format json       # provenance confirmed

Addresses ROADMAP #69: dogfooders using a stale installed binary
cannot attribute behavior to specific commits. This script makes
dogfood round zero unambiguous.

Also documents the safe workaround for contributors who have a
stale system-installed binary.
@code-yeongyu code-yeongyu merged commit d074d1c into main May 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant