Fix CLI test failures for SSE/HTTP transport configs

- Pass URL as command for SSE/HTTP configs instead of empty string
- Update runCli to pass transport type flag when needed
- Update tests to expect connection errors for non-existent SSE/HTTP servers
This commit is contained in:
Felix Weinberger 2025-08-05 14:21:18 +01:00
commit 195f79076e
No known key found for this signature in database
2 changed files with 17 additions and 6 deletions

View file

@ -744,8 +744,8 @@ async function runTests() {
"tools/list", "tools/list",
); );
// Test 26: Config with SSE transport type (CLI mode) // Test 26: Config with SSE transport type (CLI mode) - expects connection error
await runBasicTest( await runErrorTest(
"config_sse_type_cli", "config_sse_type_cli",
"--config", "--config",
sseConfigPath, sseConfigPath,
@ -756,8 +756,8 @@ async function runTests() {
"tools/list", "tools/list",
); );
// Test 27: Config with streamable-http transport type (CLI mode) // Test 27: Config with streamable-http transport type (CLI mode) - expects connection error
await runBasicTest( await runErrorTest(
"config_http_type_cli", "config_http_type_cli",
"--config", "--config",
httpConfigPath, httpConfigPath,

View file

@ -122,7 +122,18 @@ async function runCli(args: Args): Promise<void> {
}); });
try { try {
await spawnPromise("node", [cliPath, args.command, ...args.args], { // Build CLI arguments
const cliArgs = [cliPath];
// Add transport flag if specified
if (args.transport && args.transport !== "stdio") {
cliArgs.push("--transport", args.transport);
}
// Add command and remaining args
cliArgs.push(args.command, ...args.args);
await spawnPromise("node", cliArgs, {
env: { ...process.env, ...args.envArgs }, env: { ...process.env, ...args.envArgs },
signal: abort.signal, signal: abort.signal,
echoOutput: true, echoOutput: true,
@ -268,7 +279,7 @@ function parseArgs(): Args {
}; };
} else if (config.type === "sse" || config.type === "streamable-http") { } else if (config.type === "sse" || config.type === "streamable-http") {
return { return {
command: "", command: config.url,
args: finalArgs, args: finalArgs,
envArgs: options.e || {}, envArgs: options.e || {},
cli: options.cli || false, cli: options.cli || false,