@modelcontextprotocol/inspector-cli 0.17.0 → 0.17.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/build/index.js +9 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import * as fs from "fs";
|
|
2
3
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
4
|
import { Command } from "commander";
|
|
4
5
|
import { callTool, connect, disconnect, getPrompt, listPrompts, listResources, listResourceTemplates, listTools, readResource, setLoggingLevel, validLogLevels, } from "./client/index.js";
|
|
5
6
|
import { handleError } from "./error-handler.js";
|
|
6
7
|
import { createTransport } from "./transport.js";
|
|
7
8
|
import { awaitableLog } from "./utils/awaitable-log.js";
|
|
8
|
-
import packageJson from "../package.json" with { type: "json" };
|
|
9
9
|
function createTransportOptions(target, transport, headers) {
|
|
10
10
|
if (target.length === 0) {
|
|
11
11
|
throw new Error("Target is required. Specify a URL or a command to execute.");
|
|
@@ -52,6 +52,14 @@ function createTransportOptions(target, transport, headers) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
async function callMethod(args) {
|
|
55
|
+
// Read package.json to get name and version for client identity
|
|
56
|
+
const pathA = "../package.json"; // We're in package @modelcontextprotocol/inspector-cli
|
|
57
|
+
const pathB = "../../package.json"; // We're in package @modelcontextprotocol/inspector
|
|
58
|
+
let packageJson;
|
|
59
|
+
let packageJsonData = await import(fs.existsSync(pathA) ? pathA : pathB, {
|
|
60
|
+
with: { type: "json" },
|
|
61
|
+
});
|
|
62
|
+
packageJson = packageJsonData.default;
|
|
55
63
|
const transportOptions = createTransportOptions(args.target, args.transport, args.headers);
|
|
56
64
|
const transport = createTransport(transportOptions);
|
|
57
65
|
const [, name = packageJson.name] = packageJson.name.split("/");
|