@modelcontextprotocol/inspector 0.17.5 → 0.18.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.
@@ -5,8 +5,8 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/mcp.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>MCP Inspector</title>
8
- <script type="module" crossorigin src="/assets/index-CneFQkmB.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-DH5T2nDo.css">
8
+ <script type="module" crossorigin src="/assets/index-Dw52pmVD.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/index-DoQUGvvr.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="root" class="w-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelcontextprotocol/inspector",
3
- "version": "0.17.5",
3
+ "version": "0.18.0",
4
4
  "description": "Model Context Protocol inspector",
5
5
  "license": "MIT",
6
6
  "author": "Anthropic, PBC (https://anthropic.com)",
@@ -47,10 +47,10 @@
47
47
  "check-version": "node scripts/check-version-consistency.js"
48
48
  },
49
49
  "dependencies": {
50
- "@modelcontextprotocol/inspector-cli": "^0.17.5",
51
- "@modelcontextprotocol/inspector-client": "^0.17.5",
52
- "@modelcontextprotocol/inspector-server": "^0.17.5",
53
- "@modelcontextprotocol/sdk": "^1.23.0",
50
+ "@modelcontextprotocol/inspector-cli": "^0.18.0",
51
+ "@modelcontextprotocol/inspector-client": "^0.18.0",
52
+ "@modelcontextprotocol/inspector-server": "^0.18.0",
53
+ "@modelcontextprotocol/sdk": "^1.24.3",
54
54
  "concurrently": "^9.2.0",
55
55
  "node-fetch": "^3.3.2",
56
56
  "open": "^10.2.0",
@@ -8,7 +8,7 @@ const fetch = nodeFetch;
8
8
  const Headers = NodeHeaders;
9
9
  import { SSEClientTransport, SseError, } from "@modelcontextprotocol/sdk/client/sse.js";
10
10
  import { StdioClientTransport, getDefaultEnvironment, } from "@modelcontextprotocol/sdk/client/stdio.js";
11
- import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
11
+ import { StreamableHTTPClientTransport, StreamableHTTPError, } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
12
12
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
13
13
  import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
14
14
  import express from "express";
@@ -30,6 +30,21 @@ const { values } = parseArgs({
30
30
  "server-url": { type: "string", default: "" },
31
31
  },
32
32
  });
33
+ /**
34
+ * Helper function to detect 401 Unauthorized errors from various transport types.
35
+ * StreamableHTTPClientTransport throws a generic Error with "HTTP 401" in the message
36
+ * when there's no authProvider configured, while SSEClientTransport throws SseError.
37
+ */
38
+ const is401Error = (error) => {
39
+ if (error instanceof SseError && error.code === 401)
40
+ return true;
41
+ if (error instanceof StreamableHTTPError && error.code === 401)
42
+ return true;
43
+ if (error instanceof Error &&
44
+ (error.message.includes("HTTP 401") || error.message.includes("(401)")))
45
+ return true;
46
+ return false;
47
+ };
33
48
  // Function to get HTTP headers.
34
49
  const getHttpHeaders = (req) => {
35
50
  const headers = {};
@@ -388,8 +403,8 @@ app.post("/mcp", originValidationMiddleware, authMiddleware, async (req, res) =>
388
403
  await webAppTransport.handleRequest(req, res, req.body);
389
404
  }
390
405
  catch (error) {
391
- if (error instanceof SseError && error.code === 401) {
392
- console.error("Received 401 Unauthorized from MCP server:", error.message);
406
+ if (is401Error(error)) {
407
+ console.error("Received 401 Unauthorized from MCP server:", error instanceof Error ? error.message : error);
393
408
  res.status(401).json(error);
394
409
  return;
395
410
  }
@@ -521,7 +536,7 @@ app.get("/stdio", originValidationMiddleware, authMiddleware, async (req, res) =
521
536
  });
522
537
  }
523
538
  catch (error) {
524
- if (error instanceof SseError && error.code === 401) {
539
+ if (is401Error(error)) {
525
540
  console.error("Received 401 Unauthorized from MCP server. Authentication failure.");
526
541
  res.status(401).json(error);
527
542
  return;
@@ -552,7 +567,7 @@ app.get("/sse", originValidationMiddleware, authMiddleware, async (req, res) =>
552
567
  });
553
568
  }
554
569
  catch (error) {
555
- if (error instanceof SseError && error.code === 401) {
570
+ if (is401Error(error)) {
556
571
  console.error("Received 401 Unauthorized from MCP server. Authentication failure.");
557
572
  res.status(401).json(error);
558
573
  return;