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
This commit is contained in:
parent
7ea47c0caa
commit
98b7e63bb0
1 changed files with 13 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ type CliOptions = {
|
||||||
config?: string;
|
config?: string;
|
||||||
server?: string;
|
server?: string;
|
||||||
cli?: boolean;
|
cli?: boolean;
|
||||||
|
transport?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ServerConfig =
|
type ServerConfig =
|
||||||
|
|
@ -127,7 +128,9 @@ async function runCli(args: Args): Promise<void> {
|
||||||
|
|
||||||
// Add transport flag if specified
|
// Add transport flag if specified
|
||||||
if (args.transport && args.transport !== "stdio") {
|
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
|
// Add command and remaining args
|
||||||
|
|
@ -220,7 +223,8 @@ function parseArgs(): Args {
|
||||||
)
|
)
|
||||||
.option("--config <path>", "config file path")
|
.option("--config <path>", "config file path")
|
||||||
.option("--server <n>", "server name from config file")
|
.option("--server <n>", "server name from config file")
|
||||||
.option("--cli", "enable CLI mode");
|
.option("--cli", "enable CLI mode")
|
||||||
|
.option("--transport <type>", "transport type (stdio, sse, http)");
|
||||||
|
|
||||||
// Parse only the arguments before --
|
// Parse only the arguments before --
|
||||||
program.parse(preArgs);
|
program.parse(preArgs);
|
||||||
|
|
@ -301,12 +305,19 @@ function parseArgs(): Args {
|
||||||
// Otherwise use command line arguments
|
// Otherwise use command line arguments
|
||||||
const command = finalArgs[0] || "";
|
const command = finalArgs[0] || "";
|
||||||
const args = finalArgs.slice(1);
|
const args = finalArgs.slice(1);
|
||||||
|
|
||||||
|
// Map "http" shorthand to "streamable-http"
|
||||||
|
let transport = options.transport;
|
||||||
|
if (transport === "http") {
|
||||||
|
transport = "streamable-http";
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
command,
|
command,
|
||||||
args,
|
args,
|
||||||
envArgs: options.e || {},
|
envArgs: options.e || {},
|
||||||
cli: options.cli || false,
|
cli: options.cli || false,
|
||||||
|
transport: transport as "stdio" | "sse" | "streamable-http" | undefined,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue