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
|
|
@ -1,5 +1,6 @@
|
|||
import { existsSync, readFileSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
import { getDefaultMcpConfigPath } from "../../storage/store-io.js";
|
||||
import type {
|
||||
MCPConfig,
|
||||
MCPServerConfig,
|
||||
|
|
@ -211,8 +212,26 @@ function applyOverrides(
|
|||
|
||||
export type ResolveServerConfigsMode = "single" | "multi";
|
||||
|
||||
export function hasAdHocServerOptions(options: ServerConfigOptions): boolean {
|
||||
return (
|
||||
(options.target != null && options.target.length > 0) ||
|
||||
Boolean(options.transport) ||
|
||||
Boolean(options.serverUrl?.trim())
|
||||
);
|
||||
}
|
||||
|
||||
/** When no --config and no ad-hoc target, use ~/.mcp-inspector/mcp.json (same as web). */
|
||||
export function withDefaultConfigPath(
|
||||
options: ServerConfigOptions,
|
||||
): ServerConfigOptions {
|
||||
if (options.configPath?.trim() || hasAdHocServerOptions(options)) {
|
||||
return options;
|
||||
}
|
||||
return { ...options, configPath: getDefaultMcpConfigPath() };
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves server config(s) from options and mode. Used by all runners.
|
||||
* Resolves server config(s) from explicit options and mode.
|
||||
* Single mode: one config (from file + overrides, or from args).
|
||||
* Multi mode: all servers from file (with optional env/cwd/headers overrides), or one from args; errors if config path + transport/serverUrl/positional.
|
||||
*/
|
||||
|
|
@ -221,10 +240,7 @@ export function resolveServerConfigs(
|
|||
mode: ResolveServerConfigsMode,
|
||||
): MCPServerConfig[] {
|
||||
const hasConfigPath = Boolean(options.configPath?.trim());
|
||||
const hasAdHoc =
|
||||
(options.target && options.target.length > 0) ||
|
||||
Boolean(options.transport) ||
|
||||
Boolean(options.serverUrl);
|
||||
const hasAdHoc = hasAdHocServerOptions(options);
|
||||
|
||||
if (mode === "single") {
|
||||
if (hasConfigPath && options.serverName) {
|
||||
|
|
@ -286,6 +302,17 @@ export function resolveServerConfigs(
|
|||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch-time resolver for CLI/TUI: applies the default catalog path when no
|
||||
* `--config` or ad-hoc target is given, then delegates to `resolveServerConfigs`.
|
||||
*/
|
||||
export function resolveLaunchServerConfigs(
|
||||
options: ServerConfigOptions,
|
||||
mode: ResolveServerConfigsMode,
|
||||
): MCPServerConfig[] {
|
||||
return resolveServerConfigs(withDefaultConfigPath(options), mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns named server configs from a config file (multi-server). Use when the caller
|
||||
* needs server names (e.g. TUI). Errors if config path is missing or if ad-hoc options
|
||||
|
|
|
|||
Loading…
Reference in a new issue