@mcpc-tech/unplugin-dev-inspector-mcp 0.1.5 → 0.1.7

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/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as getPublicBaseUrl, c as isEnvTruthy, i as setupMcpMiddleware, n as setupAcpMiddleware, o as init_helpers, r as setupInspectorMiddleware, t as updateMcpConfigs } from "./config-updater.js";
2
+ import { i as setupMcpMiddleware, l as isEnvTruthy, n as setupAcpMiddleware, o as getPublicBaseUrl, r as setupInspectorMiddleware, s as init_helpers, t as updateMcpConfigs } from "./config-updater.js";
3
3
  import http from "node:http";
4
4
  import { execSync } from "child_process";
5
5
  import { existsSync, readFileSync, writeFileSync } from "fs";
@@ -86434,6 +86434,12 @@ const PROMPT_SCHEMAS = {
86434
86434
  title: "Get Console Messages",
86435
86435
  description: "List console messages or get details of a specific one. Always refreshes the list first.",
86436
86436
  arguments: []
86437
+ },
86438
+ get_stdio_messages: {
86439
+ name: "get_stdio_messages",
86440
+ title: "Get Stdio Messages",
86441
+ description: "List stdio (stdout/stderr) messages from the server process. Always refreshes the list first.",
86442
+ arguments: []
86437
86443
  }
86438
86444
  };
86439
86445
 
@@ -86568,10 +86574,13 @@ var init_helpers = require_chunk.__esmMin((() => {}));
86568
86574
  //#region src/utils/log-storage.ts
86569
86575
  const logs = [];
86570
86576
  const networkRequests = [];
86577
+ const stdioLogs = [];
86571
86578
  let nextLogId = 1;
86572
86579
  let nextRequestId = 1;
86580
+ let nextStdioId = 1;
86573
86581
  const MAX_LOGS = 500;
86574
86582
  const MAX_REQUESTS = 500;
86583
+ const MAX_STDIO_LOGS = 500;
86575
86584
  function addLog(type, args) {
86576
86585
  const log = {
86577
86586
  id: nextLogId++,
@@ -86593,18 +86602,35 @@ function addNetworkRequest(request) {
86593
86602
  while (networkRequests.length > MAX_REQUESTS) networkRequests.shift();
86594
86603
  return req;
86595
86604
  }
86605
+ function addStdioLog(stream$2, data$1) {
86606
+ const log = {
86607
+ id: nextStdioId++,
86608
+ stream: stream$2,
86609
+ data: data$1,
86610
+ timestamp: Date.now()
86611
+ };
86612
+ stdioLogs.push(log);
86613
+ while (stdioLogs.length > MAX_STDIO_LOGS) stdioLogs.shift();
86614
+ return log;
86615
+ }
86596
86616
  function getLogs() {
86597
86617
  return [...logs];
86598
86618
  }
86599
86619
  function getNetworkRequests() {
86600
86620
  return [...networkRequests];
86601
86621
  }
86622
+ function getStdioLogs() {
86623
+ return [...stdioLogs];
86624
+ }
86602
86625
  function getLogById(id) {
86603
86626
  return logs.find((l) => l.id === id);
86604
86627
  }
86605
86628
  function getRequestById(id) {
86606
86629
  return networkRequests.find((r) => r.id === id);
86607
86630
  }
86631
+ function getStdioById(id) {
86632
+ return stdioLogs.find((s) => s.id === id);
86633
+ }
86608
86634
 
86609
86635
  //#endregion
86610
86636
  //#region src/mcp.ts
@@ -86717,6 +86743,7 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
86717
86743
  return { prompts: [
86718
86744
  { ...PROMPT_SCHEMAS.capture_element },
86719
86745
  { ...PROMPT_SCHEMAS.view_inspections },
86746
+ { ...PROMPT_SCHEMAS.get_stdio_messages },
86720
86747
  ...!chromeDisabled ? [
86721
86748
  {
86722
86749
  ...PROMPT_SCHEMAS.launch_chrome_devtools,
@@ -86998,6 +87025,75 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
86998
87025
  }] };
86999
87026
  }
87000
87027
  }
87028
+ case "get_stdio_messages": {
87029
+ const stdioLogs$1 = getStdioLogs();
87030
+ const stdioIdStr = request.params.arguments?.stdioid;
87031
+ const formattedMessages = stdioLogs$1.map((log) => {
87032
+ const truncatedData = log.data.length > 1e3 ? log.data.substring(0, 997) + "..." : log.data;
87033
+ return `stdioid=${log.id} [${log.stream}] ${truncatedData}`;
87034
+ }).reverse();
87035
+ if (stdioIdStr) {
87036
+ const stdioId = parseInt(stdioIdStr);
87037
+ if (isNaN(stdioId)) return { messages: [{
87038
+ role: "user",
87039
+ content: {
87040
+ type: "text",
87041
+ text: "Invalid stdio ID"
87042
+ }
87043
+ }] };
87044
+ const log = getStdioById(stdioId);
87045
+ if (log) return { messages: [{
87046
+ role: "user",
87047
+ content: {
87048
+ type: "text",
87049
+ text: JSON.stringify(log, null, 2)
87050
+ }
87051
+ }] };
87052
+ return { messages: [{
87053
+ role: "user",
87054
+ content: {
87055
+ type: "text",
87056
+ text: "Stdio message not found"
87057
+ }
87058
+ }] };
87059
+ }
87060
+ mcpServer.setRequestHandler(_modelcontextprotocol_sdk_types_js.ListPromptsRequestSchema, async (_request) => {
87061
+ const defaultUrl = process.env.DEV_INSPECTOR_PUBLIC_BASE_URL ? stripTrailingSlash(process.env.DEV_INSPECTOR_PUBLIC_BASE_URL) : `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`;
87062
+ return { prompts: [
87063
+ { ...PROMPT_SCHEMAS.capture_element },
87064
+ { ...PROMPT_SCHEMAS.view_inspections },
87065
+ {
87066
+ ...PROMPT_SCHEMAS.get_stdio_messages,
87067
+ arguments: [{
87068
+ name: "stdioid",
87069
+ description: `Optional. The stdio message ID to get details for.\n\nAvailable messages:\n${formattedMessages.join("\n") || "No stdio messages"}`,
87070
+ required: false
87071
+ }]
87072
+ },
87073
+ ...!chromeDisabled ? [
87074
+ {
87075
+ ...PROMPT_SCHEMAS.launch_chrome_devtools,
87076
+ description: `Launch Chrome DevTools and navigate to the dev server. Default URL: ${defaultUrl}`,
87077
+ arguments: [{
87078
+ name: "url",
87079
+ description: `URL to navigate to. Default: ${defaultUrl}`,
87080
+ required: false
87081
+ }]
87082
+ },
87083
+ { ...PROMPT_SCHEMAS.get_network_requests },
87084
+ { ...PROMPT_SCHEMAS.get_console_messages }
87085
+ ] : []
87086
+ ] };
87087
+ });
87088
+ await mcpServer.sendPromptListChanged();
87089
+ return { messages: [{
87090
+ role: "user",
87091
+ content: {
87092
+ type: "text",
87093
+ text: `Stdio Messages (Terminal Output):\n${formattedMessages.join("\n") || "No stdio messages"}`
87094
+ }
87095
+ }] };
87096
+ }
87001
87097
  default: throw new Error(`Unknown promptId: ${promptName}`);
87002
87098
  }
87003
87099
  });
@@ -87508,6 +87604,32 @@ function setupInspectorMiddleware(middlewares, config) {
87508
87604
  }
87509
87605
  return;
87510
87606
  }
87607
+ if (req.url === "/__inspector__/stdio" && req.method === "GET") {
87608
+ const stdioLogs$1 = getStdioLogs();
87609
+ res.statusCode = 200;
87610
+ res.setHeader("Content-Type", "application/json");
87611
+ res.end(JSON.stringify(stdioLogs$1));
87612
+ return;
87613
+ }
87614
+ const stdioDetailsMatch = req.url?.match(/^\/__inspector__\/stdio\/(\d+)$/);
87615
+ if (stdioDetailsMatch && req.method === "GET") {
87616
+ const stdioid = parseInt(stdioDetailsMatch[1]);
87617
+ if (!Number.isInteger(stdioid) || stdioid <= 0) {
87618
+ res.statusCode = 400;
87619
+ res.end("Invalid stdio ID");
87620
+ return;
87621
+ }
87622
+ const stdioLog = getStdioById(stdioid);
87623
+ if (stdioLog) {
87624
+ res.statusCode = 200;
87625
+ res.setHeader("Content-Type", "application/json");
87626
+ res.end(JSON.stringify(stdioLog));
87627
+ } else {
87628
+ res.statusCode = 404;
87629
+ res.end("Stdio log not found");
87630
+ }
87631
+ return;
87632
+ }
87511
87633
  next$1();
87512
87634
  });
87513
87635
  }
@@ -89196,6 +89318,12 @@ async function updateMcpConfigs(root$1, sseUrl, options, logger) {
89196
89318
  }
89197
89319
 
89198
89320
  //#endregion
89321
+ Object.defineProperty(exports, 'addStdioLog', {
89322
+ enumerable: true,
89323
+ get: function () {
89324
+ return addStdioLog;
89325
+ }
89326
+ });
89199
89327
  Object.defineProperty(exports, 'getPublicBaseUrl', {
89200
89328
  enumerable: true,
89201
89329
  get: function () {
@@ -86469,6 +86469,12 @@ const PROMPT_SCHEMAS = {
86469
86469
  title: "Get Console Messages",
86470
86470
  description: "List console messages or get details of a specific one. Always refreshes the list first.",
86471
86471
  arguments: []
86472
+ },
86473
+ get_stdio_messages: {
86474
+ name: "get_stdio_messages",
86475
+ title: "Get Stdio Messages",
86476
+ description: "List stdio (stdout/stderr) messages from the server process. Always refreshes the list first.",
86477
+ arguments: []
86472
86478
  }
86473
86479
  };
86474
86480
 
@@ -86603,10 +86609,13 @@ var init_helpers = __esmMin((() => {}));
86603
86609
  //#region src/utils/log-storage.ts
86604
86610
  const logs = [];
86605
86611
  const networkRequests = [];
86612
+ const stdioLogs = [];
86606
86613
  let nextLogId = 1;
86607
86614
  let nextRequestId = 1;
86615
+ let nextStdioId = 1;
86608
86616
  const MAX_LOGS = 500;
86609
86617
  const MAX_REQUESTS = 500;
86618
+ const MAX_STDIO_LOGS = 500;
86610
86619
  function addLog(type, args) {
86611
86620
  const log = {
86612
86621
  id: nextLogId++,
@@ -86628,18 +86637,35 @@ function addNetworkRequest(request) {
86628
86637
  while (networkRequests.length > MAX_REQUESTS) networkRequests.shift();
86629
86638
  return req;
86630
86639
  }
86640
+ function addStdioLog(stream$1, data$1) {
86641
+ const log = {
86642
+ id: nextStdioId++,
86643
+ stream: stream$1,
86644
+ data: data$1,
86645
+ timestamp: Date.now()
86646
+ };
86647
+ stdioLogs.push(log);
86648
+ while (stdioLogs.length > MAX_STDIO_LOGS) stdioLogs.shift();
86649
+ return log;
86650
+ }
86631
86651
  function getLogs() {
86632
86652
  return [...logs];
86633
86653
  }
86634
86654
  function getNetworkRequests() {
86635
86655
  return [...networkRequests];
86636
86656
  }
86657
+ function getStdioLogs() {
86658
+ return [...stdioLogs];
86659
+ }
86637
86660
  function getLogById(id) {
86638
86661
  return logs.find((l) => l.id === id);
86639
86662
  }
86640
86663
  function getRequestById(id) {
86641
86664
  return networkRequests.find((r) => r.id === id);
86642
86665
  }
86666
+ function getStdioById(id) {
86667
+ return stdioLogs.find((s) => s.id === id);
86668
+ }
86643
86669
 
86644
86670
  //#endregion
86645
86671
  //#region src/mcp.ts
@@ -86752,6 +86778,7 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
86752
86778
  return { prompts: [
86753
86779
  { ...PROMPT_SCHEMAS.capture_element },
86754
86780
  { ...PROMPT_SCHEMAS.view_inspections },
86781
+ { ...PROMPT_SCHEMAS.get_stdio_messages },
86755
86782
  ...!chromeDisabled ? [
86756
86783
  {
86757
86784
  ...PROMPT_SCHEMAS.launch_chrome_devtools,
@@ -87033,6 +87060,75 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
87033
87060
  }] };
87034
87061
  }
87035
87062
  }
87063
+ case "get_stdio_messages": {
87064
+ const stdioLogs$1 = getStdioLogs();
87065
+ const stdioIdStr = request.params.arguments?.stdioid;
87066
+ const formattedMessages = stdioLogs$1.map((log) => {
87067
+ const truncatedData = log.data.length > 1e3 ? log.data.substring(0, 997) + "..." : log.data;
87068
+ return `stdioid=${log.id} [${log.stream}] ${truncatedData}`;
87069
+ }).reverse();
87070
+ if (stdioIdStr) {
87071
+ const stdioId = parseInt(stdioIdStr);
87072
+ if (isNaN(stdioId)) return { messages: [{
87073
+ role: "user",
87074
+ content: {
87075
+ type: "text",
87076
+ text: "Invalid stdio ID"
87077
+ }
87078
+ }] };
87079
+ const log = getStdioById(stdioId);
87080
+ if (log) return { messages: [{
87081
+ role: "user",
87082
+ content: {
87083
+ type: "text",
87084
+ text: JSON.stringify(log, null, 2)
87085
+ }
87086
+ }] };
87087
+ return { messages: [{
87088
+ role: "user",
87089
+ content: {
87090
+ type: "text",
87091
+ text: "Stdio message not found"
87092
+ }
87093
+ }] };
87094
+ }
87095
+ mcpServer.setRequestHandler(ListPromptsRequestSchema, async (_request) => {
87096
+ const defaultUrl = process.env.DEV_INSPECTOR_PUBLIC_BASE_URL ? stripTrailingSlash(process.env.DEV_INSPECTOR_PUBLIC_BASE_URL) : `http://${serverContext?.host || "localhost"}:${serverContext?.port || 5173}`;
87097
+ return { prompts: [
87098
+ { ...PROMPT_SCHEMAS.capture_element },
87099
+ { ...PROMPT_SCHEMAS.view_inspections },
87100
+ {
87101
+ ...PROMPT_SCHEMAS.get_stdio_messages,
87102
+ arguments: [{
87103
+ name: "stdioid",
87104
+ description: `Optional. The stdio message ID to get details for.\n\nAvailable messages:\n${formattedMessages.join("\n") || "No stdio messages"}`,
87105
+ required: false
87106
+ }]
87107
+ },
87108
+ ...!chromeDisabled ? [
87109
+ {
87110
+ ...PROMPT_SCHEMAS.launch_chrome_devtools,
87111
+ description: `Launch Chrome DevTools and navigate to the dev server. Default URL: ${defaultUrl}`,
87112
+ arguments: [{
87113
+ name: "url",
87114
+ description: `URL to navigate to. Default: ${defaultUrl}`,
87115
+ required: false
87116
+ }]
87117
+ },
87118
+ { ...PROMPT_SCHEMAS.get_network_requests },
87119
+ { ...PROMPT_SCHEMAS.get_console_messages }
87120
+ ] : []
87121
+ ] };
87122
+ });
87123
+ await mcpServer.sendPromptListChanged();
87124
+ return { messages: [{
87125
+ role: "user",
87126
+ content: {
87127
+ type: "text",
87128
+ text: `Stdio Messages (Terminal Output):\n${formattedMessages.join("\n") || "No stdio messages"}`
87129
+ }
87130
+ }] };
87131
+ }
87036
87132
  default: throw new Error(`Unknown promptId: ${promptName}`);
87037
87133
  }
87038
87134
  });
@@ -87543,6 +87639,32 @@ function setupInspectorMiddleware(middlewares, config) {
87543
87639
  }
87544
87640
  return;
87545
87641
  }
87642
+ if (req.url === "/__inspector__/stdio" && req.method === "GET") {
87643
+ const stdioLogs$1 = getStdioLogs();
87644
+ res.statusCode = 200;
87645
+ res.setHeader("Content-Type", "application/json");
87646
+ res.end(JSON.stringify(stdioLogs$1));
87647
+ return;
87648
+ }
87649
+ const stdioDetailsMatch = req.url?.match(/^\/__inspector__\/stdio\/(\d+)$/);
87650
+ if (stdioDetailsMatch && req.method === "GET") {
87651
+ const stdioid = parseInt(stdioDetailsMatch[1]);
87652
+ if (!Number.isInteger(stdioid) || stdioid <= 0) {
87653
+ res.statusCode = 400;
87654
+ res.end("Invalid stdio ID");
87655
+ return;
87656
+ }
87657
+ const stdioLog = getStdioById(stdioid);
87658
+ if (stdioLog) {
87659
+ res.statusCode = 200;
87660
+ res.setHeader("Content-Type", "application/json");
87661
+ res.end(JSON.stringify(stdioLog));
87662
+ } else {
87663
+ res.statusCode = 404;
87664
+ res.end("Stdio log not found");
87665
+ }
87666
+ return;
87667
+ }
87546
87668
  next$1();
