@mcpjam/inspector 0.3.3 → 0.3.5

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/cli/build/cli.js CHANGED
@@ -73,15 +73,13 @@ async function runWebClient(args) {
73
73
  if (serverOk) {
74
74
  try {
75
75
  console.log("\x1b[32m%s\x1b[0m", "✅ Server initialized successfully"); // Green color
76
- console.log("\x1b[36m%s\x1b[0m", `🌐 Opening browser at http://127.0.0.1:${CLIENT_PORT}`);
77
- if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
78
- // Note: We need to import 'open' if we want to auto-open browser
79
- // import open from "open";
80
- // open(`http://127.0.0.1:${CLIENT_PORT}`);
81
- }
82
76
  console.log("\x1b[33m%s\x1b[0m", "🖥️ Starting client interface...");
83
77
  await spawnPromise("node", [inspectorClientPath], {
84
- env: { ...process.env, PORT: CLIENT_PORT },
78
+ env: {
79
+ ...process.env,
80
+ PORT: CLIENT_PORT,
81
+ MCP_AUTO_OPEN_ENABLED: process.env.MCP_AUTO_OPEN_ENABLED ?? "true",
82
+ },
85
83
  signal: abort.signal,
86
84
  echoOutput: true,
87
85
  });
@@ -4,6 +4,7 @@ import { join, dirname } from "path";
4
4
  import { fileURLToPath } from "url";
5
5
  import handler from "serve-handler";
6
6
  import http from "http";
7
+ import open from "open";
7
8
 
8
9
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
10
  const distPath = join(__dirname, "../dist");
@@ -39,19 +40,32 @@ const server = http.createServer((request, response) => {
39
40
  return handler(request, response, handlerOptions);
40
41
  });
41
42
 
42
- const port = process.env.PORT || 6274;
43
+ const defaultPort = process.env.PORT || 6274;
44
+ let port = Number(defaultPort);
45
+
46
+ // Try ports sequentially until one works
47
+ server.on("error", (err) => {
48
+ if (err.code === "EADDRINUSE") {
49
+ console.log(`⚠️ Port ${port} was in use, trying ${port + 1}`);
50
+ port++;
51
+ server.listen(port);
52
+ } else {
53
+ console.error(`❌ MCPJam Inspector failed to start: ${err.message}`);
54
+ }
55
+ });
56
+
43
57
  server.on("listening", () => {
58
+ const url = `http://127.0.0.1:${port}`;
44
59
  console.log(
45
- `🔍 MCPJam Inspector is up and running at http://127.0.0.1:${port} 🚀`,
60
+ `🔍 MCPJam Inspector is up and running at \u001B]8;;${url}\u0007${url}\u001B]8;;\u0007 🚀`,
46
61
  );
47
- });
48
- server.on("error", (err) => {
49
- if (err.message.includes(`EADDRINUSE`)) {
50
- console.error(
51
- `❌ MCPJam Inspector PORT IS IN USE at http://127.0.0.1:${port} ❌ `,
62
+
63
+ if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
64
+ console.log(
65
+ `🌐 Opening browser at \u001B]8;;${url}\u0007${url}\u001B]8;;\u0007`,
52
66
  );
53
- } else {
54
- throw err;
67
+ open(url);
55
68
  }
56
69
  });
70
+
57
71
  server.listen(port);
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import open from "open";
4
3
  import { resolve, dirname } from "path";
5
4
  import { spawnPromise } from "spawn-rx";
6
5
  import { fileURLToPath } from "url";
@@ -87,6 +86,7 @@ async function main() {
87
86
  abort.abort();
88
87
  console.log("\n\x1b[31m%s\x1b[0m", "⚠️ Shutting down MCP Inspector..."); // Red color
89
88
  });
89
+
90
90
  let server, serverOk;
91
91
  try {
92
92
  server = spawnPromise(
@@ -116,19 +116,14 @@ async function main() {
116
116
  if (serverOk) {
117
117
  try {
118
118
  console.log("\x1b[32m%s\x1b[0m", "✅ Server initialized successfully"); // Green color
119
- console.log(
120
- "\x1b[36m%s\x1b[0m",
121
- `🌐 Opening browser at http://127.0.0.1:${CLIENT_PORT}`,
122
- );
123
-
124
- if (process.env.MCP_AUTO_OPEN_ENABLED !== "false") {
125
- open(`http://127.0.0.1:${CLIENT_PORT}`);
126
- }
127
-
128
119
  console.log("\x1b[33m%s\x1b[0m", "🖥️ Starting client interface...");
129
120
 
130
121
  await spawnPromise("node", [inspectorClientPath], {
131
- env: { ...process.env, PORT: CLIENT_PORT },
122
+ env: {
123
+ ...process.env,
124
+ PORT: CLIENT_PORT,
125
+ MCP_AUTO_OPEN_ENABLED: process.env.MCP_AUTO_OPEN_ENABLED ?? "true",
126
+ },
132
127
  signal: abort.signal,
133
128
  echoOutput: true,
134
129
  });
@@ -1,4 +1,4 @@
1
- import { u as useToast, r as reactExports, j as jsxRuntimeExports, p as parseOAuthCallbackParams, g as generateOAuthErrorDescription, S as SESSION_KEYS, I as InspectorOAuthClientProvider, a as auth } from "./index-DVHTINVl.js";
1
+ import { u as useToast, r as reactExports, j as jsxRuntimeExports, p as parseOAuthCallbackParams, g as generateOAuthErrorDescription, S as SESSION_KEYS, I as InspectorOAuthClientProvider, a as auth } from "./index-DQYTYcqe.js";
2
2
  const OAuthCallback = ({ onConnect }) => {
3
3
  const { toast } = useToast();
4
4
  const hasProcessedRef = reactExports.useRef(false);
@@ -1,4 +1,4 @@
1
- import { r as reactExports, S as SESSION_KEYS, p as parseOAuthCallbackParams, j as jsxRuntimeExports, g as generateOAuthErrorDescription } from "./index-DVHTINVl.js";
1
+ import { r as reactExports, S as SESSION_KEYS, p as parseOAuthCallbackParams, j as jsxRuntimeExports, g as generateOAuthErrorDescription } from "./index-DQYTYcqe.js";
2
2
  const OAuthDebugCallback = ({ onConnect }) => {
3
3
  reactExports.useEffect(() => {
4
4
  let isProcessed = false;