@mcpc-tech/unplugin-dev-inspector-mcp 0.0.1 → 0.0.2-beta.2

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/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ require("@modelcontextprotocol/sdk/server/index.js");
38
38
  let __mcpc_tech_core = require("@mcpc-tech/core");
39
39
  let node_path = require("node:path");
40
40
  node_path = __toESM(node_path);
41
+ let node_url = require("node:url");
41
42
  let fs = require("fs");
42
43
  fs = __toESM(fs);
43
44
  let path = require("path");
@@ -48,6 +49,7 @@ let __mcpc_tech_acp_ai_provider = require("@mcpc-tech/acp-ai-provider");
48
49
  let __agentclientprotocol_sdk = require("@agentclientprotocol/sdk");
49
50
  let node_fs = require("node:fs");
50
51
  let node_module = require("node:module");
52
+ let __vue_compiler_sfc = require("@vue/compiler-sfc");
51
53
 
52
54
  //#region ../../node_modules/.pnpm/@mcpc-tech+cmcp@0.0.13-beta.2/node_modules/@mcpc-tech/cmcp/index.mjs
53
55
  var ClientToolResponseRequestSchema = zod.z.object({
@@ -412,6 +414,49 @@ function bindPuppet(transport, puppet, methods = [...DEFAULT_FORWARDED]) {
412
414
  }
413
415
  var encoder = new TextEncoder();
414
416
 
417
+ //#endregion
418
+ //#region src/prompt-schemas.ts
419
+ /**
420
+ * Shared prompt schemas for MCP inspector prompts
421
+ * Used by both server and client implementations
422
+ */
423
+ const PROMPT_SCHEMAS = {
424
+ capture_element: {
425
+ name: "capture_element",
426
+ title: "Capture Element Context",
427
+ description: "Capture context about a UI element for troubleshooting and investigation.",
428
+ arguments: []
429
+ },
430
+ view_inspections: {
431
+ name: "view_inspections",
432
+ title: "View All Inspections",
433
+ description: "View all element inspections in the queue with their status.",
434
+ arguments: []
435
+ },
436
+ launch_chrome_devtools: {
437
+ name: "launch_chrome_devtools",
438
+ title: "Launch Chrome DevTools",
439
+ description: "Launch Chrome DevTools and navigate to a specified URL for debugging and inspection.",
440
+ arguments: [{
441
+ name: "url",
442
+ description: "The URL to navigate to (e.g., http://localhost:3000)",
443
+ required: true
444
+ }]
445
+ },
446
+ refresh_chrome_state: {
447
+ name: "refresh_chrome_state",
448
+ title: "Refresh Chrome State",
449
+ description: "Refresh the state of the Chrome DevTools for the specified URL.",
450
+ arguments: []
451
+ },
452
+ get_network_requests: {
453
+ name: "get_network_requests",
454
+ title: "Get Network Requests",
455
+ description: "Get all network requests for the specified URL.",
456
+ arguments: []
457
+ }
458
+ };
459
+
415
460
  //#endregion
416
461
  //#region src/tool-schemas.ts
417
462
  /**
@@ -419,31 +464,31 @@ var encoder = new TextEncoder();
419
464
  * Used by both server and client implementations
420
465
  */
421
466
  const TOOL_SCHEMAS = {
422
- inspect_element: {
423
- name: "inspect_element",
424
- description: "Activate the visual element inspector to let the user select a UI element on the page. The user will click an element and provide feedback about what they want to change. Returns the source code location and user feedback.",
467
+ capture_element_context: {
468
+ name: "capture_element_context",
469
+ 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).",
425
470
  inputSchema: {
426
471
  type: "object",
427
472
  properties: {}
428
473
  }
429
474
  },
430
- get_all_feedbacks: {
431
- name: "get_all_feedbacks",
432
- description: "Get a list of all current feedback items in the queue, including their status (pending/loading/success/error) and progress. Use this to see what tasks are already being worked on.",
475
+ list_inspections: {
476
+ name: "list_inspections",
477
+ description: "List all captured inspections with ID, element details, source location, notes, and status (pending/in-progress/completed/failed). Use with chrome_devtools for additional context (Console.getMessages, Network.getHAR, Performance.getMetrics).",
433
478
  inputSchema: {
434
479
  type: "object",
435
480
  properties: {}
436
481
  }
437
482
  },
438
- update_feedback_status: {
439
- name: "update_feedback_status",
440
- description: "Update the status of the current feedback item in the user's queue. Use this to show progress or mark completion.",
483
+ update_inspection_status: {
484
+ name: "update_inspection_status",
485
+ description: "Update inspection status with optional progress tracking.\n\n**Parameters**:\n- inspectionId: Optional (auto-detects if omitted)\n- status: 'in-progress' | 'completed' | 'failed'\n- progress: Optional steps array [{id, title, status}]\n- message: REQUIRED for 'completed'/'failed' status\n\n**Example**:\n```javascript\nupdate_inspection_status({\n status: 'completed',\n message: 'Fixed: pointer-events: none blocking clicks'\n});\n```",
441
486
  inputSchema: {
442
487
  type: "object",
443
488
  properties: {
444
- feedbackId: {
489
+ inspectionId: {
445
490
  type: "string",
446
- description: "Optional feedback ID. If not provided, will use the most recent loading feedback or the one from session."
491
+ description: "Optional inspection ID. If not provided, uses the current active inspection."
447
492
  },
448
493
  status: {
449
494
  type: "string",
@@ -452,7 +497,7 @@ const TOOL_SCHEMAS = {
452
497
  "completed",
453
498
  "failed"
454
499
  ],
455
- description: "Current status: 'in-progress' for updates, 'completed' when done, 'failed' on error"
500
+ description: "Current status: 'in-progress' for updates, 'completed' when resolved, 'failed' if unresolvable"
456
501
  },
457
502
  progress: {
458
503
  type: "object",
@@ -480,21 +525,43 @@ const TOOL_SCHEMAS = {
480
525
  ]
481
526
  }
482
527
  } },
483
- description: "Optional progress info with step-by-step details"
528
+ description: "Optional step-by-step progress tracking"
484
529
  },
485
530
  message: {
486
531
  type: "string",
487
- description: "Status message or completion summary. REQUIRED when status is 'completed' or 'failed'"
532
+ description: "Summary of findings or resolution. REQUIRED when status is 'completed' or 'failed'"
488
533
  }
489
534
  },
490
535
  required: ["status"]
491
536
  }
537
+ },
538
+ execute_page_script: {
539
+ name: "execute_page_script",
540
+ description: "Execute JavaScript in browser context (synchronous only, must return value). Access: window, document, DOM APIs, React/Vue instances, localStorage. For deeper diagnostics, use chrome_devtools MCP (Network.getHAR, Console.getMessages, Performance.getMetrics, Debugger, HeapProfiler).",
541
+ inputSchema: {
542
+ type: "object",
543
+ properties: { code: {
544
+ type: "string",
545
+ description: "JavaScript code to execute in page context. Must return a value for diagnostic output."
546
+ } },
547
+ required: ["code"]
548
+ }
492
549
  }
493
550
  };
494
551
 
495
552
  //#endregion
496
553
  //#region src/mcp.ts
497
554
  /**
555
+ * Get Chrome DevTools binary path from npm package, then use node to run it, faster/stabler than npx
556
+ */
557
+ function getChromeDevToolsBinPath() {
558
+ const resolver = {}.resolve;
559
+ if (!resolver) throw new Error("Cannot resolve chrome-devtools-mcp package");
560
+ const pkgUrl = resolver("chrome-devtools-mcp/package.json");
561
+ const chromeDevTools = node_path.default.dirname((0, node_url.fileURLToPath)(pkgUrl));
562
+ return node_path.default.join(chromeDevTools, "./build/src/index.js");
563
+ }
564
+ /**
498
565
  * Call MCP server method and wait for response
499
566
  * @param mcpServer - The MCP server instance
500
567
  * @param method - The method name to call
@@ -527,51 +594,178 @@ function callMcpMethod(mcpServer, method, params) {
527
594
  /**
528
595
  * Create and configure the MCP server for source inspection
529
596
  */
530
- async function createInspectorMcpServer() {
597
+ async function createInspectorMcpServer(serverContext) {
531
598
  const mcpServer = await (0, __mcpc_tech_core.mcpc)([{
532
599
  name: "dev-inspector",
533
600
  version: "1.0.0",
534
601
  title: "A tool for inspecting and interacting with the development environment."
535
602
  }, { capabilities: {
536
- tools: {},
603
+ tools: { listChanged: true },
537
604
  sampling: {},
538
- prompts: {}
539
- } }], []);
605
+ prompts: { listChanged: true }
606
+ } }], [{
607
+ name: "chrome_devtools",
608
+ description: `Access Chrome DevTools for browser diagnostics.
609
+
610
+ Provides tools for inspecting network requests, console logs, and performance metrics.
611
+
612
+ IMPORTANT: Must first call chrome_navigate_page to launch Chrome before using these capabilities.
613
+ Default dev server URL: http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}
614
+
615
+ You MUST ask the user for confirmation before navigating to any URL.`,
616
+ options: { refs: ["<tool name=\"chrome.__ALL__\"/>"] },
617
+ deps: { mcpServers: { chrome: {
618
+ transportType: "stdio",
619
+ command: "node",
620
+ args: [getChromeDevToolsBinPath()]
621
+ } } }
622
+ }]);
540
623
  const mcpClientExecServer = createClientExecServer(mcpServer, "inspector");
541
624
  mcpClientExecServer.registerClientToolSchemas([
542
- { ...TOOL_SCHEMAS.inspect_element },
543
- { ...TOOL_SCHEMAS.get_all_feedbacks },
544
- { ...TOOL_SCHEMAS.update_feedback_status }
625
+ { ...TOOL_SCHEMAS.capture_element_context },
626
+ { ...TOOL_SCHEMAS.list_inspections },
627
+ { ...TOOL_SCHEMAS.update_inspection_status },
628
+ { ...TOOL_SCHEMAS.execute_page_script }
545
629
  ]);
546
630
  mcpServer.setRequestHandler(__modelcontextprotocol_sdk_types_js.ListPromptsRequestSchema, async (request) => {
547
- return { prompts: [{
548
- name: "grab-element",
549
- title: "Inspect Element",
550
- description: "Inspect a UI element and get user feedback for modifications.",
551
- arguments: []
552
- }, {
553
- name: "view-feedbacks",
554
- title: "View All Feedbacks",
555
- description: "View all current feedback items in the queue with their status.",
556
- arguments: []
557
- }] };
631
+ const defaultUrl = `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`;
632
+ return { prompts: [
633
+ { ...PROMPT_SCHEMAS.capture_element },
634
+ { ...PROMPT_SCHEMAS.view_inspections },
635
+ {
636
+ ...PROMPT_SCHEMAS.launch_chrome_devtools,
637
+ description: `Launch Chrome DevTools and navigate to the dev server for debugging and inspection. Default URL: ${defaultUrl}. You can use this default URL or provide a custom one.`,
638
+ arguments: [{
639
+ name: "url",
640
+ description: `The URL to navigate to. Press Enter to use default: ${defaultUrl}`,
641
+ required: false
642
+ }]
643
+ },
644
+ { ...PROMPT_SCHEMAS.refresh_chrome_state }
645
+ ] };
558
646
  });
559
647
  mcpServer.setRequestHandler(__modelcontextprotocol_sdk_types_js.GetPromptRequestSchema, async (request) => {
560
- if (request.params.name === "grab-element") return { messages: (await callMcpMethod(mcpServer, "tools/call", {
561
- name: "inspect_element",
562
- arguments: {}
563
- }))?.content.map((item) => ({
564
- role: "user",
565
- content: item
566
- })) || [] };
567
- else if (request.params.name === "view-feedbacks") return { messages: (await callMcpMethod(mcpServer, "tools/call", {
568
- name: "get_all_feedbacks",
569
- arguments: {}
570
- }))?.content.map((item) => ({
571
- role: "user",
572
- content: item
573
- })) || [] };
574
- else throw new Error(`Unknown promptId: ${request.params.name}`);
648
+ const promptName = request.params.name;
649
+ switch (promptName) {
650
+ case "capture_element": return { messages: (await callMcpMethod(mcpServer, "tools/call", {
651
+ name: "capture_element_context",
652
+ arguments: {}
653
+ }))?.content.map((item) => ({
654
+ role: "user",
655
+ content: item
656
+ })) || [] };
657
+ case "view_inspections": return { messages: (await callMcpMethod(mcpServer, "tools/call", {
658
+ name: "list_inspections",
659
+ arguments: {}
660
+ }))?.content.map((item) => ({
661
+ role: "user",
662
+ content: item
663
+ })) || [] };
664
+ case "launch_chrome_devtools": {
665
+ const defaultUrl = `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`;
666
+ const url$1 = request.params.arguments?.url || defaultUrl;
667
+ try {
668
+ new URL(url$1);
669
+ } catch (error) {
670
+ return { messages: [{
671
+ role: "user",
672
+ content: {
673
+ type: "text",
674
+ text: `Error: Invalid URL format: "${url$1}". Please provide a valid URL (e.g., http://localhost:5173)`
675
+ }
676
+ }] };
677
+ }
678
+ try {
679
+ return { messages: [...((await callMcpMethod(mcpServer, "tools/call", {
680
+ name: "chrome_devtools",
681
+ arguments: {
682
+ useTool: "chrome_navigate_page",
683
+ hasDefinitions: ["chrome_navigate_page"],
684
+ chrome_navigate_page: { url: url$1 }
685
+ }
686
+ }))?.content || []).map((item) => ({
687
+ role: "user",
688
+ content: item
689
+ }))] };
690
+ } catch (error) {
691
+ return { messages: [{
692
+ role: "user",
693
+ content: {
694
+ type: "text",
695
+ text: `Error launching Chrome DevTools: ${error instanceof Error ? error.message : String(error)}`
696
+ }
697
+ }] };
698
+ }
699
+ }
700
+ case "refresh_chrome_state": try {
701
+ const result = await callMcpMethod(mcpServer, "tools/call", {
702
+ name: "chrome_devtools",
703
+ arguments: {
704
+ useTool: "chrome_list_network_requests",
705
+ hasDefinitions: ["chrome_list_network_requests"],
706
+ chrome_list_network_requests: {}
707
+ }
708
+ });
709
+ const reqIdMatches = (result?.content?.map((item) => item.text).join("\n") || "").matchAll(/reqid=(\d+)\s+(GET|POST|PUT|DELETE|PATCH)\s+([^\s]+)\s+\[([^\]]+)\]/g);
710
+ const requestOptions = Array.from(reqIdMatches).map((match) => {
711
+ const [, reqId, method, url$1, status] = match;
712
+ return ` ${reqId}: ${method} ${url$1.length > 60 ? url$1.substring(0, 57) + "..." : url$1} [${status}]`;
713
+ }).reverse().join("\n");
714
+ mcpServer.setRequestHandler(__modelcontextprotocol_sdk_types_js.ListPromptsRequestSchema, async (request$1) => {
715
+ return { prompts: [
716
+ { ...PROMPT_SCHEMAS.capture_element },
717
+ { ...PROMPT_SCHEMAS.view_inspections },
718
+ { ...PROMPT_SCHEMAS.launch_chrome_devtools },
719
+ { ...PROMPT_SCHEMAS.refresh_chrome_state },
720
+ {
721
+ ...PROMPT_SCHEMAS.get_network_requests,
722
+ arguments: [{
723
+ name: "reqid",
724
+ description: `The request ID to get details for. Available requests:\n\n${requestOptions || "No requests available"}`,
725
+ required: true
726
+ }]
727
+ }
728
+ ] };
729
+ });
730
+ await mcpServer.sendPromptListChanged();
731
+ return { messages: [...(result?.content || []).map((item) => ({
732
+ role: "user",
733
+ content: item
734
+ }))] };
735
+ } catch (error) {
736
+ return { messages: [{
737
+ role: "user",
738
+ content: {
739
+ type: "text",
740
+ text: `Error launching Chrome DevTools: ${error instanceof Error ? error.message : String(error)}`
741
+ }
742
+ }] };
743
+ }
744
+ case "get_network_requests":
745
+ const reqid = parseInt(request.params.arguments?.reqid);
746
+ try {
747
+ return { messages: [...((await callMcpMethod(mcpServer, "tools/call", {
748
+ name: "chrome_devtools",
749
+ arguments: {
750
+ useTool: "chrome_get_network_request",
751
+ hasDefinitions: ["chrome_get_network_request"],
752
+ chrome_get_network_request: { reqid }
753
+ }
754
+ }))?.content || []).map((item) => ({
755
+ role: "user",
756
+ content: item
757
+ }))] };
758
+ } catch (error) {
759
+ return { messages: [{
760
+ role: "user",
761
+ content: {
762
+ type: "text",
763
+ text: `Error launching Chrome DevTools: ${error instanceof Error ? error.message : String(error)}`
764
+ }
765
+ }] };
766
+ }
767
+ default: throw new Error(`Unknown promptId: ${promptName}`);
768
+ }
575
769
  });
576
770
  return mcpClientExecServer;
577
771
  }
@@ -581,11 +775,11 @@ async function createInspectorMcpServer() {
581
775
  /**
582
776
  * Setup MCP server endpoints in Vite dev server
583
777
  */
584
- async function setupMcpMiddleware(middlewares) {
778
+ async function setupMcpMiddleware(middlewares, serverContext) {
585
779
  const transports = {};
586
780
  middlewares.use(async (req, res, next) => {
587
781
  const url$1 = req.url || "";
588
- const mcpServer = await createInspectorMcpServer();
782
+ const mcpServer = await createInspectorMcpServer(serverContext);
589
783
  if (url$1.startsWith("/__mcp__") && !url$1.startsWith("/__mcp__/sse") && !url$1.startsWith("/__mcp__/messages")) {
590
784
  if (req.method === "POST") await handleStreamableHttpPost(req, res, mcpServer, transports);
591
785
  else if (req.method === "GET") await handleStreamableHttpGet(req, res, transports);
@@ -896,7 +1090,7 @@ function resolveMcpRemote(cwd = process.cwd()) {
896
1090
 
897
1091
  //#endregion
898
1092
  //#region src/middleware/acp-middleware.ts
899
- function setupAcpMiddleware(middlewares) {
1093
+ function setupAcpMiddleware(middlewares, serverContext) {
900
1094
  middlewares.use("/api/acp/chat", async (req, res) => {
901
1095
  if (req.method !== "POST") {
902
1096
  res.statusCode = 405;
@@ -908,11 +1102,6 @@ function setupAcpMiddleware(middlewares) {
908
1102
  const { messages, agent, envVars } = JSON.parse(body);
909
1103
  const cwd = process.cwd();
910
1104
  const mcpRemote = resolveMcpRemote(cwd);
911
- console.log("ACP Agent Command:", {
912
- agent,
913
- envVars,
914
- mcpRemote
915
- });
916
1105
  const provider = (0, __mcpc_tech_acp_ai_provider.createACPProvider)({
917
1106
  command: agent.command,
918
1107
  args: agent.args,
@@ -921,7 +1110,7 @@ function setupAcpMiddleware(middlewares) {
921
1110
  cwd,
922
1111
  mcpServers: [{
923
1112
  command: mcpRemote.command,
924
- args: [...mcpRemote.args, "http://localhost:5173/__mcp__/sse?puppetId=chrome"],
1113
+ args: [...mcpRemote.args, `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}/__mcp__/sse?puppetId=chrome`],
925
1114
  env: [],
926
1115
  name: "inspect"
927
1116
  }]
@@ -5451,13 +5640,13 @@ var require_lib = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@babel+
5451
5640
  super.checkParams(node, false, true);
5452
5641
  this.scope.exit();
5453
5642
  }
5454
- forwardNoArrowParamsConversionAt(node, parse$2) {
5643
+ forwardNoArrowParamsConversionAt(node, parse$3) {
5455
5644
  let result;
5456
5645
  if (this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node.start))) {
5457
5646
  this.state.noArrowParamsConversionAt.push(this.state.start);
5458
- result = parse$2();
5647
+ result = parse$3();
5459
5648
  this.state.noArrowParamsConversionAt.pop();
5460
- } else result = parse$2();
5649
+ } else result = parse$3();
5461
5650
  return result;
5462
5651
  }
5463
5652
  parseParenItem(node, startLoc) {
@@ -14504,7 +14693,7 @@ var require_lib = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@babel+
14504
14693
  return result;
14505
14694
  }
14506
14695
  };
14507
- function parse$1(input, options) {
14696
+ function parse$2(input, options) {
14508
14697
  var _options;
14509
14698
  if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
14510
14699
  options = Object.assign({}, options);
@@ -14562,19 +14751,19 @@ var require_lib = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/@babel+
14562
14751
  }
14563
14752
  return cls;
14564
14753
  }
14565
- exports.parse = parse$1;
14754
+ exports.parse = parse$2;
14566
14755
  }) });
14567
14756
 
14568
14757
  //#endregion
14569
14758
  //#region src/compiler/jsx-transform.ts
14570
14759
  var import_lib = require_lib();
14571
14760
  const traverse = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("@babel/traverse").default;
14572
- function normalizePath(id) {
14761
+ function normalizePath$1(id) {
14573
14762
  return id.split(node_path.default.sep).join("/");
14574
14763
  }
14575
- const DATA_SOURCE_ATTR = "data-source";
14764
+ const DATA_SOURCE_ATTR$1 = "data-source";
14576
14765
  async function transformJSX({ code: code$1, id }) {
14577
- const relativePath = normalizePath(node_path.default.relative(process.cwd(), id));
14766
+ const relativePath = normalizePath$1(node_path.default.relative(process.cwd(), id));
14578
14767
  const ast = (0, import_lib.parse)(code$1, {
14579
14768
  sourceType: "module",
14580
14769
  plugins: [
@@ -14587,9 +14776,9 @@ async function transformJSX({ code: code$1, id }) {
14587
14776
  });
14588
14777
  const s = new MagicString(code$1);
14589
14778
  let hasModifications = false;
14590
- traverse(ast, { JSXOpeningElement(path$4) {
14591
- const node = path$4.node;
14592
- if (node.attributes.some((attr) => attr.type === "JSXAttribute" && attr.name.name === DATA_SOURCE_ATTR)) return;
14779
+ traverse(ast, { JSXOpeningElement(path$5) {
14780
+ const node = path$5.node;
14781
+ if (node.attributes.some((attr) => attr.type === "JSXAttribute" && attr.name.name === DATA_SOURCE_ATTR$1)) return;
14593
14782
  const { line, column } = node.loc.start;
14594
14783
  const sourceValue = `${relativePath}:${line}:${column}`;
14595
14784
  let insertPos;
@@ -14598,7 +14787,7 @@ async function transformJSX({ code: code$1, id }) {
14598
14787
  const tagName = node.name.name || "";
14599
14788
  insertPos = node.start + tagName.length + 1;
14600
14789
  }
14601
- s.prependLeft(insertPos, ` ${DATA_SOURCE_ATTR}="${sourceValue}"`);
14790
+ s.prependLeft(insertPos, ` ${DATA_SOURCE_ATTR$1}="${sourceValue}"`);
14602
14791
  hasModifications = true;
14603
14792
  } });
14604
14793
  if (!hasModifications) return null;
@@ -14608,6 +14797,42 @@ async function transformJSX({ code: code$1, id }) {
14608
14797
  };
14609
14798
  }
14610
14799
 
14800
+ //#endregion
14801
+ //#region src/compiler/vue-transform.ts
14802
+ function normalizePath(id) {
14803
+ return id.split(node_path.default.sep).join("/");
14804
+ }
14805
+ const DATA_SOURCE_ATTR = "data-source";
14806
+ async function compileVue({ code: code$1, id }) {
14807
+ const relativePath = normalizePath(node_path.default.relative(process.cwd(), id));
14808
+ const { descriptor } = (0, __vue_compiler_sfc.parse)(code$1, {
14809
+ filename: id,
14810
+ sourceMap: true
14811
+ });
14812
+ if (!descriptor.template || !descriptor.template.ast) return null;
14813
+ const s = new MagicString(code$1);
14814
+ let hasModifications = false;
14815
+ function traverse$1(node) {
14816
+ if (node.type === 1) {
14817
+ if (!node.props.some((prop) => prop.type === 6 && prop.name === DATA_SOURCE_ATTR)) {
14818
+ const { line, column } = node.loc.start;
14819
+ const sourceValue = `${relativePath}:${line}:${column}`;
14820
+ const tagName = node.tag;
14821
+ const insertPos = node.loc.start.offset + 1 + tagName.length;
14822
+ s.prependLeft(insertPos, ` ${DATA_SOURCE_ATTR}="${sourceValue}"`);
14823
+ hasModifications = true;
14824
+ }
14825
+ }
14826
+ if (node.children) node.children.forEach(traverse$1);
14827
+ }
14828
+ traverse$1(descriptor.template.ast);
14829
+ if (!hasModifications) return null;
14830
+ return {
14831
+ code: s.toString(),
14832
+ map: s.generateMap({ hires: true })
14833
+ };
14834
+ }
14835
+
14611
14836
  //#endregion
14612
14837
  //#region src/core.ts
14613
14838
  const unplugin$1 = (0, unplugin.createUnplugin)((options = {}) => {
@@ -14618,9 +14843,8 @@ const unplugin$1 = (0, unplugin.createUnplugin)((options = {}) => {
14618
14843
  name: "unplugin-dev-inspector",
14619
14844
  enforce: "pre",
14620
14845
  async transform(code$1, id) {
14621
- if (!id.match(/\.(jsx|tsx)$/)) return null;
14622
14846
  if (id.includes("node_modules")) return null;
14623
- try {
14847
+ if (id.match(/\.(jsx|tsx)$/)) try {
14624
14848
  return await transformJSX({
14625
14849
  code: code$1,
14626
14850
  id
@@ -14629,6 +14853,16 @@ const unplugin$1 = (0, unplugin.createUnplugin)((options = {}) => {
14629
14853
  console.error(`[dev-inspector] Failed to transform ${id}:`, error);
14630
14854
  return null;
14631
14855
  }
14856
+ if (id.match(/\.vue$/)) try {
14857
+ return await compileVue({
14858
+ code: code$1,
14859
+ id
14860
+ });
14861
+ } catch (error) {
14862
+ console.error(`[dev-inspector] Failed to transform ${id}:`, error);
14863
+ return null;
14864
+ }
14865
+ return null;
14632
14866
  },
14633
14867
  vite: {
14634
14868
  apply: "serve",
@@ -14638,8 +14872,15 @@ const unplugin$1 = (0, unplugin.createUnplugin)((options = {}) => {
14638
14872
  async configureServer(server) {
14639
14873
  console.log("\n✨ Dev Inspector Plugin enabled!");
14640
14874
  if (enableMcp) {
14641
- await setupMcpMiddleware(server.middlewares);
14642
- setupAcpMiddleware(server.middlewares);
14875
+ const host = server.config.server.host;
14876
+ const serverContext = {
14877
+ host: typeof host === "string" ? host : host === true ? "0.0.0.0" : "localhost",
14878
+ port: server.config.server.port || 5173
14879
+ };
14880
+ const displayHost = serverContext.host === "0.0.0.0" ? "localhost" : serverContext.host;
14881
+ console.log(`šŸ“” MCP: http://${displayHost}:${serverContext.port}/__mcp__/sse?puppetId=chrome\n`);
14882
+ await setupMcpMiddleware(server.middlewares, serverContext);
14883
+ setupAcpMiddleware(server.middlewares, serverContext);
14643
14884
  }
14644
14885
  setupInspectorMiddleware(server.middlewares);
14645
14886
  },