@mcpc-tech/unplugin-dev-inspector-mcp 0.0.35 → 0.0.37

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.
@@ -83445,19 +83445,6 @@ async function getOrCreateMcpClient(defKey, def) {
83445
83445
  mcpClientConnecting.delete(defKey);
83446
83446
  }
83447
83447
  }
83448
- async function releaseMcpClient(defKey) {
83449
- const entry = mcpClientPool.get(defKey);
83450
- if (!entry) return;
83451
- entry.refCount -= 1;
83452
- if (entry.refCount <= 0) {
83453
- mcpClientPool.delete(defKey);
83454
- try {
83455
- await entry.client.close();
83456
- } catch (err) {
83457
- console.error("Error closing MCP client:", err);
83458
- }
83459
- }
83460
- }
83461
83448
  var cleanupAllPooledClients = async () => {
83462
83449
  const entries = Array.from(mcpClientPool.entries());
83463
83450
  mcpClientPool.clear();
@@ -83515,12 +83502,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
83515
83502
  console.error(`Error creating MCP client for ${name}:`, error);
83516
83503
  }
83517
83504
  }
83518
- const cleanupClients = async () => {
83519
- await Promise.all(acquiredKeys.map((k) => releaseMcpClient(k)));
83520
- acquiredKeys.length = 0;
83521
- Object.keys(allTools).forEach((key) => delete allTools[key]);
83522
- Object.keys(allClients).forEach((key) => delete allClients[key]);
83523
- };
83505
+ const cleanupClients = async () => {};
83524
83506
  return {
83525
83507
  tools: allTools,
83526
83508
  clients: allClients,
@@ -86322,17 +86304,6 @@ var ComposableMCPServer = class extends _modelcontextprotocol_sdk_server_index_j
86322
86304
  server: this,
86323
86305
  toolNames: Object.keys(allTools)
86324
86306
  });
86325
- this.onclose = async () => {
86326
- await cleanupClients();
86327
- await this.disposePlugins();
86328
- await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
86329
- };
86330
- this.onerror = async (error) => {
86331
- await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
86332
- await cleanupClients();
86333
- await this.disposePlugins();
86334
- await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
86335
- };
86336
86307
  const toolNameToDetailList = Object.entries(allTools);
86337
86308
  const publicToolNames = this.getPublicToolNames();
86338
86309
  const hiddenToolNames = this.getHiddenToolNames();
@@ -86894,11 +86865,14 @@ var ConnectionManager = class {
86894
86865
  }
86895
86866
  }
86896
86867
  /**
86897
- * Handle watcher connection.
86898
- * @param sessionId - unique session ID
86899
- * @param clientId - who is connecting (vscode, acp, cursor, etc.)
86900
- * @param puppetId - who to control (inspector)
86901
- * @param transport - the transport instance
86868
+ * Get the currently active Inspector (browser) transport
86869
+ */
86870
+ getInspectorTransport() {
86871
+ if (!this.latestInspectorSessionId) return null;
86872
+ return this.transports[this.latestInspectorSessionId] || null;
86873
+ }
86874
+ /**
86875
+ * Bind watcher (e.g. VS Code/ACP) to Inspector (browser)
86902
86876
  */
