diff --git a/apps/wordcraft-cli/src/main.rs b/apps/wordcraft-cli/src/main.rs index 7a12dd3c32..944a66a64a 100644 --- a/apps/wordcraft-cli/src/main.rs +++ b/apps/wordcraft-cli/src/main.rs @@ -733,11 +733,12 @@ fn run>(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()); diff --git a/apps/wordcraft-cli/src/tests.rs b/apps/wordcraft-cli/src/tests.rs index 8466ef8d9c..110f3ad223 100644 --- a/apps/wordcraft-cli/src/tests.rs +++ b/apps/wordcraft-cli/src/tests.rs @@ -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}");