From 98b7e63bb032b6aae4767712af4359594271a29a Mon Sep 17 00:00:00 2001 From: Felix Weinberger Date: Wed, 6 Aug 2025 19:50:23 +0100 Subject: [PATCH] Add --transport flag support to CLI - Add --transport option to command line parser - Support --transport stdio/sse/http flags - Convert 'http' to 'streamable-http' internally - Fix transport type conversion for CLI mode --- cli/src/cli.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cli/src/cli.ts b/cli/src/cli.ts index df16f0cc..6c72e6a4 100644 --- a/cli/src/cli.ts +++ b/cli/src/cli.ts @@ -23,6 +23,7 @@ type CliOptions = { config?: string; server?: string; cli?: boolean; + transport?: string; }; type ServerConfig = @@ -127,7 +128,9 @@ async function runCli(args: Args): Promise { // Add transport flag if specified if (args.transport && args.transport !== "stdio") { - cliArgs.push("--transport", args.transport); + // Convert streamable-http back to http for CLI mode + const cliTransport = args.transport === "streamable-http" ? "http" : args.transport; + cliArgs.push("--transport", cliTransport); } // Add command and remaining args @@ -220,7 +223,8 @@ function parseArgs(): Args { ) .option("--config ", "config file path") .option("--server ", "server name from config file") - .option("--cli", "enable CLI mode"); + .option("--cli", "enable CLI mode") + .option("--transport ", "transport type (stdio, sse, http)"); // Parse only the arguments before -- program.parse(preArgs); @@ -301,12 +305,19 @@ function parseArgs(): Args { // Otherwise use command line arguments const command = finalArgs[0] || ""; const args = finalArgs.slice(1); + + // Map "http" shorthand to "streamable-http" + let transport = options.transport; + if (transport === "http") { + transport = "streamable-http"; + } return { command, args, envArgs: options.e || {}, cli: options.cli || false, + transport: transport as "stdio" | "sse" | "streamable-http" | undefined, }; }