@mcp-use/inspector 0.4.11-canary.0 → 0.4.11-canary.1
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 +87 -40
- package/dist/client/assets/{chunk-VL2OQCWN-BE4txAap.js → chunk-VL2OQCWN-DfcO0mnz.js} +2 -2
- package/dist/client/assets/embeddings-xed8XPUx.js +1 -0
- package/dist/client/assets/index-B1D3L6Rv.js +81 -0
- package/dist/client/assets/{index-DrYUC3_O.js → index-BZ1_aNq6.js} +4 -4
- package/dist/client/assets/{index-BEMSyME5.js → index-Bob6AdPG.js} +4 -4
- package/dist/client/assets/{index-Ba21hizt.css → index-BrUPorMz.css} +1 -1
- package/dist/client/assets/{index-B0MYHYe6.js → index-CMBY6iPe.js} +6 -6
- package/dist/client/assets/index-CMXxZksu.js +70 -0
- package/dist/client/assets/{index-BgupETL3.js → index-DAnTywZM.js} +3 -3
- package/dist/client/assets/index-DE-CW45b.js +4 -0
- package/dist/client/assets/{index-mBO7pd_t.js → index-R3N_effq.js} +1 -1
- package/dist/client/assets/{langfuse-MO3AMDBE-DYoZ4Kwk.js → langfuse-LCJ6VJEP-CbWGt6Q5.js} +3 -3
- package/dist/client/index.html +33 -13
- package/dist/server/{chunk-AFTM3F6I.js → chunk-222XA5JA.js} +7 -3
- package/dist/server/{chunk-RK4WSNY7.js → chunk-76XNP4ZB.js} +41 -17
- package/dist/server/{chunk-XJDEAO7Y.js → chunk-JCLAFMDT.js} +3 -1
- package/dist/server/{chunk-VMVT3HVZ.js → chunk-TIYOH5C4.js} +53 -21
- package/dist/server/{chunk-5JZ2RXUR.js → chunk-YGCKPAWJ.js} +9 -5
- package/dist/server/{chunk-JTBAUVJ3.js → chunk-ZFMPIRVB.js} +36 -21
- package/dist/server/cli.js +11 -7
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +6 -6
- package/dist/server/middleware.d.ts +2 -2
- package/dist/server/middleware.d.ts.map +1 -1
- package/dist/server/middleware.js +6 -6
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +20 -10
- package/dist/server/shared-routes.d.ts +1 -1
- package/dist/server/shared-routes.d.ts.map +1 -1
- package/dist/server/shared-routes.js +3 -3
- package/dist/server/shared-static.d.ts +1 -1
- package/dist/server/shared-static.d.ts.map +1 -1
- package/dist/server/shared-static.js +2 -2
- package/dist/server/shared-utils-browser.d.ts +3 -3
- package/dist/server/shared-utils-browser.d.ts.map +1 -1
- package/dist/server/shared-utils-browser.js +1 -1
- package/dist/server/shared-utils.d.ts +3 -3
- package/dist/server/shared-utils.d.ts.map +1 -1
- package/dist/server/shared-utils.js +1 -1
- package/dist/server/utils.d.ts.map +1 -1
- package/dist/server/utils.js +1 -1
- package/package.json +2 -2
- package/dist/client/assets/embeddings-D0mnwVrX.js +0 -1
- package/dist/client/assets/index-CQ9XIRcv.js +0 -150
- package/dist/client/assets/index-wkxN17B9.js +0 -4
package/dist/cli.js
CHANGED
|
@@ -23,7 +23,9 @@ function toBase64(str) {
|
|
|
23
23
|
async function* handleChatRequestStream(requestBody) {
|
|
24
24
|
const { mcpServerUrl, llmConfig, authConfig, messages } = requestBody;
|
|
25
25
|
if (!mcpServerUrl || !llmConfig || !messages) {
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error(
|
|
27
|
+
"Missing required fields: mcpServerUrl, llmConfig, messages"
|
|
28
|
+
);
|
|
27
29
|
}
|
|
28
30
|
const { MCPAgent, MCPClient } = await import("mcp-use");
|
|
29
31
|
let llm;
|
|
@@ -135,7 +137,9 @@ async function* handleChatRequestStream(requestBody) {
|
|
|
135
137
|
async function handleChatRequest(requestBody) {
|
|
136
138
|
const { mcpServerUrl, llmConfig, authConfig, messages } = requestBody;
|
|
137
139
|
if (!mcpServerUrl || !llmConfig || !messages) {
|
|
138
|
-
throw new Error(
|
|
140
|
+
throw new Error(
|
|
141
|
+
"Missing required fields: mcpServerUrl, llmConfig, messages"
|
|
142
|
+
);
|
|
139
143
|
}
|
|
140
144
|
const { MCPAgent, MCPClient } = await import("mcp-use");
|
|
141
145
|
let llm;
|
|
@@ -175,7 +179,10 @@ async function handleChatRequest(requestBody) {
|
|
|
175
179
|
const tokenType = authConfig.oauthTokens.token_type ? authConfig.oauthTokens.token_type.charAt(0).toUpperCase() + authConfig.oauthTokens.token_type.slice(1) : "Bearer";
|
|
176
180
|
serverConfig.headers.Authorization = `${tokenType} ${authConfig.oauthTokens.access_token}`;
|
|
177
181
|
console.log("Using OAuth access token for MCP server authentication");
|
|
178
|
-
console.log(
|
|
182
|
+
console.log(
|
|
183
|
+
"Authorization header:",
|
|
184
|
+
`${tokenType} ${authConfig.oauthTokens.access_token.substring(0, 20)}...`
|
|
185
|
+
);
|
|
179
186
|
} else {
|
|
180
187
|
console.warn("OAuth selected but no access token provided");
|
|
181
188
|
}
|
|
@@ -230,21 +237,35 @@ setInterval(
|
|
|
230
237
|
5 * 60 * 1e3
|
|
231
238
|
).unref();
|
|
232
239
|
function storeWidgetData(data) {
|
|
233
|
-
const {
|
|
240
|
+
const {
|
|
241
|
+
serverId,
|
|
242
|
+
uri,
|
|
243
|
+
toolInput,
|
|
244
|
+
toolOutput,
|
|
245
|
+
resourceData,
|
|
246
|
+
toolId,
|
|
247
|
+
widgetCSP
|
|
248
|
+
} = data;
|
|
234
249
|
console.log("[Widget Store] Received request for toolId:", toolId);
|
|
235
|
-
console.log("[Widget Store] Fields:", {
|
|
250
|
+
console.log("[Widget Store] Fields:", {
|
|
251
|
+
serverId,
|
|
252
|
+
uri,
|
|
253
|
+
hasResourceData: !!resourceData,
|
|
254
|
+
hasToolInput: !!toolInput,
|
|
255
|
+
hasToolOutput: !!toolOutput,
|
|
256
|
+
hasWidgetCSP: !!widgetCSP
|
|
257
|
+
});
|
|
236
258
|
if (!serverId || !uri || !toolId || !resourceData) {
|
|
237
259
|
const missingFields = [];
|
|
238
|
-
if (!serverId)
|
|
239
|
-
|
|
240
|
-
if (!
|
|
241
|
-
|
|
242
|
-
if (!toolId)
|
|
243
|
-
missingFields.push("toolId");
|
|
244
|
-
if (!resourceData)
|
|
245
|
-
missingFields.push("resourceData");
|
|
260
|
+
if (!serverId) missingFields.push("serverId");
|
|
261
|
+
if (!uri) missingFields.push("uri");
|
|
262
|
+
if (!toolId) missingFields.push("toolId");
|
|
263
|
+
if (!resourceData) missingFields.push("resourceData");
|
|
246
264
|
console.error("[Widget Store] Missing required fields:", missingFields);
|
|
247
|
-
return {
|
|
265
|
+
return {
|
|
266
|
+
success: false,
|
|
267
|
+
error: `Missing required fields: ${missingFields.join(", ")}`
|
|
268
|
+
};
|
|
248
269
|
}
|
|
249
270
|
widgetDataStore.set(toolId, {
|
|
250
271
|
serverId,
|
|
@@ -298,7 +319,10 @@ function generateWidgetContainerHtml(basePath, toolId) {
|
|
|
298
319
|
}
|
|
299
320
|
function generateWidgetContentHtml(widgetData) {
|
|
300
321
|
const { serverId, uri, toolInput, toolOutput, resourceData, toolId } = widgetData;
|
|
301
|
-
console.log("[Widget Content] Using pre-fetched resource for:", {
|
|
322
|
+
console.log("[Widget Content] Using pre-fetched resource for:", {
|
|
323
|
+
serverId,
|
|
324
|
+
uri
|
|
325
|
+
});
|
|
302
326
|
let htmlContent = "";
|
|
303
327
|
const contentsArray = Array.isArray(resourceData?.contents) ? resourceData.contents : [];
|
|
304
328
|
const firstContent = contentsArray[0];
|
|
@@ -528,8 +552,8 @@ function getWidgetSecurityHeaders(widgetCSP) {
|
|
|
528
552
|
"X-Frame-Options": "SAMEORIGIN",
|
|
529
553
|
"X-Content-Type-Options": "nosniff",
|
|
530
554
|
"Cache-Control": "no-cache, no-store, must-revalidate",
|
|
531
|
-
|
|
532
|
-
|
|
555
|
+
Pragma: "no-cache",
|
|
556
|
+
Expires: "0"
|
|
533
557
|
};
|
|
534
558
|
}
|
|
535
559
|
|
|
@@ -558,7 +582,9 @@ async function findAvailablePort(startPort2 = 8080, maxAttempts = 100) {
|
|
|
558
582
|
continue;
|
|
559
583
|
}
|
|
560
584
|
}
|
|
561
|
-
throw new Error(
|
|
585
|
+
throw new Error(
|
|
586
|
+
`No available port found after trying ${maxAttempts} ports starting from ${startPort2}`
|
|
587
|
+
);
|
|
562
588
|
}
|
|
563
589
|
function formatErrorResponse(error, context) {
|
|
564
590
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -643,7 +669,9 @@ function registerInspectorRoutes(app2, config) {
|
|
|
643
669
|
} catch (error) {
|
|
644
670
|
const errorMsg = `${JSON.stringify({
|
|
645
671
|
type: "error",
|
|
646
|
-
data: {
|
|
672
|
+
data: {
|
|
673
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
674
|
+
}
|
|
647
675
|
})}
|
|
648
676
|
`;
|
|
649
677
|
await writer.write(encoder.encode(errorMsg));
|
|
@@ -655,7 +683,7 @@ function registerInspectorRoutes(app2, config) {
|
|
|
655
683
|
headers: {
|
|
656
684
|
"Content-Type": "text/event-stream",
|
|
657
685
|
"Cache-Control": "no-cache",
|
|
658
|
-
|
|
686
|
+
Connection: "keep-alive"
|
|
659
687
|
}
|
|
660
688
|
});
|
|
661
689
|
} catch (error) {
|
|
@@ -681,7 +709,10 @@ function registerInspectorRoutes(app2, config) {
|
|
|
681
709
|
return c.json(result);
|
|
682
710
|
} catch (error) {
|
|
683
711
|
console.error("[Widget Store] Error:", error);
|
|
684
|
-
console.error(
|
|
712
|
+
console.error(
|
|
713
|
+
"[Widget Store] Stack:",
|
|
714
|
+
error instanceof Error ? error.stack : ""
|
|
715
|
+
);
|
|
685
716
|
return c.json(formatErrorResponse(error, "storeWidgetData"), 500);
|
|
686
717
|
}
|
|
687
718
|
});
|
|
@@ -701,7 +732,10 @@ function registerInspectorRoutes(app2, config) {
|
|
|
701
732
|
const toolId = c.req.param("toolId");
|
|
702
733
|
const widgetData = getWidgetData(toolId);
|
|
703
734
|
if (!widgetData) {
|
|
704
|
-
console.error(
|
|
735
|
+
console.error(
|
|
736
|
+
"[Widget Content] Widget data not found for toolId:",
|
|
737
|
+
toolId
|
|
738
|
+
);
|
|
705
739
|
return c.html(
|
|
706
740
|
"<html><body>Error: Widget data not found or expired</body></html>",
|
|
707
741
|
404
|
|
@@ -721,10 +755,7 @@ function registerInspectorRoutes(app2, config) {
|
|
|
721
755
|
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
722
756
|
const errorStack = error instanceof Error ? error.stack : "";
|
|
723
757
|
console.error("[Widget Content] Stack:", errorStack);
|
|
724
|
-
return c.html(
|
|
725
|
-
`<html><body>Error: ${errorMessage}</body></html>`,
|
|
726
|
-
500
|
|
727
|
-
);
|
|
758
|
+
return c.html(`<html><body>Error: ${errorMessage}</body></html>`, 500);
|
|
728
759
|
}
|
|
729
760
|
});
|
|
730
761
|
app2.get("/inspector/config.json", (c) => {
|
|
@@ -740,9 +771,12 @@ function registerInspectorRoutes(app2, config) {
|
|
|
740
771
|
return c.json({ success: false, error: "Missing event name" }, 400);
|
|
741
772
|
}
|
|
742
773
|
const { PostHog } = await import("posthog-node");
|
|
743
|
-
const posthog = new PostHog(
|
|
744
|
-
|
|
745
|
-
|
|
774
|
+
const posthog = new PostHog(
|
|
775
|
+
"phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI",
|
|
776
|
+
{
|
|
777
|
+
host: "https://eu.i.posthog.com"
|
|
778
|
+
}
|
|
779
|
+
);
|
|
746
780
|
const distinctId = user_id || "anonymous";
|
|
747
781
|
posthog.capture({
|
|
748
782
|
distinctId,
|
|
@@ -759,16 +793,23 @@ function registerInspectorRoutes(app2, config) {
|
|
|
759
793
|
app2.post("/inspector/api/tel/scarf", async (c) => {
|
|
760
794
|
try {
|
|
761
795
|
const body = await c.req.json();
|
|
762
|
-
const response = await fetch(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
796
|
+
const response = await fetch(
|
|
797
|
+
"https://mcpuse.gateway.scarf.sh/events-inspector",
|
|
798
|
+
{
|
|
799
|
+
method: "POST",
|
|
800
|
+
headers: {
|
|
801
|
+
"Content-Type": "application/json"
|
|
802
|
+
},
|
|
803
|
+
body: JSON.stringify(body)
|
|
804
|
+
}
|
|
805
|
+
);
|
|
769
806
|
if (!response.ok) {
|
|
770
807
|
console.error("[Telemetry] Scarf request failed:", response.status);
|
|
771
|
-
return c.json({
|
|
808
|
+
return c.json({
|
|
809
|
+
success: false,
|
|
810
|
+
status: response.status,
|
|
811
|
+
error: response.statusText
|
|
812
|
+
});
|
|
772
813
|
}
|
|
773
814
|
return c.json({ success: true });
|
|
774
815
|
} catch (error) {
|
|
@@ -838,7 +879,9 @@ function registerStaticRoutes(app2, clientDistPath) {
|
|
|
838
879
|
const distPath = clientDistPath || getClientDistPath();
|
|
839
880
|
if (!checkClientFiles(distPath)) {
|
|
840
881
|
console.warn(`\u26A0\uFE0F MCP Inspector client files not found at ${distPath}`);
|
|
841
|
-
console.warn(
|
|
882
|
+
console.warn(
|
|
883
|
+
` Run 'yarn build' in the inspector package to build the UI`
|
|
884
|
+
);
|
|
842
885
|
app2.get("*", (c) => {
|
|
843
886
|
return c.html(`
|
|
844
887
|
<!DOCTYPE html>
|
|
@@ -907,7 +950,9 @@ for (let i = 0; i < args.length; i++) {
|
|
|
907
950
|
} else if (args[i] === "--port" && i + 1 < args.length) {
|
|
908
951
|
const parsedPort = Number.parseInt(args[i + 1], 10);
|
|
909
952
|
if (Number.isNaN(parsedPort) || parsedPort < 1 || parsedPort > 65535) {
|
|
910
|
-
console.error(
|
|
953
|
+
console.error(
|
|
954
|
+
`Error: Port must be a number between 1 and 65535, got: ${args[i + 1]}`
|
|
955
|
+
);
|
|
911
956
|
process.exit(1);
|
|
912
957
|
}
|
|
913
958
|
startPort = parsedPort;
|
|
@@ -957,7 +1002,9 @@ async function startServer() {
|
|
|
957
1002
|
await open(`http://localhost:${port}/inspector`);
|
|
958
1003
|
console.log(`\u{1F310} Browser opened`);
|
|
959
1004
|
} catch {
|
|
960
|
-
console.log(
|
|
1005
|
+
console.log(
|
|
1006
|
+
`\u{1F310} Please open http://localhost:${port}/inspector in your browser`
|
|
1007
|
+
);
|
|
961
1008
|
}
|
|
962
1009
|
return { port, fetch: app.fetch };
|
|
963
1010
|
} catch (error) {
|