From 64f92b156004058cd60245ed74f11ccf95584b1e Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Tue, 5 May 2026 06:05:28 +0900 Subject: [PATCH] fix(mcp): exit 1 when JSON envelope contains ok:false MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- rust/crates/rusty-claude-cli/src/main.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index d3ee789b..a4ff9bc9 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -5107,10 +5107,17 @@ impl LiveCli { let cwd = env::current_dir()?; match output_format { CliOutputFormat::Text => println!("{}", handle_mcp_slash_command(args, &cwd)?), - CliOutputFormat::Json => println!( - "{}", - serde_json::to_string_pretty(&handle_mcp_slash_command_json(args, &cwd)?)? - ), + CliOutputFormat::Json => { + let value = handle_mcp_slash_command_json(args, &cwd)?; + // Propagate ok:false → non-zero exit so automation callers + // can rely on exit code instead of inspecting the envelope. + // (#68: mcp error envelopes previously always exited 0.) + let is_error = value.get("ok").and_then(|v| v.as_bool()) == Some(false); + println!("{}", serde_json::to_string_pretty(&value)?); + if is_error { + std::process::exit(1); + } + } } Ok(()) }