@bryan-thompson/inspector-assessment-cli 1.4.0 → 1.6.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/cli.js +10 -1
- package/build/client/prompts.js +10 -5
- package/build/client/resources.js +12 -6
- package/build/client/tools.js +17 -4
- package/build/index.js +34 -9
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -46,6 +46,10 @@ async function runWebClient(args) {
|
|
|
46
46
|
if (args.serverUrl) {
|
|
47
47
|
startArgs.push("--server-url", args.serverUrl);
|
|
48
48
|
}
|
|
49
|
+
// Pass Claude Code flag if enabled
|
|
50
|
+
if (args.claudeEnabled) {
|
|
51
|
+
startArgs.push("--claude-enabled");
|
|
52
|
+
}
|
|
49
53
|
// Pass command and args (using -- to separate them)
|
|
50
54
|
if (args.command) {
|
|
51
55
|
startArgs.push("--", args.command, ...args.args);
|
|
@@ -171,7 +175,8 @@ function parseArgs() {
|
|
|
171
175
|
.option("--cli", "enable CLI mode")
|
|
172
176
|
.option("--transport <type>", "transport type (stdio, sse, http)")
|
|
173
177
|
.option("--server-url <url>", "server URL for SSE/HTTP transport")
|
|
174
|
-
.option("--header <headers...>", 'HTTP headers as "HeaderName: Value" pairs (for HTTP/SSE transports)', parseHeaderPair, {})
|
|
178
|
+
.option("--header <headers...>", 'HTTP headers as "HeaderName: Value" pairs (for HTTP/SSE transports)', parseHeaderPair, {})
|
|
179
|
+
.option("--claude-enabled", "enable Claude Code integration for intelligent analysis (requires Claude CLI)");
|
|
175
180
|
// Parse only the arguments before --
|
|
176
181
|
program.parse(preArgs);
|
|
177
182
|
const options = program.opts();
|
|
@@ -214,6 +219,7 @@ function parseArgs() {
|
|
|
214
219
|
cli: options.cli || false,
|
|
215
220
|
transport: "stdio",
|
|
216
221
|
headers: options.header,
|
|
222
|
+
claudeEnabled: options.claudeEnabled || false,
|
|
217
223
|
};
|
|
218
224
|
}
|
|
219
225
|
else if (config.type === "sse" || config.type === "streamable-http") {
|
|
@@ -225,6 +231,7 @@ function parseArgs() {
|
|
|
225
231
|
transport: config.type,
|
|
226
232
|
serverUrl: config.url,
|
|
227
233
|
headers: options.header,
|
|
234
|
+
claudeEnabled: options.claudeEnabled || false,
|
|
228
235
|
};
|
|
229
236
|
}
|
|
230
237
|
else {
|
|
@@ -236,6 +243,7 @@ function parseArgs() {
|
|
|
236
243
|
cli: options.cli || false,
|
|
237
244
|
transport: "stdio",
|
|
238
245
|
headers: options.header,
|
|
246
|
+
claudeEnabled: options.claudeEnabled || false,
|
|
239
247
|
};
|
|
240
248
|
}
|
|
241
249
|
}
|
|
@@ -255,6 +263,7 @@ function parseArgs() {
|
|
|
255
263
|
transport: transport,
|
|
256
264
|
serverUrl: options.serverUrl,
|
|
257
265
|
headers: options.header,
|
|
266
|
+
claudeEnabled: options.claudeEnabled || false,
|
|
258
267
|
};
|
|
259
268
|
}
|
|
260
269
|
async function main() {
|
package/build/client/prompts.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// List available prompts
|
|
2
|
-
export async function listPrompts(client) {
|
|
2
|
+
export async function listPrompts(client, metadata) {
|
|
3
3
|
try {
|
|
4
|
-
const
|
|
4
|
+
const params = metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
|
5
|
+
const response = await client.listPrompts(params);
|
|
5
6
|
return response;
|
|
6
7
|
}
|
|
7
8
|
catch (error) {
|
|
@@ -9,7 +10,7 @@ export async function listPrompts(client) {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
// Get a prompt
|
|
12
|
-
export async function getPrompt(client, name, args) {
|
|
13
|
+
export async function getPrompt(client, name, args, metadata) {
|
|
13
14
|
try {
|
|
14
15
|
// Convert all arguments to strings for prompt arguments
|
|
15
16
|
const stringArgs = {};
|
|
@@ -26,10 +27,14 @@ export async function getPrompt(client, name, args) {
|
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
const
|
|
30
|
+
const params = {
|
|
30
31
|
name,
|
|
31
32
|
arguments: stringArgs,
|
|
32
|
-
}
|
|
33
|
+
};
|
|
34
|
+
if (metadata && Object.keys(metadata).length > 0) {
|
|
35
|
+
params._meta = metadata;
|
|
36
|
+
}
|
|
37
|
+
const response = await client.getPrompt(params);
|
|
33
38
|
return response;
|
|
34
39
|
}
|
|
35
40
|
catch (error) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// List available resources
|
|
2
|
-
export async function listResources(client) {
|
|
2
|
+
export async function listResources(client, metadata) {
|
|
3
3
|
try {
|
|
4
|
-
const
|
|
4
|
+
const params = metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
|
5
|
+
const response = await client.listResources(params);
|
|
5
6
|
return response;
|
|
6
7
|
}
|
|
7
8
|
catch (error) {
|
|
@@ -9,9 +10,13 @@ export async function listResources(client) {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
// Read a resource
|
|
12
|
-
export async function readResource(client, uri) {
|
|
13
|
+
export async function readResource(client, uri, metadata) {
|
|
13
14
|
try {
|
|
14
|
-
const
|
|
15
|
+
const params = { uri };
|
|
16
|
+
if (metadata && Object.keys(metadata).length > 0) {
|
|
17
|
+
params._meta = metadata;
|
|
18
|
+
}
|
|
19
|
+
const response = await client.readResource(params);
|
|
15
20
|
return response;
|
|
16
21
|
}
|
|
17
22
|
catch (error) {
|
|
@@ -19,9 +24,10 @@ export async function readResource(client, uri) {
|
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
// List resource templates
|
|
22
|
-
export async function listResourceTemplates(client) {
|
|
27
|
+
export async function listResourceTemplates(client, metadata) {
|
|
23
28
|
try {
|
|
24
|
-
const
|
|
29
|
+
const params = metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
|
30
|
+
const response = await client.listResourceTemplates(params);
|
|
25
31
|
return response;
|
|
26
32
|
}
|
|
27
33
|
catch (error) {
|
package/build/client/tools.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export async function listTools(client) {
|
|
1
|
+
export async function listTools(client, metadata) {
|
|
2
2
|
try {
|
|
3
|
-
const
|
|
3
|
+
const params = metadata && Object.keys(metadata).length > 0 ? { _meta: metadata } : {};
|
|
4
|
+
const response = await client.listTools(params);
|
|
4
5
|
return response;
|
|
5
6
|
}
|
|
6
7
|
catch (error) {
|
|
@@ -42,9 +43,9 @@ function convertParameters(tool, params) {
|
|
|
42
43
|
}
|
|
43
44
|
return result;
|
|
44
45
|
}
|
|
45
|
-
export async function callTool(client, name, args) {
|
|
46
|
+
export async function callTool(client, name, args, generalMetadata, toolSpecificMetadata) {
|
|
46
47
|
try {
|
|
47
|
-
const toolsResponse = await listTools(client);
|
|
48
|
+
const toolsResponse = await listTools(client, generalMetadata);
|
|
48
49
|
const tools = toolsResponse.tools;
|
|
49
50
|
const tool = tools.find((t) => t.name === name);
|
|
50
51
|
let convertedArgs = args;
|
|
@@ -62,9 +63,21 @@ export async function callTool(client, name, args) {
|
|
|
62
63
|
convertedArgs = { ...args, ...convertedStringArgs };
|
|
63
64
|
}
|
|
64
65
|
}
|
|
66
|
+
// Merge general metadata with tool-specific metadata
|
|
67
|
+
// Tool-specific metadata takes precedence over general metadata
|
|
68
|
+
let mergedMetadata;
|
|
69
|
+
if (generalMetadata || toolSpecificMetadata) {
|
|
70
|
+
mergedMetadata = {
|
|
71
|
+
...(generalMetadata || {}),
|
|
72
|
+
...(toolSpecificMetadata || {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
65
75
|
const response = await client.callTool({
|
|
66
76
|
name: name,
|
|
67
77
|
arguments: convertedArgs,
|
|
78
|
+
_meta: mergedMetadata && Object.keys(mergedMetadata).length > 0
|
|
79
|
+
? mergedMetadata
|
|
80
|
+
: undefined,
|
|
68
81
|
});
|
|
69
82
|
return response;
|
|
70
83
|
}
|
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("/");
|
|
@@ -63,36 +71,36 @@ async function callMethod(args) {
|
|
|
63
71
|
let result;
|
|
64
72
|
// Tools methods
|
|
65
73
|
if (args.method === "tools/list") {
|
|
66
|
-
result = await listTools(client);
|
|
74
|
+
result = await listTools(client, args.metadata);
|
|
67
75
|
}
|
|
68
76
|
else if (args.method === "tools/call") {
|
|
69
77
|
if (!args.toolName) {
|
|
70
78
|
throw new Error("Tool name is required for tools/call method. Use --tool-name to specify the tool name.");
|
|
71
79
|
}
|
|
72
|
-
result = await callTool(client, args.toolName, args.toolArg || {});
|
|
80
|
+
result = await callTool(client, args.toolName, args.toolArg || {}, args.metadata, args.toolMeta);
|
|
73
81
|
}
|
|
74
82
|
// Resources methods
|
|
75
83
|
else if (args.method === "resources/list") {
|
|
76
|
-
result = await listResources(client);
|
|
84
|
+
result = await listResources(client, args.metadata);
|
|
77
85
|
}
|
|
78
86
|
else if (args.method === "resources/read") {
|
|
79
87
|
if (!args.uri) {
|
|
80
88
|
throw new Error("URI is required for resources/read method. Use --uri to specify the resource URI.");
|
|
81
89
|
}
|
|
82
|
-
result = await readResource(client, args.uri);
|
|
90
|
+
result = await readResource(client, args.uri, args.metadata);
|
|
83
91
|
}
|
|
84
92
|
else if (args.method === "resources/templates/list") {
|
|
85
|
-
result = await listResourceTemplates(client);
|
|
93
|
+
result = await listResourceTemplates(client, args.metadata);
|
|
86
94
|
}
|
|
87
95
|
// Prompts methods
|
|
88
96
|
else if (args.method === "prompts/list") {
|
|
89
|
-
result = await listPrompts(client);
|
|
97
|
+
result = await listPrompts(client, args.metadata);
|
|
90
98
|
}
|
|
91
99
|
else if (args.method === "prompts/get") {
|
|
92
100
|
if (!args.promptName) {
|
|
93
101
|
throw new Error("Prompt name is required for prompts/get method. Use --prompt-name to specify the prompt name.");
|
|
94
102
|
}
|
|
95
|
-
result = await getPrompt(client, args.promptName, args.promptArgs || {});
|
|
103
|
+
result = await getPrompt(client, args.promptName, args.promptArgs || {}, args.metadata);
|
|
96
104
|
}
|
|
97
105
|
// Logging methods
|
|
98
106
|
else if (args.method === "logging/setLevel") {
|
|
@@ -199,7 +207,12 @@ function parseArgs() {
|
|
|
199
207
|
//
|
|
200
208
|
// HTTP headers
|
|
201
209
|
//
|
|
202
|
-
.option("--header <headers...>", 'HTTP headers as "HeaderName: Value" pairs (for HTTP/SSE transports)', parseHeaderPair, {})
|
|
210
|
+
.option("--header <headers...>", 'HTTP headers as "HeaderName: Value" pairs (for HTTP/SSE transports)', parseHeaderPair, {})
|
|
211
|
+
//
|
|
212
|
+
// Metadata options
|
|
213
|
+
//
|
|
214
|
+
.option("--metadata <pairs...>", "General metadata as key=value pairs (applied to all methods)", parseKeyValuePair, {})
|
|
215
|
+
.option("--tool-metadata <pairs...>", "Tool-specific metadata as key=value pairs (for tools/call method only)", parseKeyValuePair, {});
|
|
203
216
|
// Parse only the arguments before --
|
|
204
217
|
program.parse(preArgs);
|
|
205
218
|
const options = program.opts();
|
|
@@ -213,6 +226,18 @@ function parseArgs() {
|
|
|
213
226
|
target: finalArgs,
|
|
214
227
|
...options,
|
|
215
228
|
headers: options.header, // commander.js uses 'header' field, map to 'headers'
|
|
229
|
+
metadata: options.metadata
|
|
230
|
+
? Object.fromEntries(Object.entries(options.metadata).map(([key, value]) => [
|
|
231
|
+
key,
|
|
232
|
+
String(value),
|
|
233
|
+
]))
|
|
234
|
+
: undefined,
|
|
235
|
+
toolMeta: options.toolMetadata
|
|
236
|
+
? Object.fromEntries(Object.entries(options.toolMetadata).map(([key, value]) => [
|
|
237
|
+
key,
|
|
238
|
+
String(value),
|
|
239
|
+
]))
|
|
240
|
+
: undefined,
|
|
216
241
|
};
|
|
217
242
|
}
|
|
218
243
|
async function main() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bryan-thompson/inspector-assessment-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "CLI for the Enhanced MCP Inspector with assessment capabilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bryan Thompson <bryan@triepod.ai>",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
37
|
+
"@modelcontextprotocol/sdk": "^1.23.0",
|
|
38
38
|
"commander": "^13.1.0",
|
|
39
39
|
"spawn-rx": "^5.1.2"
|
|
40
40
|
}
|