Skip to content

fix(cli): escape pretty-format strings, dedupe not-found error, respect --format in setup#170

Merged
bug-ops merged 4 commits into
masterfrom
163-164-165-cli-format-bugs
Jul 9, 2026
Merged

fix(cli): escape pretty-format strings, dedupe not-found error, respect --format in setup#170
bug-ops merged 4 commits into
masterfrom
163-164-165-cli-format-bugs

Conversation

@bug-ops

@bug-ops bug-ops commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Summary

Three independent bugs in crates/mcp-cli, grouped into one PR since they share the same subsystem and have no cross-dependencies:

Test plan

  • cargo +nightly fmt --check
  • cargo +stable clippy --all-targets --all-features --workspace -- -D warnings
  • cargo nextest run --all-features --workspace --no-fail-fast (735 passed)
  • cargo test --doc --all-features --workspace
  • RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps
  • Manual repro verification for all three issues (server validate on unknown server produces valid JSON after ANSI-strip; server info on unknown server prints a single error; setup --format json produces structured output, default pretty unchanged)
  • Independent code review pass (rust-code-reviewer) re-ran the full CI suite from scratch and confirmed all green

…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).
@github-actions github-actions Bot added area: cli CLI commands and interface crate: mcp-cli Changes to mcp-cli crate (command-line interface) type: documentation Documentation changes (*.md, docs/, comments) type: dependencies Dependency updates (Cargo.toml, Cargo.lock) breaking change Contains breaking API changes (requires major version bump) release Release preparation (changelog, version bumps) labels Jul 9, 2026
@bug-ops
bug-ops enabled auto-merge (squash) July 9, 2026 19:20
bug-ops added 2 commits July 9, 2026 21:26
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.
@bug-ops
bug-ops merged commit 7cd6149 into master Jul 9, 2026
17 checks passed
@bug-ops
bug-ops deleted the 163-164-165-cli-format-bugs branch July 9, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI commands and interface breaking change Contains breaking API changes (requires major version bump) crate: mcp-cli Changes to mcp-cli crate (command-line interface) release Release preparation (changelog, version bumps) type: dependencies Dependency updates (Cargo.toml, Cargo.lock) type: documentation Documentation changes (*.md, docs/, comments)

Projects

None yet

1 participant