Skip to content

refactor(mcp): replace bool parameters with type-safe enums in McpClient connect paths#6614

Merged
bug-ops merged 1 commit into
mainfrom
fix/6478-mcp-bool-param-order-swap
Jul 20, 2026
Merged

refactor(mcp): replace bool parameters with type-safe enums in McpClient connect paths#6614
bug-ops merged 1 commit into
mainfrom
fix/6478-mcp-bool-param-order-swap

Conversation

@bug-ops

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

Copy link
Copy Markdown
Owner

Summary

  • McpClient::connect took two adjacent positional bool parameters (suppress_stderr, env_isolation). Replaced with StderrPolicy (Forward/Suppress) and EnvPolicy (InheritAll/Isolated) so a future signature edit can no longer silently swap stderr verbosity with the parent-environment-inheritance control.
  • connect_url / connect_url_with_headers / connect_url_oauth took a bare trusted: bool, downgraded from McpTrustLevel at the only call site. They now take McpTrustLevel directly and match on it internally, so the SSRF private-IP bypass check is gated by the enum instead of a bool that discarded which variant it came from.
  • No runtime behavior change — this is a pure type-safety refactor. Breaking change to zeph-mcp's public API; documented in CHANGELOG.md.

Closes #6478

Test plan

  • cargo +nightly fmt --check
  • cargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warnings
  • cargo nextest run --config-file .github/nextest.toml -p zeph-mcp --features "mock,profiling" — 563 passed, 0 failed (561 pre-existing + 2 new)
  • RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --all-features -p zeph-mcp clean
  • cargo test --doc -p zeph-mcp — all doctests pass, including the two new ones on StderrPolicy/EnvPolicy
  • Added connect_url_untrusted_blocks_private_ip / connect_url_trusted_skips_ssrf_check — exercise McpTrustLevel at the actual changed public connect_url signature (SSRF check runs before any I/O, so no real MCP server needed)
  • gitleaks protect --staged — no leaks

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes refactor Code refactoring without functional changes size/M Medium PR (51-200 lines) labels Jul 20, 2026
…ient connect paths

McpClient::connect took two adjacent positional bools (suppress_stderr,
env_isolation); connect_url/connect_url_with_headers/connect_url_oauth took a
bare trusted bool downgraded from McpTrustLevel at the call site. Both shapes
let a future signature edit silently swap security-relevant behavior (full
parent-env inheritance, SSRF private-IP bypass) without a compiler error.

Replace the two connect() bools with StderrPolicy and EnvPolicy enums, and
pass McpTrustLevel through connect_url* directly instead of collapsing it to
bool beforehand. No runtime behavior change.

BREAKING CHANGE: McpClient::connect now takes StderrPolicy/EnvPolicy instead
of two bools; connect_url/connect_url_with_headers/connect_url_oauth now take
McpTrustLevel instead of trusted: bool.

Closes #6478
@bug-ops
bug-ops force-pushed the fix/6478-mcp-bool-param-order-swap branch from cb5ed26 to 3817075 Compare July 20, 2026 21:28
@bug-ops
bug-ops enabled auto-merge (squash) July 20, 2026 21:28
@bug-ops
bug-ops merged commit 309cd44 into main Jul 20, 2026
43 checks passed
@bug-ops
bug-ops deleted the fix/6478-mcp-bool-param-order-swap branch July 20, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation refactor Code refactoring without functional changes rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zeph-mcp: adjacent bool parameters in McpClient::connect/connect_url risk order-swap regression

1 participant