@bryan-thompson/inspector-assessment-cli 1.8.2 → 1.10.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/assess-full.js +35 -8
- package/package.json +1 -1
package/build/assess-full.js
CHANGED
|
@@ -40,6 +40,7 @@ function loadServerConfig(serverName, configPath) {
|
|
|
40
40
|
command: serverConfig.command,
|
|
41
41
|
args: serverConfig.args || [],
|
|
42
42
|
env: serverConfig.env || {},
|
|
43
|
+
cwd: serverConfig.cwd,
|
|
43
44
|
};
|
|
44
45
|
}
|
|
45
46
|
if (config.url ||
|
|
@@ -129,6 +130,7 @@ function loadSourceFiles(sourcePath) {
|
|
|
129
130
|
*/
|
|
130
131
|
async function connectToServer(config) {
|
|
131
132
|
let transport;
|
|
133
|
+
let stderrData = ""; // Capture stderr for error reporting
|
|
132
134
|
switch (config.transport) {
|
|
133
135
|
case "http":
|
|
134
136
|
if (!config.url)
|
|
@@ -151,8 +153,18 @@ async function connectToServer(config) {
|
|
|
151
153
|
...Object.fromEntries(Object.entries(process.env).filter(([, v]) => v !== undefined)),
|
|
152
154
|
...config.env,
|
|
153
155
|
},
|
|
156
|
+
cwd: config.cwd,
|
|
154
157
|
stderr: "pipe",
|
|
155
158
|
});
|
|
159
|
+
// Capture stderr BEFORE connecting - critical for error context
|
|
160
|
+
// The MCP SDK creates a PassThrough stream immediately when stderr: "pipe"
|
|
161
|
+
// is set, allowing us to attach listeners before start() is called
|
|
162
|
+
const stderrStream = transport.stderr;
|
|
163
|
+
if (stderrStream) {
|
|
164
|
+
stderrStream.on("data", (data) => {
|
|
165
|
+
stderrData += data.toString();
|
|
166
|
+
});
|
|
167
|
+
}
|
|
156
168
|
break;
|
|
157
169
|
}
|
|
158
170
|
const client = new Client({
|
|
@@ -161,7 +173,22 @@ async function connectToServer(config) {
|
|
|
161
173
|
}, {
|
|
162
174
|
capabilities: {},
|
|
163
175
|
});
|
|
164
|
-
|
|
176
|
+
try {
|
|
177
|
+
await client.connect(transport);
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
181
|
+
// Provide helpful context when connection fails
|
|
182
|
+
if (stderrData.trim()) {
|
|
183
|
+
throw new Error(`Failed to connect to MCP server: ${errorMessage}\n\n` +
|
|
184
|
+
`Server stderr:\n${stderrData.trim()}\n\n` +
|
|
185
|
+
`Common causes:\n` +
|
|
186
|
+
` - Missing environment variables (check .env file)\n` +
|
|
187
|
+
` - Required external services not running\n` +
|
|
188
|
+
` - Missing API credentials`);
|
|
189
|
+
}
|
|
190
|
+
throw new Error(`Failed to connect to MCP server: ${errorMessage}`);
|
|
191
|
+
}
|
|
165
192
|
return client;
|
|
166
193
|
}
|
|
167
194
|
/**
|
|
@@ -251,15 +278,15 @@ async function runFullAssessment(options) {
|
|
|
251
278
|
}
|
|
252
279
|
const response = await client.listTools();
|
|
253
280
|
const tools = response.tools || [];
|
|
281
|
+
// Always emit tool discovery events to stderr for audit-worker parsing
|
|
282
|
+
// Format: TOOL_DISCOVERED:name|description|param1,param2,... (works even with --json flag)
|
|
283
|
+
for (const tool of tools) {
|
|
284
|
+
const description = tool.description || "";
|
|
285
|
+
const params = Object.keys(tool.inputSchema?.properties || {}).join(",");
|
|
286
|
+
console.error(`TOOL_DISCOVERED:${tool.name}|${description}|${params}`);
|
|
287
|
+
}
|
|
254
288
|
if (!options.jsonOnly) {
|
|
255
289
|
console.log(`🔧 Found ${tools.length} tool${tools.length !== 1 ? "s" : ""}`);
|
|
256
|
-
// Output individual tools to stderr for early parsing by audit-worker
|
|
257
|
-
// Format: TOOL_DISCOVERED:name|description
|
|
258
|
-
// This enables MCP Auditor UI to show tools immediately after connection
|
|
259
|
-
for (const tool of tools) {
|
|
260
|
-
const description = tool.description || "";
|
|
261
|
-
console.error(`TOOL_DISCOVERED:${tool.name}|${description}`);
|
|
262
|
-
}
|
|
263
290
|
}
|
|
264
291
|
const config = buildConfig(options);
|
|
265
292
|
const orchestrator = new AssessmentOrchestrator(config);
|
package/package.json
CHANGED