fix(cli): escape pretty-format strings, dedupe not-found error, respect --format in setup#170
Merged
Merged
Conversation
…ct --format in setup - pretty::format_value hand-wrapped string values and object keys in literal quotes without JSON escaping, producing invalid JSON whenever a value or key contained a quote, backslash, newline, or control character. Both are now serialized through serde_json::to_string before colorizing (#163). - show_server_info double-wrapped the not-found error from get_mcp_server with a redundant, incomplete context, printing the same message twice in the error chain. It now propagates the original error directly (#164). - setup ignored the global --format flag and always printed fixed plain text. It now returns a structured SetupResult routed through format_output, so json/text produce structured output while pretty keeps the existing human-readable summary (#165).
…mat-bugs # Conflicts: # CHANGELOG.md
bug-ops
enabled auto-merge (squash)
July 9, 2026 19:20
dirs::home_dir() on Windows resolves via SHGetKnownFolderPath, a Win32 API that reads the real OS user profile and ignores HOME (or any other env var) entirely. The regression test's HOME-redirection trick therefore cannot work on Windows: it consistently reached the real (nonexistent) profile path in CI and failed at the earlier "read config file" step instead of exercising the not-found branch the test targets. Gate the test to #[cfg(unix)], matching the existing chmod-related unix gating in setup.rs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three independent bugs in
crates/mcp-cli, grouped into one PR since they share the same subsystem and have no cross-dependencies:prettyoutput formatter hand-wrapped string values and object keys in literal quotes without JSON-escaping, producing invalid JSON whenever a value/key contained a quote, backslash, newline, or control character (e.g.server validateagainst an unknown server, orintrospect --detailedrendering remote-server-controlled schema keys). Both paths now go throughserde_json::to_stringbefore colorizing, matching thejson/textformatters.server infoon an unknown server printed the not-found error twice (a redundant, incompletewith_contextwrap around the already-complete error fromget_mcp_server).show_server_infonow propagates the original error directly, matchingintrospect/generate.setupignored the global--formatflag and always printed fixed plain text. It now returns a structuredSetupResultrouted throughformat_output, so--format json/textproduce structured output while the defaultprettyformat keeps the existing human-readable summary.Test plan
cargo +nightly fmt --checkcargo +stable clippy --all-targets --all-features --workspace -- -D warningscargo nextest run --all-features --workspace --no-fail-fast(735 passed)cargo test --doc --all-features --workspaceRUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps