@modelcontextprotocol/inspector-cli 0.14.2 → 0.15.0
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/index.js +38 -3
- package/build/transport.js +14 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Command } from "commander";
|
|
|
4
4
|
import { callTool, connect, disconnect, getPrompt, listPrompts, listResources, listResourceTemplates, listTools, readResource, setLoggingLevel, validLogLevels, } from "./client/index.js";
|
|
5
5
|
import { handleError } from "./error-handler.js";
|
|
6
6
|
import { createTransport } from "./transport.js";
|
|
7
|
-
function createTransportOptions(target) {
|
|
7
|
+
function createTransportOptions(target, transport) {
|
|
8
8
|
if (target.length === 0) {
|
|
9
9
|
throw new Error("Target is required. Specify a URL or a command to execute.");
|
|
10
10
|
}
|
|
@@ -16,15 +16,40 @@ function createTransportOptions(target) {
|
|
|
16
16
|
if (isUrl && commandArgs.length > 0) {
|
|
17
17
|
throw new Error("Arguments cannot be passed to a URL-based MCP server.");
|
|
18
18
|
}
|
|
19
|
+
let transportType;
|
|
20
|
+
if (transport) {
|
|
21
|
+
if (!isUrl && transport !== "stdio") {
|
|
22
|
+
throw new Error("Only stdio transport can be used with local commands.");
|
|
23
|
+
}
|
|
24
|
+
if (isUrl && transport === "stdio") {
|
|
25
|
+
throw new Error("stdio transport cannot be used with URLs.");
|
|
26
|
+
}
|
|
27
|
+
transportType = transport;
|
|
28
|
+
}
|
|
29
|
+
else if (isUrl) {
|
|
30
|
+
const url = new URL(command);
|
|
31
|
+
if (url.pathname.endsWith("/mcp")) {
|
|
32
|
+
transportType = "http";
|
|
33
|
+
}
|
|
34
|
+
else if (url.pathname.endsWith("/sse")) {
|
|
35
|
+
transportType = "sse";
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
transportType = "sse";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
transportType = "stdio";
|
|
43
|
+
}
|
|
19
44
|
return {
|
|
20
|
-
transportType
|
|
45
|
+
transportType,
|
|
21
46
|
command: isUrl ? undefined : command,
|
|
22
47
|
args: isUrl ? undefined : commandArgs,
|
|
23
48
|
url: isUrl ? command : undefined,
|
|
24
49
|
};
|
|
25
50
|
}
|
|
26
51
|
async function callMethod(args) {
|
|
27
|
-
const transportOptions = createTransportOptions(args.target);
|
|
52
|
+
const transportOptions = createTransportOptions(args.target, args.transport);
|
|
28
53
|
const transport = createTransport(transportOptions);
|
|
29
54
|
const client = new Client({
|
|
30
55
|
name: "inspector-cli",
|
|
@@ -136,6 +161,16 @@ function parseArgs() {
|
|
|
136
161
|
throw new Error(`Invalid log level: ${value}. Valid levels are: ${validLogLevels.join(", ")}`);
|
|
137
162
|
}
|
|
138
163
|
return value;
|
|
164
|
+
})
|
|
165
|
+
//
|
|
166
|
+
// Transport options
|
|
167
|
+
//
|
|
168
|
+
.option("--transport <type>", "Transport type (sse, http, or stdio). Auto-detected from URL: /mcp → http, /sse → sse, commands → stdio", (value) => {
|
|
169
|
+
const validTransports = ["sse", "http", "stdio"];
|
|
170
|
+
if (!validTransports.includes(value)) {
|
|
171
|
+
throw new Error(`Invalid transport type: ${value}. Valid types are: ${validTransports.join(", ")}`);
|
|
172
|
+
}
|
|
173
|
+
return value;
|
|
139
174
|
});
|
|
140
175
|
// Parse only the arguments before --
|
|
141
176
|
program.parse(preArgs);
|
package/build/transport.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
2
2
|
import { getDefaultEnvironment, StdioClientTransport, } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
3
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
3
4
|
import { findActualExecutable } from "spawn-rx";
|
|
4
5
|
function createSSETransport(options) {
|
|
5
6
|
const baseUrl = new URL(options.url ?? "");
|
|
6
|
-
const sseUrl =
|
|
7
|
+
const sseUrl = baseUrl.pathname.endsWith("/sse")
|
|
8
|
+
? baseUrl
|
|
9
|
+
: new URL("/sse", baseUrl);
|
|
7
10
|
return new SSEClientTransport(sseUrl);
|
|
8
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
|
+
}
|
|
9
19
|
function createStdioTransport(options) {
|
|
10
20
|
let args = [];
|
|
11
21
|
if (options.args !== undefined) {
|
|
@@ -39,6 +49,9 @@ export function createTransport(options) {
|
|
|
39
49
|
if (transportType === "sse") {
|
|
40
50
|
return createSSETransport(options);
|
|
41
51
|
}
|
|
52
|
+
if (transportType === "http") {
|
|
53
|
+
return createHTTPTransport(options);
|
|
54
|
+
}
|
|
42
55
|
throw new Error(`Unsupported transport type: ${transportType}`);
|
|
43
56
|
}
|
|
44
57
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modelcontextprotocol/inspector-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
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.13.1",
|
|
25
25
|
"commander": "^13.1.0",
|
|
26
26
|
"spawn-rx": "^5.1.2"
|
|
27
27
|
}
|