use std::process::Command;
const SERVER_CMD: &str = "npx -y @upstash/context7-mcp";
fn live_enabled() -> bool {
std::env::var("SCC_CONTEXT7_LIVE").map(|v| v == "1").unwrap_or(false)
}
#[test]
#[ignore = "needs network + npx; run with SCC_CONTEXT7_LIVE=1"]
fn real_context7_server_protocol_compatibility() {
if !live_enabled() {
eprintln!("skipping: set SCC_CONTEXT7_LIVE=1 to run the live Context7 suite");
return;
}
let probe = Command::new("sh")
.arg("-c")
.arg(format!("{SERVER_CMD} --help"))
.output()
.expect("spawn context7");
assert!(
probe.status.success(),
"context7 server must launch: {}",
String::from_utf8_lossy(&probe.stderr)
);
let mut client = scc_indexer::adapters::context7::start(
SERVER_CMD,
&std::env::current_dir().expect("cwd"),
)
.expect("MCP handshake with the real server");
let docs = client
.docs_for("react")
.expect("library-search + query-docs must succeed against the real server");
assert!(
docs.contains("CONTEXT7 EXTERNAL DOCUMENTATION"),
"labeled external docs marker: {docs}"
);
assert!(
docs.to_ascii_lowercase().contains("react"),
"docs must mention the library: {docs}"
);
}
#[test]
#[ignore = "needs network + npx; run with SCC_CONTEXT7_LIVE=1"]
fn real_context7_server_rejects_unknown_library_gracefully() {
if !live_enabled() {
return;
}
let mut client = scc_indexer::adapters::context7::start(
SERVER_CMD,
&std::env::current_dir().expect("cwd"),
)
.expect("MCP handshake with the real server");
let result = client.docs_for("this-library-does-not-exist-xyz-12345");
let _ = result;
}