@mcpc-tech/unplugin-dev-inspector-mcp 0.0.42 → 0.0.44

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.
@@ -86411,7 +86411,11 @@ const PROMPT_SCHEMAS = {
86411
86411
  name: "capture_element",
86412
86412
  title: "Capture Element Context",
86413
86413
  description: "Capture context about a UI element for troubleshooting and investigation.",
86414
- arguments: []
86414
+ arguments: [{
86415
+ name: "automated",
86416
+ description: "If true, the AI will automate the capture process (click/feedback/submit).",
86417
+ required: false
86418
+ }]
86415
86419
  },
86416
86420
  view_inspections: {
86417
86421
  name: "view_inspections",
@@ -86452,10 +86456,19 @@ const PROMPT_SCHEMAS = {
86452
86456
  const TOOL_SCHEMAS = {
86453
86457
  capture_element_context: {
86454
86458
  name: "capture_element_context",
86455
- description: "Capture element context for troubleshooting. Activates visual selector, user clicks element and provides notes, returns source location, DOM hierarchy, computed styles, dimensions, and user notes. Combine with chrome_devtools MCP for deeper diagnostics (Network, Console, Performance, DOM tools).",
86459
+ description: `Capture element context for troubleshooting.
86460
+
86461
+ **Default (automated=false)**: Manual mode - activates visual selector for user interaction.
86462
+
86463
+ **Automated (automated=true)**: AI controls capture by clicking elements programmatically. Only set to true when user needs automation.
86464
+
86465
+ Returns: source location, DOM hierarchy, computed styles, dimensions, and user notes. Use \`list_inspections\` to view all captured elements.`,
86456
86466
  inputSchema: {
86457
86467
  type: "object",
86458
- properties: {}
86468
+ properties: { automated: {
86469
+ type: "boolean",
86470
+ description: "Set to true ONLY when user explicitly requests automated capture. Default is false (manual mode)."
86471
+ } }
86459
86472
  }
86460
86473
  },
86461
86474
  list_inspections: {
@@ -86606,6 +86619,8 @@ function callMcpMethod(mcpServer, method, params) {
86606
86619
  */
86607
86620
  async function createInspectorMcpServer(serverContext) {
86608
86621
  const chromeDisabled = isChromeDisabled(serverContext?.disableChrome);
86622
+ const isAutomated = serverContext?.isAutomated ?? false;
86623
+ console.log(`[dev-inspector] Chrome DevTools integration is ${chromeDisabled ? "disabled" : "enabled"}`);
86609
86624
  const mcpServer = await mcpc([{
86610
86625
  name: "dev-inspector",
86611
86626
  version: "1.0.0",
@@ -86620,10 +86635,10 @@ async function createInspectorMcpServer(serverContext) {
86620
86635
 
86621
86636
  Provides tools for inspecting network requests, console logs, and performance metrics.
86622
86637
 
86623
- If Chrome is already open, this tool can connect to it directly. Otherwise, call chrome_navigate_page first to launch Chrome.
86624
- Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`}
86638
+ ${isAutomated ? "Chrome is already open and connected. You can use this tool to inspect the page directly." : "The client does not support automation. You MUST ask the user for confirmation before navigating to any URL."}
86625
86639
 
86626
- You MUST ask the user for confirmation before navigating to any URL.`,
86640
+ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`}
86641
+ `,
86627
86642
  options: { refs: [
86628
86643
  "<tool name=\"chrome.navigate_page\"/>",
86629
86644
  "<tool name=\"chrome.list_pages\"/>",
@@ -86761,7 +86776,7 @@ You MUST ask the user for confirmation before navigating to any URL.`,
86761
86776
  switch (promptName) {
86762
86777
  case "capture_element": return { messages: (await callMcpMethod(mcpServer, "tools/call", {
86763
86778
  name: "capture_element_context",
86764
- arguments: {}
86779
+ arguments: { automated: request.params.arguments?.automated === "true" }
86765
86780
  }))?.content.map((item) => ({
86766
86781
  role: "user",
86767
86782
  content: item
@@ -87142,7 +87157,6 @@ async function handleSseConnection(req, res, serverContext, connectionManager) {
87142
87157
  }
87143
87158
  res.socket?.setKeepAlive?.(true);
87144
87159
  res.socket?.setTimeout?.(0);
87145
- const mcpServer = await createInspectorMcpServer(serverContext);
87146
87160
  const host = serverContext?.host || "localhost";
87147
87161
  const port = serverContext?.port || 5173;
87148
87162
  const url$1 = new URL(req.url ?? "", `http://${host}:${port}`);
@@ -87150,6 +87164,13 @@ async function handleSseConnection(req, res, serverContext, connectionManager) {
87150
87164
  const sessionId = transport.sessionId;
87151
87165
  const clientId = url$1.searchParams.get("clientId") || `agent-${sessionId}`;
87152
87166
  const puppetId = url$1.searchParams.get("puppetId") || "inspector";
87167
+ const isAutomated = url$1.searchParams.get("isAutomated") === "true";
87168
+ console.log(`[dev-inspector] New SSE connection: sessionId=${sessionId}, clientId=${clientId}, puppetId=${puppetId}, isAutomated=${isAutomated}`);
87169
+ if (isAutomated && serverContext) serverContext.isAutomated = true;
87170
+ const mcpServer = await createInspectorMcpServer({
87171
+ ...serverContext,
87172
+ isAutomated
87173
+ });
87153
87174
  console.log(`[dev-inspector] [sse] New connection request: clientId=${clientId}, puppetId=${puppetId}, sessionId=${sessionId}`);
87154
87175
  connectionManager.registerTransport(sessionId, transport);
87155
87176
  if (clientId === "inspector") {
@@ -88651,7 +88672,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88651
88672
  }
88652
88673
  try {
88653
88674
  const body = await readBody(req);
88654
- const { messages, agent, envVars, sessionId } = JSON.parse(body);
88675
+ const { messages, agent, envVars, sessionId, isAutomated } = JSON.parse(body);
88655
88676
  const cwd$1 = process.cwd();
88656
88677
  let provider;
88657
88678
  let shouldCleanupProvider = true;
@@ -88698,10 +88719,12 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88698
88719
  await new Promise((resolve$1) => setTimeout(resolve$1, delay));
88699
88720
  }
88700
88721
  const abortController = new AbortController();
88701
- req.on("close", () => {
88702
- console.log("[dev-inspector] [acp] Client disconnected, aborting stream");
88703
- abortController.abort();
88704
- if (shouldCleanupProvider) provider.cleanup();
88722
+ res.on("close", () => {
88723
+ if (!abortController.signal.aborted) {
88724
+ console.log("[dev-inspector] [acp] Client disconnected, aborting stream");
88725
+ abortController.abort();
88726
+ if (shouldCleanupProvider) provider.cleanup();
88727
+ }
88705
88728
  });
88706
88729
  const systemPrompt = agent.acpSystemPrompt ?? acpOptions?.acpSystemPrompt ?? DEFAULT_SYSTEM_INSTRUCTIONS;
88707
88730
  const enhancedMessages = (0, ai.convertToModelMessages)(messages).map((msg, index$1) => {
@@ -88709,7 +88732,11 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88709
88732
  ...msg,
88710
88733
  content: [{
88711
88734
  type: "text",
88712
- text: `<system_instructions>\n${systemPrompt}\n</system_instructions>\n\n`
88735
+ text: `<system_instructions>
88736
+ ${systemPrompt}
88737
+ ${isAutomated ? "" : "Currently chrome devtools automation is disabled. You do not have access to Console/Network context."}
88738
+ </system_instructions>
88739
+ `
88713
88740
  }, ...msg.content]
88714
88741
  };
88715
88742
  return msg;
@@ -88722,7 +88749,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88722
88749
  tools: acpTools(mcpTools),
88723
88750
  onError: (error) => {
88724
88751
  console.error("Error occurred while streaming text:", JSON.stringify(error, null, 2));
88725
- provider.cleanup();
88752
+ if (shouldCleanupProvider) provider.cleanup();
88726
88753
  }
88727
88754
  }).toUIMessageStreamResponse({
88728
88755
  messageMetadata: ({ part }) => {
@@ -86446,7 +86446,11 @@ const PROMPT_SCHEMAS = {
86446
86446
  name: "capture_element",
86447
86447
  title: "Capture Element Context",
86448
86448
  description: "Capture context about a UI element for troubleshooting and investigation.",
86449
- arguments: []
86449
+ arguments: [{
86450
+ name: "automated",
86451
+ description: "If true, the AI will automate the capture process (click/feedback/submit).",
86452
+ required: false
86453
+ }]
86450
86454
  },
86451
86455
  view_inspections: {
86452
86456
  name: "view_inspections",
@@ -86487,10 +86491,19 @@ const PROMPT_SCHEMAS = {
86487
86491
  const TOOL_SCHEMAS = {
86488
86492
  capture_element_context: {
86489
86493
  name: "capture_element_context",
86490
- description: "Capture element context for troubleshooting. Activates visual selector, user clicks element and provides notes, returns source location, DOM hierarchy, computed styles, dimensions, and user notes. Combine with chrome_devtools MCP for deeper diagnostics (Network, Console, Performance, DOM tools).",
86494
+ description: `Capture element context for troubleshooting.
86495
+
86496
+ **Default (automated=false)**: Manual mode - activates visual selector for user interaction.
86497
+
86498
+ **Automated (automated=true)**: AI controls capture by clicking elements programmatically. Only set to true when user needs automation.
86499
+
86500
+ Returns: source location, DOM hierarchy, computed styles, dimensions, and user notes. Use \`list_inspections\` to view all captured elements.`,
86491
86501
  inputSchema: {
86492
86502
  type: "object",
86493
- properties: {}
86503
+ properties: { automated: {
86504
+ type: "boolean",
86505
+ description: "Set to true ONLY when user explicitly requests automated capture. Default is false (manual mode)."
86506
+ } }
86494
86507
  }
86495
86508
  },
86496
86509
  list_inspections: {
@@ -86641,6 +86654,8 @@ function callMcpMethod(mcpServer, method, params) {
86641
86654
  */
86642
86655
  async function createInspectorMcpServer(serverContext) {
86643
86656
  const chromeDisabled = isChromeDisabled(serverContext?.disableChrome);
86657
+ const isAutomated = serverContext?.isAutomated ?? false;
86658
+ console.log(`[dev-inspector] Chrome DevTools integration is ${chromeDisabled ? "disabled" : "enabled"}`);
86644
86659
  const mcpServer = await mcpc([{
86645
86660
  name: "dev-inspector",
86646
86661
  version: "1.0.0",
@@ -86655,10 +86670,10 @@ async function createInspectorMcpServer(serverContext) {
86655
86670
 
86656
86671
  Provides tools for inspecting network requests, console logs, and performance metrics.
86657
86672
 
86658
- If Chrome is already open, this tool can connect to it directly. Otherwise, call chrome_navigate_page first to launch Chrome.
86659
- Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`}
86673
+ ${isAutomated ? "Chrome is already open and connected. You can use this tool to inspect the page directly." : "The client does not support automation. You MUST ask the user for confirmation before navigating to any URL."}
86660
86674
 
86661
- You MUST ask the user for confirmation before navigating to any URL.`,
86675
+ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`}
86676
+ `,
86662
86677
  options: { refs: [
86663
86678
  "<tool name=\"chrome.navigate_page\"/>",
86664
86679
  "<tool name=\"chrome.list_pages\"/>",
@@ -86796,7 +86811,7 @@ You MUST ask the user for confirmation before navigating to any URL.`,
86796
86811
  switch (promptName) {
86797
86812
  case "capture_element": return { messages: (await callMcpMethod(mcpServer, "tools/call", {
86798
86813
  name: "capture_element_context",
86799
- arguments: {}
86814
+ arguments: { automated: request.params.arguments?.automated === "true" }
86800
86815
  }))?.content.map((item) => ({
86801
86816
  role: "user",
86802
86817
  content: item
@@ -87177,7 +87192,6 @@ async function handleSseConnection(req, res, serverContext, connectionManager) {
87177
87192
  }
87178
87193
  res.socket?.setKeepAlive?.(true);
87179
87194
  res.socket?.setTimeout?.(0);
87180
- const mcpServer = await createInspectorMcpServer(serverContext);
87181
87195
  const host = serverContext?.host || "localhost";
87182
87196
  const port = serverContext?.port || 5173;
87183
87197
  const url = new URL(req.url ?? "", `http://${host}:${port}`);
@@ -87185,6 +87199,13 @@ async function handleSseConnection(req, res, serverContext, connectionManager) {
87185
87199
  const sessionId = transport.sessionId;
87186
87200
  const clientId = url.searchParams.get("clientId") || `agent-${sessionId}`;
87187
87201
  const puppetId = url.searchParams.get("puppetId") || "inspector";
87202
+ const isAutomated = url.searchParams.get("isAutomated") === "true";
87203
+ console.log(`[dev-inspector] New SSE connection: sessionId=${sessionId}, clientId=${clientId}, puppetId=${puppetId}, isAutomated=${isAutomated}`);
87204
+ if (isAutomated && serverContext) serverContext.isAutomated = true;
87205
+ const mcpServer = await createInspectorMcpServer({
87206
+ ...serverContext,
87207
+ isAutomated
87208
+ });
87188
87209
  console.log(`[dev-inspector] [sse] New connection request: clientId=${clientId}, puppetId=${puppetId}, sessionId=${sessionId}`);
87189
87210
  connectionManager.registerTransport(sessionId, transport);
87190
87211
  if (clientId === "inspector") {
@@ -88686,7 +88707,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88686
88707
  }
88687
88708
  try {
88688
88709
  const body = await readBody(req);
88689
- const { messages, agent, envVars, sessionId } = JSON.parse(body);
88710
+ const { messages, agent, envVars, sessionId, isAutomated } = JSON.parse(body);
88690
88711
  const cwd$1 = process.cwd();
88691
88712
  let provider;
88692
88713
  let shouldCleanupProvider = true;
@@ -88733,10 +88754,12 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88733
88754
  await new Promise((resolve$2) => setTimeout(resolve$2, delay));
88734
88755
  }
88735
88756
  const abortController = new AbortController();
88736
- req.on("close", () => {
88737
- console.log("[dev-inspector] [acp] Client disconnected, aborting stream");
88738
- abortController.abort();
88739
- if (shouldCleanupProvider) provider.cleanup();
88757
+ res.on("close", () => {
88758
+ if (!abortController.signal.aborted) {
88759
+ console.log("[dev-inspector] [acp] Client disconnected, aborting stream");
88760
+ abortController.abort();
88761
+ if (shouldCleanupProvider) provider.cleanup();
88762
+ }
88740
88763
  });
88741
88764
  const systemPrompt = agent.acpSystemPrompt ?? acpOptions?.acpSystemPrompt ?? DEFAULT_SYSTEM_INSTRUCTIONS;
88742
88765
  const enhancedMessages = convertToModelMessages(messages).map((msg, index$1) => {
@@ -88744,7 +88767,11 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88744
88767
  ...msg,
88745
88768
  content: [{
88746
88769
  type: "text",
88747
- text: `<system_instructions>\n${systemPrompt}\n</system_instructions>\n\n`
88770
+ text: `<system_instructions>
88771
+ ${systemPrompt}
88772
+ ${isAutomated ? "" : "Currently chrome devtools automation is disabled. You do not have access to Console/Network context."}
88773
+ </system_instructions>
88774
+ `
88748
88775
  }, ...msg.content]
88749
88776
  };
88750
88777
  return msg;
@@ -88757,7 +88784,7 @@ function setupAcpMiddleware(middlewares, serverContext, acpOptions) {
88757
88784
  tools: acpTools(mcpTools),
88758
88785
  onError: (error) => {
88759
88786
  console.error("Error occurred while streaming text:", JSON.stringify(error, null, 2));
88760
- provider.cleanup();
88787
+ if (shouldCleanupProvider) provider.cleanup();
88761
88788
  }
88762
88789
  }).toUIMessageStreamResponse({
88763
88790
  messageMetadata: ({ part }) => {
package/dist/index.cjs CHANGED
@@ -76,7 +76,7 @@ async function launchBrowserWithDevTools(options) {
76
76
  console.log(`[dev-inspector] 📴 Skipping browser launch: Chrome integration disabled (DEV_INSPECTOR_DISABLE_CHROME=1 or disableChrome: true)`);
77
77
  return false;
78
78
  }
79
- const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=browser-launcher-${process.pid}`;
79
+ const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=browser-launcher-${process.pid}&isAutomated=true`;
80
80
  try {
81
81
  await (await getOrCreateClient(sseUrl)).callTool({
82
82
  name: "chrome_devtools",
package/dist/index.js CHANGED
@@ -72,7 +72,7 @@ async function launchBrowserWithDevTools(options) {
72
72
  console.log(`[dev-inspector] 📴 Skipping browser launch: Chrome integration disabled (DEV_INSPECTOR_DISABLE_CHROME=1 or disableChrome: true)`);
73
73
  return false;
74
74
  }
75
- const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=browser-launcher-${process.pid}`;
75
+ const sseUrl = `http://${serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host || "localhost"}:${serverContext.port || 5173}/__mcp__/sse?clientId=browser-launcher-${process.pid}&isAutomated=true`;
76
76
  try {
77
77
  await (await getOrCreateClient(sseUrl)).callTool({
78
78
  name: "chrome_devtools",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/unplugin-dev-inspector-mcp",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
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",