mcp: --connect=… gets the --connect refusal, not unknown option (#7186)

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Martin Ball
2026-11-21 10:55:17 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 70ecef86df
commit 8a047c333b
2 changed files with 5 additions and 4 deletions
+3 -2
View File
@@ -733,11 +733,12 @@ fn run<S: AsRef<OsStr>>(args: &[S]) -> Result<(), Failure> {
}
"mcp" => {
let (roots, rest) = automation_roots("mcp", &rest)?;
validate_options("mcp", &rest, MCP_OPTIONS)?;
// Refused with or without a value: a bare trailing `--connect` must not slip past.
// Refused with or without a value, before the option check, so `--connect=…` gets this refusal rather than
// "unknown option": a bare trailing `--connect` must not slip past either.
if rest.iter().any(|a| a == "--connect" || a.starts_with("--connect=")) {
return Err(MCP_CONNECT_REFUSED.into());
}
validate_options("mcp", &rest, MCP_OPTIONS)?;
// Shared rule 18 (#7124): an agent entry point never runs unconfined.
let Some(roots) = roots.filter(|r| r.read_root().is_some() && r.write_root().is_some()) else {
return Err(MCP_NEEDS_ROOTS.into());
+2 -2
View File
@@ -331,13 +331,13 @@ fn mcp_headless_session_takes_the_author_flag() {
assert_eq!(unnamed.session.author, wordcraft_mcp::Headless::default().session.author, "no flag keeps the default author");
}
/// `--connect` is refused whether or not it has a value, even with both roots valid.
/// `--connect` is refused whether or not it has a value, written apart or as `--connect=…`, even with both roots valid.
#[test]
fn mcp_connect_is_refused_without_a_value_too() {
let scratch = Scratch::new("connect-bare");
let dir = scratch.0.to_string_lossy().into_owned();
let roots = ["--automation-read-root", &dir, "--automation-write-root", &dir];
for tail in [vec!["--connect"], vec!["--connect", "--author", "Claude"]] {
for tail in [vec!["--connect"], vec!["--connect", "--author", "Claude"], vec!["--connect=127.0.0.1:9"], vec!["--connect="]] {
let line = args(&[&["mcp"][..], &roots, &tail].concat());
let e = run(&line).unwrap_err().to_string();
assert!(e.contains("--connect") && e.contains("#3695") && e.contains("#5819"), "{line:?}: {e}");