87547
87669
  });
87548
87670
  }
@@ -89231,4 +89353,4 @@ async function updateMcpConfigs(root$1, sseUrl, options, logger) {
89231
89353
  }
89232
89354
 
89233
89355
  //#endregion
89234
- export { getPublicBaseUrl as a, isEnvTruthy as c, __exportAll as d, __toCommonJS as f, setupMcpMiddleware as i, stripTrailingSlash as l, setupAcpMiddleware as n, init_helpers as o, setupInspectorMiddleware as r, isChromeDisabled as s, updateMcpConfigs as t, __esmMin as u };
89356
+ export { addStdioLog as a, isChromeDisabled as c, __esmMin as d, __exportAll as f, setupMcpMiddleware as i, isEnvTruthy as l, setupAcpMiddleware as n, getPublicBaseUrl as o, __toCommonJS as p, setupInspectorMiddleware as r, init_helpers as s, updateMcpConfigs as t, stripTrailingSlash as u };
package/dist/index.cjs CHANGED
@@ -102,8 +102,37 @@ var init_browser_launcher = require_chunk.__esmMin((() => {
102
102
  }));
103
103
 
104
104
  //#endregion
105
- //#region src/utils/create-plugin.ts
105
+ //#region src/utils/stdio-interceptor.ts
106
106
  init_browser_launcher();
107
+ let originalStdoutWrite = null;
108
+ let originalStderrWrite = null;
109
+ let isIntercepting = false;
110
+ function toText(chunk) {
111
+ return typeof chunk === "string" ? chunk : String(chunk);
112
+ }
113
+ function wrapWrite(stream, original) {
114
+ return ((chunk, ...args) => {
115
+ try {
116
+ require_config_updater.addStdioLog(stream, toText(chunk));
117
+ } catch {}
118
+ return original(chunk, ...args);
119
+ });
120
+ }
121
+ /**
122
+ * Initialize stdio interception
123
+ * Hooks into process.stdout.write and process.stderr.write
124
+ */
125
+ function initStdioInterceptor() {
126
+ if (isIntercepting) return;
127
+ originalStdoutWrite = process.stdout.write.bind(process.stdout);
128
+ originalStderrWrite = process.stderr.write.bind(process.stderr);
129
+ process.stdout.write = wrapWrite("stdout", originalStdoutWrite);
130
+ process.stderr.write = wrapWrite("stderr", originalStderrWrite);
131
+ isIntercepting = true;
132
+ }
133
+
134
+ //#endregion
135
+ //#region src/utils/create-plugin.ts
107
136
  require_config_updater.init_helpers();
108
137
  const createDevInspectorPlugin = (name, transformFactory) => {
109
138
  return (0, unplugin.createUnplugin)((options = {}) => {
@@ -273,6 +302,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
273
302
  });
274
303
  const baseUrl = `${publicBase}/__mcp__/sse`;
275
304
  console.log(`[dev-inspector] 📡 MCP: ${baseUrl}\n`);
305
+ initStdioInterceptor();
276
306
  await require_config_updater.setupMcpMiddleware(server.middlewares, serverContext);
277
307
  require_config_updater.setupAcpMiddleware(server.middlewares, serverContext, {
278
308
  acpMode: options.acpMode,
@@ -338,6 +368,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
338
368
  });
339
369
  const baseUrl = `${publicBase}/__mcp__/sse`;
340
370
  console.log(`[dev-inspector] 📡 MCP (Standalone): ${baseUrl}\n`);
371
+ initStdioInterceptor();
341
372
  require_config_updater.setupMcpMiddleware(server, serverContext);
342
373
  require_config_updater.setupAcpMiddleware(server, serverContext, {
343
374
  acpMode: options.acpMode,
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as unplugin1 from "unplugin";
1
+ import * as unplugin0 from "unplugin";
2
2
 
3
3
  //#region src/utils/config-updater.d.ts
4
4
  type EditorId = "cursor" | "vscode" | "windsurf" | "claude-code" | "antigravity";
@@ -183,10 +183,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
183
183
  }
184
184
  //#endregion
185
185
  //#region src/core.d.ts
186
- declare const unplugin: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
186
+ declare const unplugin: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
187
187
  //#endregion
188
188
  //#region src/core-external.d.ts
189
- declare const unpluginExternal: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
189
+ declare const unpluginExternal: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
190
190
  //#endregion
191
191
  //#region src/turbopack.d.ts
192
192
  interface TurbopackDevInspectorOptions extends DevInspectorOptions {
@@ -211,7 +211,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
211
211
  declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
212
212
  //#endregion
213
213
  //#region src/index.d.ts
214
- declare const external: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
214
+ declare const external: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
215
215
  declare module "virtual:dev-inspector-mcp" {}
216
216
  //#endregion
217
217
  export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as getPublicBaseUrl, d as __exportAll, f as __toCommonJS, i as setupMcpMiddleware, l as stripTrailingSlash, n as setupAcpMiddleware, o as init_helpers, r as setupInspectorMiddleware, s as isChromeDisabled, t as updateMcpConfigs, u as __esmMin } from "./config-updater.js";
1
+ import { a as addStdioLog, c as isChromeDisabled, d as __esmMin, f as __exportAll, i as setupMcpMiddleware, n as setupAcpMiddleware, o as getPublicBaseUrl, p as __toCommonJS, r as setupInspectorMiddleware, s as init_helpers, t as updateMcpConfigs, u as stripTrailingSlash } from "./config-updater.js";
2
2
  import { createRequire } from "node:module";
3
3
  import path from "node:path";
4
4
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
@@ -98,8 +98,37 @@ var init_browser_launcher = __esmMin((() => {
98
98
  }));
99
99
 
100
100
  //#endregion
101
- //#region src/utils/create-plugin.ts
101
+ //#region src/utils/stdio-interceptor.ts
102
102
  init_browser_launcher();
103
+ let originalStdoutWrite = null;
104
+ let originalStderrWrite = null;
105
+ let isIntercepting = false;
106
+ function toText(chunk) {
107
+ return typeof chunk === "string" ? chunk : String(chunk);
108
+ }
109
+ function wrapWrite(stream, original) {
110
+ return ((chunk, ...args) => {
111
+ try {
112
+ addStdioLog(stream, toText(chunk));
113
+ } catch {}
114
+ return original(chunk, ...args);
115
+ });
116
+ }
117
+ /**
118
+ * Initialize stdio interception
119
+ * Hooks into process.stdout.write and process.stderr.write
120
+ */
121
+ function initStdioInterceptor() {
122
+ if (isIntercepting) return;
123
+ originalStdoutWrite = process.stdout.write.bind(process.stdout);
124
+ originalStderrWrite = process.stderr.write.bind(process.stderr);
125
+ process.stdout.write = wrapWrite("stdout", originalStdoutWrite);
126
+ process.stderr.write = wrapWrite("stderr", originalStderrWrite);
127
+ isIntercepting = true;
128
+ }
129
+
130
+ //#endregion
131
+ //#region src/utils/create-plugin.ts
103
132
  init_helpers();
104
133
  const createDevInspectorPlugin = (name, transformFactory) => {
105
134
  return createUnplugin((options = {}) => {
@@ -269,6 +298,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
269
298
  });
270
299
  const baseUrl = `${publicBase}/__mcp__/sse`;
271
300
  console.log(`[dev-inspector] 📡 MCP: ${baseUrl}\n`);
301
+ initStdioInterceptor();
272
302
  await setupMcpMiddleware(server.middlewares, serverContext);
273
303
  setupAcpMiddleware(server.middlewares, serverContext, {
274
304
  acpMode: options.acpMode,
@@ -334,6 +364,7 @@ if (typeof window !== 'undefined' && typeof document !== 'undefined') {
334
364
  });
335
365
  const baseUrl = `${publicBase}/__mcp__/sse`;
336
366
  console.log(`[dev-inspector] 📡 MCP (Standalone): ${baseUrl}\n`);
367
+ initStdioInterceptor();
337
368
  setupMcpMiddleware(server, serverContext);
338
369
  setupAcpMiddleware(server, serverContext, {
339
370
  acpMode: options.acpMode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/unplugin-dev-inspector-mcp",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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",