feat: port CLI, TUI, and launcher from v1.5 into v2 (#1452)
Ports the CLI, TUI, and launcher from v1.5 into v2 behind a single `mcp-inspector` entrypoint (launcher → web/cli/tui). Includes the `mcp-inspector --web --dev` launcher fix (Vite alias resolution + prod-server double-start), the root `postinstall` install cascade with simplified CI, and spec/AGENTS docs (no-workspaces rationale, Development setup). Closes #1246. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
53dc4549be
commit
2488ca5e38
1 changed files with 25594 additions and 236 deletions
43
clients/launcher/src/parse-launcher-argv.ts
Normal file
43
clients/launcher/src/parse-launcher-argv.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
export const LAUNCHER_MODE_FLAGS = new Set(["--web", "--cli", "--tui"]);
|
||||
|
||||
export type LauncherMode = "web" | "cli" | "tui";
|
||||
|
||||
export type ParseLauncherArgvResult = {
|
||||
mode: LauncherMode;
|
||||
forwardedArgv: string[];
|
||||
hasPrefixModeFlag: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Launcher mode flags are read only from a contiguous prefix of user args
|
||||
* (argv[2…]). Everything after the first non-mode token is forwarded
|
||||
* unchanged so values like `--cli` can appear in app/server config.
|
||||
*/
|
||||
export function parseLauncherArgv(argv: string[]): ParseLauncherArgvResult {
|
||||
const executable = argv.slice(0, 2);
|
||||
const userArgs = argv.slice(2);
|
||||
|
||||
const prefixFlags: string[] = [];
|
||||
let index = 0;
|
||||
while (index < userArgs.length && LAUNCHER_MODE_FLAGS.has(userArgs[index]!)) {
|
||||
prefixFlags.push(userArgs[index]!);
|
||||
index++;
|
||||
}
|
||||
|
||||
if (prefixFlags.length > 1) {
|
||||
throw new Error("Specify at most one of --web, --cli, or --tui.");
|
||||
}
|
||||
|
||||
const mode: LauncherMode =
|
||||
prefixFlags[0] === "--tui"
|
||||
? "tui"
|
||||
: prefixFlags[0] === "--cli"
|
||||
? "cli"
|
||||
: "web";
|
||||
|
||||
return {
|
||||
mode,
|
||||
forwardedArgv: [...executable, ...userArgs.slice(index)],
|
||||
hasPrefixModeFlag: prefixFlags.length > 0,
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue