@mcpc-tech/unplugin-dev-inspector-mcp 0.1.4 → 0.1.6
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/README.md +12 -12
- package/client/dist/inspector.css +53 -0
- package/client/dist/inspector.js +191 -131
- package/dist/cli.js +1 -1
- package/dist/config-updater.cjs +130 -1
- package/dist/config-updater.js +125 -2
- package/dist/index.cjs +32 -1
- package/dist/index.js +33 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
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";
|
package/dist/config-updater.cjs
CHANGED
|
@@ -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
|
|
|
@@ -86553,7 +86559,8 @@ function isEnvTruthy(value) {
|
|
|
86553
86559
|
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
86554
86560
|
}
|
|
86555
86561
|
function isChromeDisabled(disableOption) {
|
|
86556
|
-
|
|
86562
|
+
if (isEnvTruthy(process.env.DEV_INSPECTOR_DISABLE_CHROME)) return true;
|
|
86563
|
+
return disableOption ?? true;
|
|
86557
86564
|
}
|
|
86558
86565
|
function getPublicBaseUrl(options) {
|
|
86559
86566
|
const fromEnv = process.env.DEV_INSPECTOR_PUBLIC_BASE_URL;
|
|
@@ -86567,10 +86574,13 @@ var init_helpers = require_chunk.__esmMin((() => {}));
|
|
|
86567
86574
|
//#region src/utils/log-storage.ts
|
|
86568
86575
|
const logs = [];
|
|
86569
86576
|
const networkRequests = [];
|
|
86577
|
+
const stdioLogs = [];
|
|
86570
86578
|
let nextLogId = 1;
|
|
86571
86579
|
let nextRequestId = 1;
|
|
86580
|
+
let nextStdioId = 1;
|
|
86572
86581
|
const MAX_LOGS = 500;
|
|
86573
86582
|
const MAX_REQUESTS = 500;
|
|
86583
|
+
const MAX_STDIO_LOGS = 500;
|
|
86574
86584
|
function addLog(type, args) {
|
|
86575
86585
|
const log = {
|
|
86576
86586
|
id: nextLogId++,
|
|
@@ -86592,18 +86602,35 @@ function addNetworkRequest(request) {
|
|
|
86592
86602
|
while (networkRequests.length > MAX_REQUESTS) networkRequests.shift();
|
|
86593
86603
|
return req;
|
|
86594
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
|
+
}
|
|
86595
86616
|
function getLogs() {
|
|
86596
86617
|
return [...logs];
|
|
86597
86618
|
}
|
|
86598
86619
|
function getNetworkRequests() {
|
|
86599
86620
|
return [...networkRequests];
|
|
86600
86621
|
}
|
|
86622
|
+
function getStdioLogs() {
|
|
86623
|
+
return [...stdioLogs];
|
|
86624
|
+
}
|
|
86601
86625
|
function getLogById(id) {
|
|
86602
86626
|
return logs.find((l) => l.id === id);
|
|
86603
86627
|
}
|
|
86604
86628
|
function getRequestById(id) {
|
|
86605
86629
|
return networkRequests.find((r) => r.id === id);
|
|
86606
86630
|
}
|
|
86631
|
+
function getStdioById(id) {
|
|
86632
|
+
return stdioLogs.find((s) => s.id === id);
|
|
86633
|
+
}
|
|
86607
86634
|
|
|
86608
86635
|
//#endregion
|
|
86609
86636
|
//#region src/mcp.ts
|
|
@@ -86716,6 +86743,7 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
|
|
|
86716
86743
|
return { prompts: [
|
|
86717
86744
|
{ ...PROMPT_SCHEMAS.capture_element },
|
|
86718
86745
|
{ ...PROMPT_SCHEMAS.view_inspections },
|
|
86746
|
+
{ ...PROMPT_SCHEMAS.get_stdio_messages },
|
|
86719
86747
|
...!chromeDisabled ? [
|
|
86720
86748
|
{
|
|
86721
86749
|
...PROMPT_SCHEMAS.launch_chrome_devtools,
|
|
@@ -86997,6 +87025,75 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
|
|
|
86997
87025
|
}] };
|
|
86998
87026
|
}
|
|
86999
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
|
+
}
|
|
87000
87097
|
default: throw new Error(`Unknown promptId: ${promptName}`);
|
|
87001
87098
|
}
|
|
87002
87099
|
});
|
|
@@ -87507,6 +87604,32 @@ function setupInspectorMiddleware(middlewares, config) {
|
|
|
87507
87604
|
}
|
|
87508
87605
|
return;
|
|
87509
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
|
+
}
|
|
87510
87633
|
next$1();
|
|
87511
87634
|
});
|
|
87512
87635
|
}
|
|
@@ -89195,6 +89318,12 @@ async function updateMcpConfigs(root$1, sseUrl, options, logger) {
|
|
|
89195
89318
|
}
|
|
89196
89319
|
|
|
89197
89320
|
//#endregion
|
|
89321
|
+
Object.defineProperty(exports, 'addStdioLog', {
|
|
89322
|
+
enumerable: true,
|
|
89323
|
+
get: function () {
|
|
89324
|
+
return addStdioLog;
|
|
89325
|
+
}
|
|
89326
|
+
});
|
|
89198
89327
|
Object.defineProperty(exports, 'getPublicBaseUrl', {
|
|
89199
89328
|
enumerable: true,
|
|
89200
89329
|
get: function () {
|
package/dist/config-updater.js
CHANGED
|
@@ -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
|
|
|
@@ -86588,7 +86594,8 @@ function isEnvTruthy(value) {
|
|
|
86588
86594
|
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
86589
86595
|
}
|
|
86590
86596
|
function isChromeDisabled(disableOption) {
|
|
86591
|
-
|
|
86597
|
+
if (isEnvTruthy(process.env.DEV_INSPECTOR_DISABLE_CHROME)) return true;
|
|
86598
|
+
return disableOption ?? true;
|
|
86592
86599
|
}
|
|
86593
86600
|
function getPublicBaseUrl(options) {
|
|
86594
86601
|
const fromEnv = process.env.DEV_INSPECTOR_PUBLIC_BASE_URL;
|
|
@@ -86602,10 +86609,13 @@ var init_helpers = __esmMin((() => {}));
|
|
|
86602
86609
|
//#region src/utils/log-storage.ts
|
|
86603
86610
|
const logs = [];
|
|
86604
86611
|
const networkRequests = [];
|
|
86612
|
+
const stdioLogs = [];
|
|
86605
86613
|
let nextLogId = 1;
|
|
86606
86614
|
let nextRequestId = 1;
|
|
86615
|
+
let nextStdioId = 1;
|
|
86607
86616
|
const MAX_LOGS = 500;
|
|
86608
86617
|
const MAX_REQUESTS = 500;
|
|
86618
|
+
const MAX_STDIO_LOGS = 500;
|
|
86609
86619
|
function addLog(type, args) {
|
|
86610
86620
|
const log = {
|
|
86611
86621
|
id: nextLogId++,
|
|
@@ -86627,18 +86637,35 @@ function addNetworkRequest(request) {
|
|
|
86627
86637
|
while (networkRequests.length > MAX_REQUESTS) networkRequests.shift();
|
|
86628
86638
|
return req;
|
|
86629
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
|
+
}
|
|
86630
86651
|
function getLogs() {
|
|
86631
86652
|
return [...logs];
|
|
86632
86653
|
}
|
|
86633
86654
|
function getNetworkRequests() {
|
|
86634
86655
|
return [...networkRequests];
|
|
86635
86656
|
}
|
|
86657
|
+
function getStdioLogs() {
|
|
86658
|
+
return [...stdioLogs];
|
|
86659
|
+
}
|
|
86636
86660
|
function getLogById(id) {
|
|
86637
86661
|
return logs.find((l) => l.id === id);
|
|
86638
86662
|
}
|
|
86639
86663
|
function getRequestById(id) {
|
|
86640
86664
|
return networkRequests.find((r) => r.id === id);
|
|
86641
86665
|
}
|
|
86666
|
+
function getStdioById(id) {
|
|
86667
|
+
return stdioLogs.find((s) => s.id === id);
|
|
86668
|
+
}
|
|
86642
86669
|
|
|
86643
86670
|
//#endregion
|
|
86644
86671
|
//#region src/mcp.ts
|
|
@@ -86751,6 +86778,7 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
|
|
|
86751
86778
|
return { prompts: [
|
|
86752
86779
|
{ ...PROMPT_SCHEMAS.capture_element },
|
|
86753
86780
|
{ ...PROMPT_SCHEMAS.view_inspections },
|
|
86781
|
+
{ ...PROMPT_SCHEMAS.get_stdio_messages },
|
|
86754
86782
|
...!chromeDisabled ? [
|
|
86755
86783
|
{
|
|
86756
86784
|
...PROMPT_SCHEMAS.launch_chrome_devtools,
|
|
@@ -87032,6 +87060,75 @@ Default dev server URL: ${process.env.DEV_INSPECTOR_PUBLIC_BASE_URL || `http://$
|
|
|
87032
87060
|
}] };
|
|
87033
87061
|
}
|
|
87034
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
|
+
}
|
|
87035
87132
|
default: throw new Error(`Unknown promptId: ${promptName}`);
|
|
87036
87133
|
}
|
|
87037
87134
|
});
|
|
@@ -87542,6 +87639,32 @@ function setupInspectorMiddleware(middlewares, config) {
|
|
|
87542
87639
|
}
|
|
87543
87640
|
return;
|
|
87544
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
|
+
}
|
|
87545
87668
|
next$1();
|
|
87546
87669
|
});
|
|
87547
87670
|
}
|
|
@@ -89230,4 +89353,4 @@ async function updateMcpConfigs(root$1, sseUrl, options, logger) {
|
|
|
89230
89353
|
}
|
|
89231
89354
|
|
|
89232
89355
|
//#endregion
|
|
89233
|
-
export {
|
|
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/
|
|
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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
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/
|
|
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