@modelcontextprotocol/inspector 1.0.1 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +199 -361
- package/clients/cli/build/index.js +13218 -0
- package/clients/launcher/build/index.js +90 -0
- package/clients/launcher/build/parse-launcher-argv.js +29 -0
- package/clients/tui/build/chunk-MCKGQKYU.js +15 -0
- package/clients/tui/build/index.js +14573 -0
- package/clients/tui/build/undici-HXPKCIY3.js +25789 -0
- package/clients/web/build/chunk-MCKGQKYU.js +15 -0
- package/clients/web/build/index.js +4322 -0
- package/clients/web/build/undici-HXPKCIY3.js +25789 -0
- package/clients/web/dist/assets/css-DfBGKsUM.js +1 -0
- package/clients/web/dist/assets/index-Cbtmmw0V.js +300 -0
- package/clients/web/dist/assets/index-CiUpWldH.css +1 -0
- package/clients/web/dist/assets/json-rfaH9Mx5.js +1 -0
- package/clients/web/dist/assets/markdown-PVXc4EJ0.js +1 -0
- package/clients/web/dist/assets/markup-Bk4keGDK.js +1 -0
- package/clients/web/dist/assets/markup-DPsXihXF.js +1 -0
- package/clients/web/dist/assets/prism-light-B8tIwqDr.js +6 -0
- package/clients/web/dist/assets/tomorrow-COrD2Qnh.js +1 -0
- package/clients/web/dist/assets/yaml-B78V9E0m.js +1 -0
- package/clients/web/dist/icons.svg +24 -0
- package/clients/web/dist/index.html +17 -0
- package/package.json +96 -80
- package/scripts/install-clients.mjs +65 -0
- package/LICENSE +0 -216
- package/cli/build/cli.js +0 -290
- package/cli/build/client/connection.js +0 -38
- package/cli/build/client/index.js +0 -6
- package/cli/build/client/prompts.js +0 -43
- package/cli/build/client/resources.js +0 -36
- package/cli/build/client/tools.js +0 -87
- package/cli/build/client/types.js +0 -1
- package/cli/build/error-handler.js +0 -18
- package/cli/build/index.js +0 -257
- package/cli/build/transport.js +0 -65
- package/cli/build/utils/awaitable-log.js +0 -7
- package/client/bin/client.js +0 -62
- package/client/bin/start.js +0 -355
- package/client/dist/assets/OAuthCallback-DKaW5Tk8.js +0 -55
- package/client/dist/assets/OAuthDebugCallback-Bx3X7Zkh.js +0 -64
- package/client/dist/assets/index-CH-qD91V.js +0 -67487
- package/client/dist/assets/index-DXy0twoH.css +0 -2786
- package/client/dist/index.html +0 -14
- package/server/build/index.js +0 -889
- package/server/build/mcpProxy.js +0 -121
- package/server/build/static/sandbox_proxy.html +0 -197
- package/server/static/sandbox_proxy.html +0 -197
- /package/{client/dist/mcp.svg → clients/web/dist/assets/MCP-CWGQJYyH.svg} +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { parseLauncherArgv } from "./parse-launcher-argv.js";
|
|
6
|
+
const launcherDir = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
function clientEntry(client) {
|
|
8
|
+
return pathToFileURL(join(launcherDir, "..", "..", client, "build", "index.js")).href;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Whether to append the error stack on a top-level failure. Gated on `MCP_DEBUG`
|
|
12
|
+
* or `DEBUG` being *meaningfully* set — `"0"` / `"false"` / empty read as off, so
|
|
13
|
+
* a stray `DEBUG=0` doesn't turn stacks on (and `DEBUG` stays useful for the
|
|
14
|
+
* `debug` package's namespace filter, which is any non-empty value).
|
|
15
|
+
*/
|
|
16
|
+
function wantsDebugStack() {
|
|
17
|
+
const on = (v) => {
|
|
18
|
+
const s = v?.trim().toLowerCase();
|
|
19
|
+
return !!s && s !== "0" && s !== "false";
|
|
20
|
+
};
|
|
21
|
+
return on(process.env.MCP_DEBUG) || on(process.env.DEBUG);
|
|
22
|
+
}
|
|
23
|
+
const program = new Command();
|
|
24
|
+
program
|
|
25
|
+
.name("mcp-inspector")
|
|
26
|
+
.description("MCP Inspector – run web UI, CLI, or TUI")
|
|
27
|
+
.option("--web", "Run web UI (default)")
|
|
28
|
+
.option("--cli", "Run CLI")
|
|
29
|
+
.option("--tui", "Run TUI");
|
|
30
|
+
let parsedArgv;
|
|
31
|
+
try {
|
|
32
|
+
parsedArgv = parseLauncherArgv(process.argv);
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const message = err instanceof Error ? err.message : "Invalid launcher arguments.";
|
|
36
|
+
console.error(`Error: ${message}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const { mode, forwardedArgv, hasPrefixModeFlag } = parsedArgv;
|
|
40
|
+
const helpOnly = process.argv.includes("-h") || process.argv.includes("--help");
|
|
41
|
+
if (helpOnly && !hasPrefixModeFlag) {
|
|
42
|
+
program.outputHelp();
|
|
43
|
+
console.log("\nMode flags (--web, --cli, --tui) must appear before app options. All following arguments are forwarded unchanged.");
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
async function run() {
|
|
47
|
+
if (mode === "web") {
|
|
48
|
+
const { runWeb } = await import(clientEntry("web"));
|
|
49
|
+
await runWeb(forwardedArgv);
|
|
50
|
+
}
|
|
51
|
+
else if (mode === "cli") {
|
|
52
|
+
// Route a CLI failure through the CLI's own error sink so `mcp-inspector
|
|
53
|
+
// --cli` (a module import here, so the CLI bin's own `.catch(handleError)`
|
|
54
|
+
// never fires) still honors the EXIT_CODES map and emits the JSON
|
|
55
|
+
// `{"error":…}` envelope its README documents — instead of the generic
|
|
56
|
+
// exit-1 catch-all below.
|
|
57
|
+
const { runCli, handleError } = await import(clientEntry("cli"));
|
|
58
|
+
try {
|
|
59
|
+
// On success, let `run()` resolve and the event loop drain (rather than a
|
|
60
|
+
// `process.exit(0)`) — the CLI closes its own transports, and an eager exit
|
|
61
|
+
// risks truncating a large stdout payload on a pipe (async on macOS).
|
|
62
|
+
await runCli(forwardedArgv);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
// A stale `cli/build` (built before handleError was exported) would make
|
|
66
|
+
// this `undefined`; fall through to the generic sink with the real message
|
|
67
|
+
// rather than throwing "handleError is not a function" over it.
|
|
68
|
+
if (typeof handleError !== "function")
|
|
69
|
+
throw err;
|
|
70
|
+
// write-then-exit like the direct bin; the envelope is a few hundred bytes,
|
|
71
|
+
// well inside the pipe buffer, so the truncation risk noted above (which is
|
|
72
|
+
// about a large stdout payload) doesn't apply to this stderr line.
|
|
73
|
+
handleError(err); // writes the envelope + process.exit(code); never returns
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const { runTui } = await import(clientEntry("tui"));
|
|
78
|
+
await runTui(forwardedArgv);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
run().catch((err) => {
|
|
82
|
+
// Print the message, not the Error stack — a startup config error (a bad flag,
|
|
83
|
+
// the OAuth callback loopback guard) should read as actionable, not internal.
|
|
84
|
+
// The stack is still available under DEBUG / MCP_DEBUG for real faults.
|
|
85
|
+
console.error("Error running MCP Inspector:", err instanceof Error ? err.message : err);
|
|
86
|
+
if (wantsDebugStack() && err instanceof Error) {
|
|
87
|
+
console.error(err.stack);
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const LAUNCHER_MODE_FLAGS = new Set(["--web", "--cli", "--tui"]);
|
|
2
|
+
/**
|
|
3
|
+
* Launcher mode flags are read only from a contiguous prefix of user args
|
|
4
|
+
* (argv[2…]). Everything after the first non-mode token is forwarded
|
|
5
|
+
* unchanged so values like `--cli` can appear in app/server config.
|
|
6
|
+
*/
|
|
7
|
+
export function parseLauncherArgv(argv) {
|
|
8
|
+
const executable = argv.slice(0, 2);
|
|
9
|
+
const userArgs = argv.slice(2);
|
|
10
|
+
const prefixFlags = [];
|
|
11
|
+
let index = 0;
|
|
12
|
+
while (index < userArgs.length && LAUNCHER_MODE_FLAGS.has(userArgs[index])) {
|
|
13
|
+
prefixFlags.push(userArgs[index]);
|
|
14
|
+
index++;
|
|
15
|
+
}
|
|
16
|
+
if (prefixFlags.length > 1) {
|
|
17
|
+
throw new Error("Specify at most one of --web, --cli, or --tui.");
|
|
18
|
+
}
|
|
19
|
+
const mode = prefixFlags[0] === "--tui"
|
|
20
|
+
? "tui"
|
|
21
|
+
: prefixFlags[0] === "--cli"
|
|
22
|
+
? "cli"
|
|
23
|
+
: "web";
|
|
24
|
+
return {
|
|
25
|
+
mode,
|
|
26
|
+
forwardedArgv: [...executable, ...userArgs.slice(index)],
|
|
27
|
+
hasPrefixModeFlag: prefixFlags.length > 0,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
__require,
|
|
14
|
+
__commonJS
|
|
15
|
+
};
|