mcp-use 2.0.0-beta.21 → 2.0.0-beta.22

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/config.d.ts CHANGED
@@ -14,13 +14,13 @@ export interface InspectorOptions {
14
14
  enabled?: boolean;
15
15
  /**
16
16
  * Full replacement URL for the inspector bundle script (FastAPI's
17
- * `swagger_js_url` analog). The shell's `<script type="module">` loads
18
- * exactly this URL, so it must point at a complete copy of the
17
+ * `swagger_js_url` analog). When set, the shell's `<script type="module">`
18
+ * loads exactly this URL, so it must point at a complete copy of the
19
19
  * `@mcp-use/inspector` CDN bundle (`dist/cdn/inspector.js`) — self-host it
20
20
  * for air-gapped environments where the public CDN is unreachable.
21
21
  *
22
- * @defaultValue The mcp-use CDN URL for the `@mcp-use/inspector` bundle,
23
- * pinned to the current version.
22
+ * @defaultValue The latest `@mcp-use/inspector` beta, resolved to one exact
23
+ * asset version in the browser before the bundle loads.
24
24
  */
25
25
  assetsUrl?: string;
26
26
  /**
@@ -185,12 +185,12 @@ interface BaseServerConfig {
185
185
  *
186
186
  * @remarks
187
187
  * Follows the FastAPI `/docs` model: the server itself ships only a tiny
188
- * dependency-free HTML page whose `<script type="module">` loads the
189
- * `@mcp-use/inspector` bundle from a CDN (pinned to the current inspector
190
- * version), so the UI updates independently of SDK releases and adds
191
- * nothing to the install. The page tells the inspector to connect to this
192
- * server's MCP endpoint at `basePath`, deriving the URL from the browser's
193
- * own origin.
188
+ * dependency-free HTML page whose inline module loader resolves the latest
189
+ * `@mcp-use/inspector` beta to one exact CDN release before loading it, so
190
+ * the UI updates independently of SDK releases without mixing asset
191
+ * versions or adding anything to the install. The page tells the inspector
192
+ * to connect to this server's MCP endpoint at `basePath`, deriving the URL
193
+ * from the browser's own origin.
194
194
  *
195
195
  * Enabled by default; set `{ enabled: false }` to disable the route, or
196
196
  * pass `{ assetsUrl }` to load the bundle from a self-hosted copy instead
package/dist/index.js CHANGED
@@ -764,17 +764,11 @@ function normalizeMcpMiddlewarePattern(raw) {
764
764
  // src/inspector-shell.ts
765
765
  var INSPECTOR_TAG = "beta";
766
766
  var DEFAULT_INSPECTOR_ASSETS_URL = `https://cdn.jsdelivr.net/npm/@mcp-use/inspector@${INSPECTOR_TAG}/dist/cdn/inspector.js`;
767
+ var INSPECTOR_VERSION_RESOLVER_URL = `https://data.jsdelivr.com/v1/packages/npm/@mcp-use/inspector/resolved?specifier=${INSPECTOR_TAG}`;
768
+ var INSPECTOR_CDN_PACKAGE_URL = "https://cdn.jsdelivr.net/npm/@mcp-use/inspector";
767
769
  function inspectorStylesUrl(assetsUrl) {
768
770
  return assetsUrl.replace(/\.js(?=$|[?#])/, ".css");
769
771
  }
770
- function isDefaultJsdelivrInspectorUrl(url) {
771
- return url.startsWith("https://cdn.jsdelivr.net/npm/@mcp-use/inspector@");
772
- }
773
- function withInspectorCacheBust(assetsUrl) {
774
- if (!isDefaultJsdelivrInspectorUrl(assetsUrl)) return assetsUrl;
775
- const sep = assetsUrl.includes("?") ? "&" : "?";
776
- return `${assetsUrl}${sep}cb=${crypto.randomUUID()}`;
777
- }
778
772
  function matchesInspectorShellPath(pathname, basePath) {
779
773
  const prefix = pathUnderBase(basePath, "inspector");
780
774
  if (pathname !== prefix && !pathname.startsWith(`${prefix}/`)) {
@@ -789,6 +783,53 @@ function escapeHtml(value) {
789
783
  function serializeForInlineScript(value) {
790
784
  return JSON.stringify(value).replaceAll("<", "\\u003c");
791
785
  }
786
+ function renderDefaultInspectorAssetLoader() {
787
+ return `<script type="module">
788
+ const resolverUrl = ${serializeForInlineScript(INSPECTOR_VERSION_RESOLVER_URL)};
789
+ const packageUrl = ${serializeForInlineScript(INSPECTOR_CDN_PACKAGE_URL)};
790
+ const versionPattern = /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/;
791
+
792
+ try {
793
+ const controller = new AbortController();
794
+ const timeout = setTimeout(() => controller.abort(), 10_000);
795
+ let response;
796
+ try {
797
+ response = await fetch(resolverUrl, { signal: controller.signal });
798
+ } finally {
799
+ clearTimeout(timeout);
800
+ }
801
+ if (!response.ok) {
802
+ throw new Error(\`Inspector version resolver returned HTTP \${response.status}\`);
803
+ }
804
+
805
+ const resolved = await response.json();
806
+ if (
807
+ resolved?.name !== "@mcp-use/inspector" ||
808
+ typeof resolved.version !== "string" ||
809
+ !versionPattern.test(resolved.version)
810
+ ) {
811
+ throw new Error("Inspector version resolver returned an invalid release");
812
+ }
813
+
814
+ const version = resolved.version;
815
+ const assetBase = \`\${packageUrl}@\${version}/dist/cdn\`;
816
+ const stylesheet = document.createElement("link");
817
+ stylesheet.rel = "stylesheet";
818
+ stylesheet.href = \`\${assetBase}/inspector.css\`;
819
+ document.head.append(stylesheet);
820
+
821
+ window.__INSPECTOR_VERSION__ = version;
822
+ await import(\`\${assetBase}/inspector.js\`);
823
+ } catch (error) {
824
+ console.error("[Inspector] Failed to load the latest Inspector release:", error);
825
+ document.querySelector(".mcp-boot-spinner")?.remove();
826
+ const label = document.querySelector(".mcp-boot-label");
827
+ if (label) {
828
+ label.textContent = "Unable to load Inspector. Reload to try again.";
829
+ }
830
+ }
831
+ </script>`;
832
+ }
792
833
  function renderInspectorShell(options) {
793
834
  const {
794
835
  serverName,
@@ -800,10 +841,13 @@ function renderInspectorShell(options) {
800
841
  } = options;
801
842
  const serializedBasePath = serializeForInlineScript(basePath);
802
843
  const serializedManufactChatUrl = manufactChatUrl ? serializeForInlineScript(manufactChatUrl) : null;
803
- const rawUrl = assetsUrl ?? DEFAULT_INSPECTOR_ASSETS_URL;
804
- const bundleUrl = withInspectorCacheBust(rawUrl);
805
- const scriptSrc = escapeHtml(bundleUrl);
806
- const stylesHref = escapeHtml(inspectorStylesUrl(bundleUrl));
844
+ const usesDefaultAssets = assetsUrl === void 0;
845
+ const customScriptSrc = assetsUrl === void 0 ? null : escapeHtml(assetsUrl);
846
+ const customStylesHref = assetsUrl === void 0 ? null : escapeHtml(inspectorStylesUrl(assetsUrl));
847
+ const assetPreconnects = usesDefaultAssets ? ` <link rel="preconnect" href="https://data.jsdelivr.com" crossorigin />
848
+ <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin />` : "";
849
+ const stylesheetTag = customStylesHref !== null ? ` <link rel="stylesheet" href="${customStylesHref}" />` : "";
850
+ const assetLoader = usesDefaultAssets ? renderDefaultInspectorAssetLoader() : `<script type="module" src="${customScriptSrc}"></script>`;
807
851
  return `<!doctype html>
808
852
  <html lang="en">
809
853
  <head>
@@ -813,11 +857,12 @@ function renderInspectorShell(options) {
813
857
  ${faviconHref !== void 0 ? `<link rel="icon"${faviconType !== void 0 ? ` type="${escapeHtml(faviconType)}"` : ""} href="${escapeHtml(faviconHref)}" />` : ""}
814
858
  <link rel="preconnect" href="https://fonts.googleapis.com" />
815
859
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
860
+ ${assetPreconnects}
816
861
  <link
817
862
  href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;500;700&display=swap"
818
863
  rel="stylesheet"
819
864
  />
820
- <link rel="stylesheet" href="${stylesHref}" />
865
+ ${stylesheetTag}
821
866
  <style>
822
867
  :root { color-scheme: light dark; }
823
868
  html, body { height: 100%; margin: 0; background-color: #f3f3f3; }
@@ -912,7 +957,7 @@ function renderInspectorShell(options) {
912
957
  }
913
958
  })();
914
959
  </script>
915
- <script type="module" src="${scriptSrc}"></script>
960
+ ${assetLoader}
916
961
  </body>
917
962
  </html>
918
963
  `;