Skip to content

Commit 98b7e63

Browse files
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
1 parent 7ea47c0 commit 98b7e63

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

cli/src/cli.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type CliOptions = {
2323
config?: string;
2424
server?: string;
2525
cli?: boolean;
26+
transport?: string;
2627
};
2728

2829
type ServerConfig =
@@ -127,7 +128,9 @@ async function runCli(args: Args): Promise<void> {
127128

128129
// Add transport flag if specified
129130
if (args.transport && args.transport !== "stdio") {
130-
cliArgs.push("--transport", args.transport);
131+
// Convert streamable-http back to http for CLI mode
132+
const cliTransport = args.transport === "streamable-http" ? "http" : args.transport;
133+
cliArgs.push("--transport", cliTransport);
131134
}
132135

133136
// Add command and remaining args
@@ -220,7 +223,8 @@ function parseArgs(): Args {
220223
)
221224
.option("--config <path>", "config file path")
222225
.option("--server <n>", "server name from config file")
223-
.option("--cli", "enable CLI mode");
226+
.option("--cli", "enable CLI mode")
227+
.option("--transport <type>", "transport type (stdio, sse, http)");
224228

225229
// Parse only the arguments before --
226230
program.parse(preArgs);
@@ -301,12 +305,19 @@ function parseArgs(): Args {
301305
// Otherwise use command line arguments
302306
const command = finalArgs[0] || "";
303307
const args = finalArgs.slice(1);
308+
309+
// Map "http" shorthand to "streamable-http"
310+
let transport = options.transport;
311+
if (transport === "http") {
312+
transport = "streamable-http";
313+
}
304314

305315
return {
306316
command,
307317
args,
308318
envArgs: options.e || {},
309319
cli: options.cli || false,
320+
transport: transport as "stdio" | "sse" | "streamable-http" | undefined,
310321
};
311322
}
312323

0 commit comments

Comments
 (0)