@modelcontextprotocol/inspector-cli 0.16.0 → 0.16.2
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/build/cli.js +17 -34
- package/build/index.js +2 -0
- package/build/transport.js +7 -16
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -24,50 +24,33 @@ function delay(ms) {
|
|
|
24
24
|
return new Promise((resolve) => setTimeout(resolve, ms, true));
|
|
25
25
|
}
|
|
26
26
|
async function runWebClient(args) {
|
|
27
|
-
const inspectorServerPath = resolve(__dirname, "../../", "server", "build", "index.js");
|
|
28
27
|
// Path to the client entry point
|
|
29
|
-
const inspectorClientPath = resolve(__dirname, "../../", "client", "bin", "
|
|
30
|
-
const CLIENT_PORT = process.env.CLIENT_PORT ?? "6274";
|
|
31
|
-
const SERVER_PORT = process.env.SERVER_PORT ?? "6277";
|
|
32
|
-
console.log("Starting MCP inspector...");
|
|
28
|
+
const inspectorClientPath = resolve(__dirname, "../../", "client", "bin", "start.js");
|
|
33
29
|
const abort = new AbortController();
|
|
34
30
|
let cancelled = false;
|
|
35
31
|
process.on("SIGINT", () => {
|
|
36
32
|
cancelled = true;
|
|
37
33
|
abort.abort();
|
|
38
34
|
});
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
// Build arguments to pass to start.js
|
|
36
|
+
const startArgs = [];
|
|
37
|
+
// Pass environment variables
|
|
38
|
+
for (const [key, value] of Object.entries(args.envArgs)) {
|
|
39
|
+
startArgs.push("-e", `${key}=${value}`);
|
|
40
|
+
}
|
|
41
|
+
// Pass command and args (using -- to separate them)
|
|
42
|
+
if (args.command) {
|
|
43
|
+
startArgs.push("--", args.command, ...args.args);
|
|
44
|
+
}
|
|
41
45
|
try {
|
|
42
|
-
|
|
43
|
-
inspectorServerPath,
|
|
44
|
-
...(args.command ? [`--env`, args.command] : []),
|
|
45
|
-
...(args.args ? [`--args=${args.args.join(" ")}`] : []),
|
|
46
|
-
], {
|
|
47
|
-
env: {
|
|
48
|
-
...process.env,
|
|
49
|
-
PORT: SERVER_PORT,
|
|
50
|
-
MCP_ENV_VARS: JSON.stringify(args.envArgs),
|
|
51
|
-
},
|
|
46
|
+
await spawnPromise("node", [inspectorClientPath, ...startArgs], {
|
|
52
47
|
signal: abort.signal,
|
|
53
48
|
echoOutput: true,
|
|
54
49
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (serverOk) {
|
|
60
|
-
try {
|
|
61
|
-
await spawnPromise("node", [inspectorClientPath], {
|
|
62
|
-
env: { ...process.env, PORT: CLIENT_PORT },
|
|
63
|
-
signal: abort.signal,
|
|
64
|
-
echoOutput: true,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
if (!cancelled || process.env.DEBUG)
|
|
69
|
-
throw e;
|
|
70
|
-
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
if (!cancelled || process.env.DEBUG)
|
|
53
|
+
throw e;
|
|
71
54
|
}
|
|
72
55
|
}
|
|
73
56
|
async function runCli(args) {
|
|
@@ -182,7 +165,7 @@ async function main() {
|
|
|
182
165
|
try {
|
|
183
166
|
const args = parseArgs();
|
|
184
167
|
if (args.cli) {
|
|
185
|
-
runCli(args);
|
|
168
|
+
await runCli(args);
|
|
186
169
|
}
|
|
187
170
|
else {
|
|
188
171
|
await runWebClient(args);
|
package/build/index.js
CHANGED
package/build/transport.js
CHANGED
|
@@ -2,20 +2,6 @@ import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
|
2
2
|
import { getDefaultEnvironment, StdioClientTransport, } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
3
3
|
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
4
4
|
import { findActualExecutable } from "spawn-rx";
|
|
5
|
-
function createSSETransport(options) {
|
|
6
|
-
const baseUrl = new URL(options.url ?? "");
|
|
7
|
-
const sseUrl = baseUrl.pathname.endsWith("/sse")
|
|
8
|
-
? baseUrl
|
|
9
|
-
: new URL("/sse", baseUrl);
|
|
10
|
-
return new SSEClientTransport(sseUrl);
|
|
11
|
-
}
|
|
12
|
-
function createHTTPTransport(options) {
|
|
13
|
-
const baseUrl = new URL(options.url ?? "");
|
|
14
|
-
const mcpUrl = baseUrl.pathname.endsWith("/mcp")
|
|
15
|
-
? baseUrl
|
|
16
|
-
: new URL("/mcp", baseUrl);
|
|
17
|
-
return new StreamableHTTPClientTransport(mcpUrl);
|
|
18
|
-
}
|
|
19
5
|
function createStdioTransport(options) {
|
|
20
6
|
let args = [];
|
|
21
7
|
if (options.args !== undefined) {
|
|
@@ -46,11 +32,16 @@ export function createTransport(options) {
|
|
|
46
32
|
if (transportType === "stdio") {
|
|
47
33
|
return createStdioTransport(options);
|
|
48
34
|
}
|
|
35
|
+
// If not STDIO, then it must be either SSE or HTTP.
|
|
36
|
+
if (!options.url) {
|
|
37
|
+
throw new Error("URL must be provided for SSE or HTTP transport types.");
|
|
38
|
+
}
|
|
39
|
+
const url = new URL(options.url);
|
|
49
40
|
if (transportType === "sse") {
|
|
50
|
-
return
|
|
41
|
+
return new SSEClientTransport(url);
|
|
51
42
|
}
|
|
52
43
|
if (transportType === "http") {
|
|
53
|
-
return
|
|
44
|
+
return new StreamableHTTPClientTransport(url);
|
|
54
45
|
}
|
|
55
46
|
throw new Error(`Unsupported transport type: ${transportType}`);
|
|
56
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modelcontextprotocol/inspector-cli",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "CLI for the Model Context Protocol inspector",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Anthropic, PBC (https://anthropic.com)",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
24
|
+
"@modelcontextprotocol/sdk": "^1.17.0",
|
|
25
25
|
"commander": "^13.1.0",
|
|
26
26
|
"spawn-rx": "^5.1.2"
|
|
27
27
|
}
|