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

View file

@ -122,7 +122,18 @@ async function runCli(args: Args): Promise<void> {
});
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 },
signal: abort.signal,
echoOutput: true,
@ -268,7 +279,7 @@ function parseArgs(): Args {
};
} else if (config.type === "sse" || config.type === "streamable-http") {
return {
command: "",
command: config.url,
args: finalArgs,
envArgs: options.e || {},
cli: options.cli || false,