86903
86877
  handleWatcherConnection(sessionId, clientId, puppetId, transport) {
86904
86878
  this.cleanupPreviousWatchers(clientId, sessionId);
@@ -88372,14 +88346,12 @@ async function loadMcpToolsV5(transport) {
88372
88346
  return tools;
88373
88347
  }
88374
88348
  /**
88375
- * Get an active transport from the connection manager
88349
+ * Get the Inspector transport from the connection manager
88376
88350
  */
88377
88351
  function getActiveTransport() {
88378
88352
  const connectionManager = getConnectionManager();
88379
88353
  if (!connectionManager) return null;
88380
- const sessionIds = Object.keys(connectionManager.transports);
88381
- if (sessionIds.length === 0) return null;
88382
- return connectionManager.transports[sessionIds[0]];
88354
+ return connectionManager.getInspectorTransport();
88383
88355
  }
88384
88356
  function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88385
88357
  /**
@@ -83480,19 +83480,6 @@ async function getOrCreateMcpClient(defKey, def) {
83480
83480
  mcpClientConnecting.delete(defKey);
83481
83481
  }
83482
83482
  }
83483
- async function releaseMcpClient(defKey) {
83484
- const entry = mcpClientPool.get(defKey);
83485
- if (!entry) return;
83486
- entry.refCount -= 1;
83487
- if (entry.refCount <= 0) {
83488
- mcpClientPool.delete(defKey);
83489
- try {
83490
- await entry.client.close();
83491
- } catch (err) {
83492
- console.error("Error closing MCP client:", err);
83493
- }
83494
- }
83495
- }
83496
83483
  var cleanupAllPooledClients = async () => {
83497
83484
  const entries = Array.from(mcpClientPool.entries());
83498
83485
  mcpClientPool.clear();
@@ -83550,12 +83537,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
83550
83537
  console.error(`Error creating MCP client for ${name}:`, error);
83551
83538
  }
83552
83539
  }
83553
- const cleanupClients = async () => {
83554
- await Promise.all(acquiredKeys.map((k) => releaseMcpClient(k)));
83555
- acquiredKeys.length = 0;
83556
- Object.keys(allTools).forEach((key) => delete allTools[key]);
83557
- Object.keys(allClients).forEach((key) => delete allClients[key]);
83558
- };
83540
+ const cleanupClients = async () => {};
83559
83541
  return {
83560
83542
  tools: allTools,
83561
83543
  clients: allClients,
@@ -86357,17 +86339,6 @@ var ComposableMCPServer = class extends Server {
86357
86339
  server: this,
86358
86340
  toolNames: Object.keys(allTools)
86359
86341
  });
86360
- this.onclose = async () => {
86361
- await cleanupClients();
86362
- await this.disposePlugins();
86363
- await this.logger.info(`[${name}] Event: closed - cleaned up dependent clients and plugins`);
86364
- };
86365
- this.onerror = async (error) => {
86366
- await this.logger.error(`[${name}] Event: error - ${error?.stack ?? String(error)}`);
86367
- await cleanupClients();
86368
- await this.disposePlugins();
86369
- await this.logger.info(`[${name}] Action: cleaned up dependent clients and plugins`);
86370
- };
86371
86342
  const toolNameToDetailList = Object.entries(allTools);
86372
86343
  const publicToolNames = this.getPublicToolNames();
86373
86344
  const hiddenToolNames = this.getHiddenToolNames();
@@ -86929,11 +86900,14 @@ var ConnectionManager = class {
86929
86900
  }
86930
86901
  }
86931
86902
  /**
86932
- * Handle watcher connection.
86933
- * @param sessionId - unique session ID
86934
- * @param clientId - who is connecting (vscode, acp, cursor, etc.)
86935
- * @param puppetId - who to control (inspector)
86936
- * @param transport - the transport instance
86903
+ * Get the currently active Inspector (browser) transport
86904
+ */
86905
+ getInspectorTransport() {
86906
+ if (!this.latestInspectorSessionId) return null;
86907
+ return this.transports[this.latestInspectorSessionId] || null;
86908
+ }
86909
+ /**
86910
+ * Bind watcher (e.g. VS Code/ACP) to Inspector (browser)
86937
86911
  */
86938
86912
  handleWatcherConnection(sessionId, clientId, puppetId, transport) {
86939
86913
  this.cleanupPreviousWatchers(clientId, sessionId);
@@ -88407,14 +88381,12 @@ async function loadMcpToolsV5(transport) {
88407
88381
  return tools;
88408
88382
  }
88409
88383
  /**
88410
- * Get an active transport from the connection manager
88384
+ * Get the Inspector transport from the connection manager
88411
88385
  */
88412
88386
  function getActiveTransport() {
88413
88387
  const connectionManager = getConnectionManager();
88414
88388
  if (!connectionManager) return null;
88415
- const sessionIds = Object.keys(connectionManager.transports);
88416
- if (sessionIds.length === 0) return null;
88417
- return connectionManager.transports[sessionIds[0]];
88389
+ return connectionManager.getInspectorTransport();
88418
88390
  }
88419
88391
  function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88420
88392
  /**
package/dist/index.cjs CHANGED
@@ -23,7 +23,7 @@ var browser_launcher_exports = /* @__PURE__ */ require_chunk.__export({ launchBr
23
23
  */
24
24
  async function launchBrowserWithDevTools(options) {
25
25
  const { url, serverContext } = options;
26
- const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=auto-browser`;
26
+ const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=temp-browser-launcher`;
27
27
  let client = null;
28
28
  try {
29
29
  client = new _modelcontextprotocol_sdk_client_index_js.Client({
@@ -40,13 +40,12 @@ async function launchBrowserWithDevTools(options) {
40
40
  chrome_navigate_page: { url }
41
41
  }
42
42
  });
43
- await new Promise((resolve) => setTimeout(resolve, 500));
44
43
  return true;
45
44
  } catch (error) {
46
45
  console.error(`[dev-inspector] ⚠️ Failed to auto-open browser:`, error instanceof Error ? error.message : String(error));
47
46
  return false;
48
47
  } finally {
49
- if (client) await client.close().catch(() => {});
48
+ await client?.close().catch(() => {});
50
49
  }
51
50
  }
52
51
  var init_browser_launcher = require_chunk.__esmMin((() => {}));
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ var browser_launcher_exports = /* @__PURE__ */ __export({ launchBrowserWithDevTo
19
19
  */
20
20
  async function launchBrowserWithDevTools(options) {
21
21
  const { url, serverContext } = options;
22
- const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=auto-browser`;
22
+ const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=temp-browser-launcher`;
23
23
  let client = null;
24
24
  try {
25
25
  client = new Client({
@@ -36,13 +36,12 @@ async function launchBrowserWithDevTools(options) {
36
36
  chrome_navigate_page: { url }
37
37
  }
38
38
  });
39
- await new Promise((resolve) => setTimeout(resolve, 500));
40
39
  return true;
41
40
  } catch (error) {
42
41
  console.error(`[dev-inspector] ⚠️ Failed to auto-open browser:`, error instanceof Error ? error.message : String(error));
43
42
  return false;
44
43
  } finally {
45
- if (client) await client.close().catch(() => {});
44
+ await client?.close().catch(() => {});
46
45
  }
47
46
  }
48
47
  var init_browser_launcher = __esmMin((() => {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/unplugin-dev-inspector-mcp",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "Universal dev inspector plugin for React/Vue - inspect component sources and API calls in any bundler",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -145,7 +145,7 @@
145
145
  "@xyflow/react": "^12.9.3",
146
146
  "ai": "^5.0.95",
147
147
  "aria-hidden": "^1.2.6",
148
- "chrome-devtools-mcp": "^0.10.1",
148
+ "chrome-devtools-mcp": "^0.12.1",
149
149
  "class-variance-authority": "^0.7.1",
150
150
  "clsx": "^2.1.1",
151
151
  "cmdk": "^1.1.1",
@@ -186,4 +186,4 @@
186
186
  "publishConfig": {
187
187
  "access": "public"
188
188
  }
189
- }
189
+ }