@bryan-thompson/inspector-assessment-server 1.7.1 → 1.8.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 +20 -5
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const fetch = nodeFetch;
|
|
|
9
9
|
const Headers = NodeHeaders;
|
|
10
10
|
import { SSEClientTransport, SseError, } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
11
11
|
import { StdioClientTransport, getDefaultEnvironment, } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
12
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
12
|
+
import { StreamableHTTPClientTransport, StreamableHTTPError, } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
13
13
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
14
14
|
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
|
|
15
15
|
import express from "express";
|
|
@@ -31,6 +31,21 @@ const { values } = parseArgs({
|
|
|
31
31
|
"server-url": { type: "string", default: "" },
|
|
32
32
|
},
|
|
33
33
|
});
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to detect 401 Unauthorized errors from various transport types.
|
|
36
|
+
* StreamableHTTPClientTransport throws a generic Error with "HTTP 401" in the message
|
|
37
|
+
* when there's no authProvider configured, while SSEClientTransport throws SseError.
|
|
38
|
+
*/
|
|
39
|
+
const is401Error = (error) => {
|
|
40
|
+
if (error instanceof SseError && error.code === 401)
|
|
41
|
+
return true;
|
|
42
|
+
if (error instanceof StreamableHTTPError && error.code === 401)
|
|
43
|
+
return true;
|
|
44
|
+
if (error instanceof Error &&
|
|
45
|
+
(error.message.includes("HTTP 401") || error.message.includes("(401)")))
|
|
46
|
+
return true;
|
|
47
|
+
return false;
|
|
48
|
+
};
|
|
34
49
|
// Function to get HTTP headers.
|
|
35
50
|
const getHttpHeaders = (req) => {
|
|
36
51
|
const headers = {};
|
|
@@ -389,8 +404,8 @@ app.post("/mcp", originValidationMiddleware, authMiddleware, async (req, res) =>
|
|
|
389
404
|
await webAppTransport.handleRequest(req, res, req.body);
|
|
390
405
|
}
|
|
391
406
|
catch (error) {
|
|
392
|
-
if (error
|
|
393
|
-
console.error("Received 401 Unauthorized from MCP server:", error.message);
|
|
407
|
+
if (is401Error(error)) {
|
|
408
|
+
console.error("Received 401 Unauthorized from MCP server:", error instanceof Error ? error.message : error);
|
|
394
409
|
res.status(401).json(error);
|
|
395
410
|
return;
|
|
396
411
|
}
|
|
@@ -522,7 +537,7 @@ app.get("/stdio", originValidationMiddleware, authMiddleware, async (req, res) =
|
|
|
522
537
|
});
|
|
523
538
|
}
|
|
524
539
|
catch (error) {
|
|
525
|
-
if (error
|
|
540
|
+
if (is401Error(error)) {
|
|
526
541
|
console.error("Received 401 Unauthorized from MCP server. Authentication failure.");
|
|
527
542
|
res.status(401).json(error);
|
|
528
543
|
return;
|
|
@@ -553,7 +568,7 @@ app.get("/sse", originValidationMiddleware, authMiddleware, async (req, res) =>
|
|
|
553
568
|
});
|
|
554
569
|
}
|
|
555
570
|
catch (error) {
|
|
556
|
-
if (error
|
|
571
|
+
if (is401Error(error)) {
|
|
557
572
|
console.error("Received 401 Unauthorized from MCP server. Authentication failure.");
|
|
558
573
|
res.status(401).json(error);
|
|
559
574
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bryan-thompson/inspector-assessment-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Server-side application for the Enhanced MCP Inspector with assessment capabilities",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Bryan Thompson <bryan@triepod.ai>",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typescript": "^5.6.2"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
41
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
42
42
|
"cors": "^2.8.5",
|
|
43
43
|
"express": "^5.1.0",
|
|
44
44
|
"shell-quote": "^1.8.3",
|