@modelcontextprotocol/inspector 0.16.3 → 0.16.4

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.
@@ -1,5 +1,4 @@
1
- import { u as useToast, r as reactExports, j as jsxRuntimeExports, S as SESSION_KEYS, I as InspectorOAuthClientProvider, a as auth } from "./index-CHDvjhl9.js";
2
- import { p as parseOAuthCallbackParams, g as generateOAuthErrorDescription } from "./oauthUtils-DTcoXpSP.js";
1
+ import { u as useToast, r as reactExports, j as jsxRuntimeExports, p as parseOAuthCallbackParams, g as generateOAuthErrorDescription, S as SESSION_KEYS, I as InspectorOAuthClientProvider, a as auth } from "./index-MFoeZZBS.js";
3
2
  const OAuthCallback = ({ onConnect }) => {
4
3
  const { toast } = useToast();
5
4
  const hasProcessedRef = reactExports.useRef(false);
@@ -1,5 +1,4 @@
1
- import { r as reactExports, S as SESSION_KEYS, j as jsxRuntimeExports } from "./index-CHDvjhl9.js";
2
- import { p as parseOAuthCallbackParams, g as generateOAuthErrorDescription } from "./oauthUtils-DTcoXpSP.js";
1
+ import { r as reactExports, S as SESSION_KEYS, p as parseOAuthCallbackParams, j as jsxRuntimeExports, g as generateOAuthErrorDescription } from "./index-MFoeZZBS.js";
3
2
  const OAuthDebugCallback = ({ onConnect }) => {
4
3
  reactExports.useEffect(() => {
5
4
  let isProcessed = false;
@@ -1,4 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OAuthCallback-DCwiUoWl.js","assets/oauthUtils-DTcoXpSP.js","assets/OAuthDebugCallback-BNuktUej.js"])))=>i.map(i=>d[i]);
2
1
  function _mergeNamespaces(n, m2) {
3
2
  for (var i = 0; i < m2.length; i++) {
4
3
  const e = m2[i];
@@ -1123,13 +1122,13 @@ function requireReactDom_production_min() {
1123
1122
  function lb(a, b) {
1124
1123
  return null == a || "http://www.w3.org/1999/xhtml" === a ? kb(b) : "http://www.w3.org/2000/svg" === a && "foreignObject" === b ? "http://www.w3.org/1999/xhtml" : a;
1125
1124
  }
1126
- var mb, nb = function(a) {
1125
+ var mb, nb = (function(a) {
1127
1126
  return "undefined" !== typeof MSApp && MSApp.execUnsafeLocalFunction ? function(b, c, d, e) {
1128
1127
  MSApp.execUnsafeLocalFunction(function() {
1129
1128
  return a(b, c, d, e);
1130
1129
  });
1131
1130
  } : a;
1132
- }(function(a, b) {
1131
+ })(function(a, b) {
1133
1132
  if ("http://www.w3.org/2000/svg" !== a.namespaceURI || "innerHTML" in a) a.innerHTML = b;
1134
1133
  else {
1135
1134
  mb = mb || document.createElement("div");
@@ -7809,7 +7808,7 @@ function usePresence(present) {
7809
7808
  const ownerWindow = node.ownerDocument.defaultView ?? window;
7810
7809
  const handleAnimationEnd = (event) => {
7811
7810
  const currentAnimationName = getAnimationName(stylesRef.current);
7812
- const isCurrentAnimation = currentAnimationName.includes(event.animationName);
7811
+ const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
7813
7812
  if (event.target === node && isCurrentAnimation) {
7814
7813
  send("ANIMATION_END");
7815
7814
  if (!prevPresentRef.current) {
@@ -8163,7 +8162,6 @@ var FocusProxy = reactExports.forwardRef(
8163
8162
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
8164
8163
  VisuallyHidden,
8165
8164
  {
8166
- "aria-hidden": true,
8167
8165
  tabIndex: 0,
8168
8166
  ...proxyProps,
8169
8167
  ref: forwardedRef,
@@ -8317,7 +8315,6 @@ var ToastImpl = reactExports.forwardRef(
8317
8315
  __scopeToast,
8318
8316
  role: "status",
8319
8317
  "aria-live": type2 === "foreground" ? "assertive" : "polite",
8320
- "aria-atomic": true,
8321
8318
  children: announceTextContent
8322
8319
  }
8323
8320
  ),
@@ -8333,9 +8330,6 @@ var ToastImpl = reactExports.forwardRef(
8333
8330
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8334
8331
  Primitive.li,
8335
8332
  {
8336
- role: "status",
8337
- "aria-live": "off",
8338
- "aria-atomic": true,
8339
8333
  tabIndex: 0,
8340
8334
  "data-state": open ? "open" : "closed",
8341
8335
  "data-swipe-direction": context.swipeDirection,
@@ -16258,151 +16252,6 @@ const EMPTY_DEBUGGER_STATE = {
16258
16252
  statusMessage: null,
16259
16253
  validationError: null
16260
16254
  };
16261
- const getClientInformationFromSessionStorage = async ({
16262
- serverUrl,
16263
- isPreregistered
16264
- }) => {
16265
- const key = getServerSpecificKey(
16266
- isPreregistered ? SESSION_KEYS.PREREGISTERED_CLIENT_INFORMATION : SESSION_KEYS.CLIENT_INFORMATION,
16267
- serverUrl
16268
- );
16269
- const value = sessionStorage.getItem(key);
16270
- if (!value) {
16271
- return void 0;
16272
- }
16273
- return await OAuthClientInformationSchema.parseAsync(JSON.parse(value));
16274
- };
16275
- const saveClientInformationToSessionStorage = ({
16276
- serverUrl,
16277
- clientInformation,
16278
- isPreregistered
16279
- }) => {
16280
- const key = getServerSpecificKey(
16281
- isPreregistered ? SESSION_KEYS.PREREGISTERED_CLIENT_INFORMATION : SESSION_KEYS.CLIENT_INFORMATION,
16282
- serverUrl
16283
- );
16284
- sessionStorage.setItem(key, JSON.stringify(clientInformation));
16285
- };
16286
- const clearClientInformationFromSessionStorage = ({
16287
- serverUrl,
16288
- isPreregistered
16289
- }) => {
16290
- const key = getServerSpecificKey(
16291
- isPreregistered ? SESSION_KEYS.PREREGISTERED_CLIENT_INFORMATION : SESSION_KEYS.CLIENT_INFORMATION,
16292
- serverUrl
16293
- );
16294
- sessionStorage.removeItem(key);
16295
- };
16296
- class InspectorOAuthClientProvider {
16297
- constructor(serverUrl) {
16298
- this.serverUrl = serverUrl;
16299
- sessionStorage.setItem(SESSION_KEYS.SERVER_URL, serverUrl);
16300
- }
16301
- get redirectUrl() {
16302
- return window.location.origin + "/oauth/callback";
16303
- }
16304
- get clientMetadata() {
16305
- return {
16306
- redirect_uris: [this.redirectUrl],
16307
- token_endpoint_auth_method: "none",
16308
- grant_types: ["authorization_code", "refresh_token"],
16309
- response_types: ["code"],
16310
- client_name: "MCP Inspector",
16311
- client_uri: "https://github.com/modelcontextprotocol/inspector"
16312
- };
16313
- }
16314
- async clientInformation() {
16315
- const preregisteredClientInformation = await getClientInformationFromSessionStorage({
16316
- serverUrl: this.serverUrl,
16317
- isPreregistered: true
16318
- });
16319
- return preregisteredClientInformation ?? await getClientInformationFromSessionStorage({
16320
- serverUrl: this.serverUrl,
16321
- isPreregistered: false
16322
- });
16323
- }
16324
- saveClientInformation(clientInformation) {
16325
- saveClientInformationToSessionStorage({
16326
- serverUrl: this.serverUrl,
16327
- clientInformation,
16328
- isPreregistered: false
16329
- });
16330
- }
16331
- async tokens() {
16332
- const key = getServerSpecificKey(SESSION_KEYS.TOKENS, this.serverUrl);
16333
- const tokens = sessionStorage.getItem(key);
16334
- if (!tokens) {
16335
- return void 0;
16336
- }
16337
- return await OAuthTokensSchema.parseAsync(JSON.parse(tokens));
16338
- }
16339
- saveTokens(tokens) {
16340
- const key = getServerSpecificKey(SESSION_KEYS.TOKENS, this.serverUrl);
16341
- sessionStorage.setItem(key, JSON.stringify(tokens));
16342
- }
16343
- redirectToAuthorization(authorizationUrl) {
16344
- window.location.href = authorizationUrl.href;
16345
- }
16346
- saveCodeVerifier(codeVerifier) {
16347
- const key = getServerSpecificKey(
16348
- SESSION_KEYS.CODE_VERIFIER,
16349
- this.serverUrl
16350
- );
16351
- sessionStorage.setItem(key, codeVerifier);
16352
- }
16353
- codeVerifier() {
16354
- const key = getServerSpecificKey(
16355
- SESSION_KEYS.CODE_VERIFIER,
16356
- this.serverUrl
16357
- );
16358
- const verifier = sessionStorage.getItem(key);
16359
- if (!verifier) {
16360
- throw new Error("No code verifier saved for session");
16361
- }
16362
- return verifier;
16363
- }
16364
- clear() {
16365
- clearClientInformationFromSessionStorage({
16366
- serverUrl: this.serverUrl,
16367
- isPreregistered: false
16368
- });
16369
- sessionStorage.removeItem(
16370
- getServerSpecificKey(SESSION_KEYS.TOKENS, this.serverUrl)
16371
- );
16372
- sessionStorage.removeItem(
16373
- getServerSpecificKey(SESSION_KEYS.CODE_VERIFIER, this.serverUrl)
16374
- );
16375
- }
16376
- }
16377
- class DebugInspectorOAuthClientProvider extends InspectorOAuthClientProvider {
16378
- get redirectUrl() {
16379
- return `${window.location.origin}/oauth/callback/debug`;
16380
- }
16381
- saveServerMetadata(metadata) {
16382
- const key = getServerSpecificKey(
16383
- SESSION_KEYS.SERVER_METADATA,
16384
- this.serverUrl
16385
- );
16386
- sessionStorage.setItem(key, JSON.stringify(metadata));
16387
- }
16388
- getServerMetadata() {
16389
- const key = getServerSpecificKey(
16390
- SESSION_KEYS.SERVER_METADATA,
16391
- this.serverUrl
16392
- );
16393
- const metadata = sessionStorage.getItem(key);
16394
- if (!metadata) {
16395
- return null;
16396
- }
16397
- return JSON.parse(metadata);
16398
- }
16399
- clear() {
16400
- super.clear();
16401
- sessionStorage.removeItem(
16402
- getServerSpecificKey(SESSION_KEYS.SERVER_METADATA, this.serverUrl)
16403
- );
16404
- }
16405
- }
16406
16255
  let crypto$1;
16407
16256
  crypto$1 = globalThis.crypto;
16408
16257
  async function getRandomValues(size2) {
@@ -16653,7 +16502,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
16653
16502
  }
16654
16503
  const fullInformation = await registerClient(authorizationServerUrl, {
16655
16504
  metadata,
16656
- clientMetadata: provider.clientMetadata
16505
+ clientMetadata: provider.clientMetadata,
16506
+ fetchFn
16657
16507
  });
16658
16508
  await provider.saveClientInformation(fullInformation);
16659
16509
  clientInformation = fullInformation;
@@ -16681,7 +16531,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
16681
16531
  clientInformation,
16682
16532
  refreshToken: tokens.refresh_token,
16683
16533
  resource,
16684
- addClientAuthentication: provider.addClientAuthentication
16534
+ addClientAuthentication: provider.addClientAuthentication,
16535
+ fetchFn
16685
16536
  });
16686
16537
  await provider.saveTokens(newTokens);
16687
16538
  return "AUTHORIZED";
@@ -16799,29 +16650,6 @@ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, o
16799
16650
  }
16800
16651
  return response;
16801
16652
  }
16802
- async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolVersion } = {}, fetchFn = fetch) {
16803
- if (typeof issuer === "string") {
16804
- issuer = new URL(issuer);
16805
- }
16806
- if (!authorizationServerUrl) {
16807
- authorizationServerUrl = issuer;
16808
- }
16809
- if (typeof authorizationServerUrl === "string") {
16810
- authorizationServerUrl = new URL(authorizationServerUrl);
16811
- }
16812
- protocolVersion !== null && protocolVersion !== void 0 ? protocolVersion : protocolVersion = LATEST_PROTOCOL_VERSION;
16813
- const response = await discoverMetadataWithFallback(authorizationServerUrl, "oauth-authorization-server", fetchFn, {
16814
- protocolVersion,
16815
- metadataServerUrl: authorizationServerUrl
16816
- });
16817
- if (!response || response.status === 404) {
16818
- return void 0;
16819
- }
16820
- if (!response.ok) {
16821
- throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);
16822
- }
16823
- return OAuthMetadataSchema.parse(await response.json());
16824
- }
16825
16653
  function buildDiscoveryUrls(authorizationServerUrl) {
16826
16654
  const url = typeof authorizationServerUrl === "string" ? new URL(authorizationServerUrl) : authorizationServerUrl;
16827
16655
  const hasPath = url.pathname !== "/";
@@ -17021,6 +16849,212 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
17021
16849
  }
17022
16850
  return OAuthClientInformationFullSchema.parse(await response.json());
17023
16851
  }
16852
+ const parseOAuthCallbackParams = (location) => {
16853
+ const params = new URLSearchParams(location);
16854
+ const code = params.get("code");
16855
+ if (code) {
16856
+ return { successful: true, code };
16857
+ }
16858
+ const error = params.get("error");
16859
+ const error_description = params.get("error_description");
16860
+ const error_uri = params.get("error_uri");
16861
+ if (error) {
16862
+ return { successful: false, error, error_description, error_uri };
16863
+ }
16864
+ return {
16865
+ successful: false,
16866
+ error: "invalid_request",
16867
+ error_description: "Missing code or error in response",
16868
+ error_uri: null
16869
+ };
16870
+ };
16871
+ const generateOAuthState = () => {
16872
+ const array = new Uint8Array(32);
16873
+ crypto.getRandomValues(array);
16874
+ return Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join(
16875
+ ""
16876
+ );
16877
+ };
16878
+ const generateOAuthErrorDescription = (params) => {
16879
+ const error = params.error;
16880
+ const errorDescription = params.error_description;
16881
+ const errorUri = params.error_uri;
16882
+ return [
16883
+ `Error: ${error}.`,
16884
+ errorDescription ? `Details: ${errorDescription}.` : "",
16885
+ errorUri ? `More info: ${errorUri}.` : ""
16886
+ ].filter(Boolean).join("\n");
16887
+ };
16888
+ const discoverScopes = async (serverUrl, resourceMetadata) => {
16889
+ try {
16890
+ const metadata = await discoverAuthorizationServerMetadata(
16891
+ new URL("/", serverUrl)
16892
+ );
16893
+ const resourceScopes = resourceMetadata == null ? void 0 : resourceMetadata.scopes_supported;
16894
+ const oauthScopes = metadata == null ? void 0 : metadata.scopes_supported;
16895
+ const scopesSupported = resourceScopes && resourceScopes.length > 0 ? resourceScopes : oauthScopes;
16896
+ return scopesSupported && scopesSupported.length > 0 ? scopesSupported.join(" ") : void 0;
16897
+ } catch (error) {
16898
+ console.debug("OAuth scope discovery failed:", error);
16899
+ return void 0;
16900
+ }
16901
+ };
16902
+ const getClientInformationFromSessionStorage = async ({
16903
+ serverUrl,
16904
+ isPreregistered
16905
+ }) => {
16906
+ const key = getServerSpecificKey(
16907
+ isPreregistered ? SESSION_KEYS.PREREGISTERED_CLIENT_INFORMATION : SESSION_KEYS.CLIENT_INFORMATION,
16908
+ serverUrl
16909
+ );
16910
+ const value = sessionStorage.getItem(key);
16911
+ if (!value) {
16912
+ return void 0;
16913
+ }
16914
+ return await OAuthClientInformationSchema.parseAsync(JSON.parse(value));
16915
+ };
16916
+ const saveClientInformationToSessionStorage = ({
16917
+ serverUrl,
16918
+ clientInformation,
16919
+ isPreregistered
16920
+ }) => {
16921
+ const key = getServerSpecificKey(
16922
+ isPreregistered ? SESSION_KEYS.PREREGISTERED_CLIENT_INFORMATION : SESSION_KEYS.CLIENT_INFORMATION,
16923
+ serverUrl
16924
+ );
16925
+ sessionStorage.setItem(key, JSON.stringify(clientInformation));
16926
+ };
16927
+ const clearClientInformationFromSessionStorage = ({
16928
+ serverUrl,
16929
+ isPreregistered
16930
+ }) => {
16931
+ const key = getServerSpecificKey(
16932
+ isPreregistered ? SESSION_KEYS.PREREGISTERED_CLIENT_INFORMATION : SESSION_KEYS.CLIENT_INFORMATION,
16933
+ serverUrl
16934
+ );
16935
+ sessionStorage.removeItem(key);
16936
+ };
16937
+ class InspectorOAuthClientProvider {
16938
+ constructor(serverUrl) {
16939
+ this.serverUrl = serverUrl;
16940
+ sessionStorage.setItem(SESSION_KEYS.SERVER_URL, serverUrl);
16941
+ }
16942
+ get redirectUrl() {
16943
+ return window.location.origin + "/oauth/callback";
16944
+ }
16945
+ get clientMetadata() {
16946
+ return {
16947
+ redirect_uris: [this.redirectUrl],
16948
+ token_endpoint_auth_method: "none",
16949
+ grant_types: ["authorization_code", "refresh_token"],
16950
+ response_types: ["code"],
16951
+ client_name: "MCP Inspector",
16952
+ client_uri: "https://github.com/modelcontextprotocol/inspector"
16953
+ };
16954
+ }
16955
+ state() {
16956
+ return generateOAuthState();
16957
+ }
16958
+ async clientInformation() {
16959
+ const preregisteredClientInformation = await getClientInformationFromSessionStorage({
16960
+ serverUrl: this.serverUrl,
16961
+ isPreregistered: true
16962
+ });
16963
+ return preregisteredClientInformation ?? await getClientInformationFromSessionStorage({
16964
+ serverUrl: this.serverUrl,
16965
+ isPreregistered: false
16966
+ });
16967
+ }
16968
+ saveClientInformation(clientInformation) {
16969
+ const safeInfo = Object.fromEntries(
16970
+ Object.entries(clientInformation).filter(
16971
+ ([key]) => key !== "client_secret"
16972
+ )
16973
+ );
16974
+ saveClientInformationToSessionStorage({
16975
+ serverUrl: this.serverUrl,
16976
+ clientInformation: safeInfo,
16977
+ isPreregistered: false
16978
+ });
16979
+ }
16980
+ async tokens() {
16981
+ const key = getServerSpecificKey(SESSION_KEYS.TOKENS, this.serverUrl);
16982
+ const tokens = sessionStorage.getItem(key);
16983
+ if (!tokens) {
16984
+ return void 0;
16985
+ }
16986
+ return await OAuthTokensSchema.parseAsync(JSON.parse(tokens));
16987
+ }
16988
+ saveTokens(tokens) {
16989
+ const key = getServerSpecificKey(SESSION_KEYS.TOKENS, this.serverUrl);
16990
+ sessionStorage.setItem(key, JSON.stringify(tokens));
16991
+ }
16992
+ redirectToAuthorization(authorizationUrl) {
16993
+ if (authorizationUrl.protocol !== "http:" && authorizationUrl.protocol !== "https:") {
16994
+ throw new Error("Authorization URL must be HTTP or HTTPS");
16995
+ }
16996
+ window.location.href = authorizationUrl.href;
16997
+ }
16998
+ saveCodeVerifier(codeVerifier) {
16999
+ const key = getServerSpecificKey(
17000
+ SESSION_KEYS.CODE_VERIFIER,
17001
+ this.serverUrl
17002
+ );
17003
+ sessionStorage.setItem(key, codeVerifier);
17004
+ }
17005
+ codeVerifier() {
17006
+ const key = getServerSpecificKey(
17007
+ SESSION_KEYS.CODE_VERIFIER,
17008
+ this.serverUrl
17009
+ );
17010
+ const verifier = sessionStorage.getItem(key);
17011
+ if (!verifier) {
17012
+ throw new Error("No code verifier saved for session");
17013
+ }
17014
+ return verifier;
17015
+ }
17016
+ clear() {
17017
+ clearClientInformationFromSessionStorage({
17018
+ serverUrl: this.serverUrl,
17019
+ isPreregistered: false
17020
+ });
17021
+ sessionStorage.removeItem(
17022
+ getServerSpecificKey(SESSION_KEYS.TOKENS, this.serverUrl)
17023
+ );
17024
+ sessionStorage.removeItem(
17025
+ getServerSpecificKey(SESSION_KEYS.CODE_VERIFIER, this.serverUrl)
17026
+ );
17027
+ }
17028
+ }
17029
+ class DebugInspectorOAuthClientProvider extends InspectorOAuthClientProvider {
17030
+ get redirectUrl() {
17031
+ return `${window.location.origin}/oauth/callback/debug`;
17032
+ }
17033
+ saveServerMetadata(metadata) {
17034
+ const key = getServerSpecificKey(
17035
+ SESSION_KEYS.SERVER_METADATA,
17036
+ this.serverUrl
17037
+ );
17038
+ sessionStorage.setItem(key, JSON.stringify(metadata));
17039
+ }
17040
+ getServerMetadata() {
17041
+ const key = getServerSpecificKey(
17042
+ SESSION_KEYS.SERVER_METADATA,
17043
+ this.serverUrl
17044
+ );
17045
+ const metadata = sessionStorage.getItem(key);
17046
+ if (!metadata) {
17047
+ return null;
17048
+ }
17049
+ return JSON.parse(metadata);
17050
+ }
17051
+ clear() {
17052
+ super.clear();
17053
+ sessionStorage.removeItem(
17054
+ getServerSpecificKey(SESSION_KEYS.SERVER_METADATA, this.serverUrl)
17055
+ );
17056
+ }
17057
+ }
17024
17058
  const oauthTransitions = {
17025
17059
  metadata_discovery: {
17026
17060
  canTransition: async () => true,
@@ -17049,7 +17083,7 @@ const oauthTransitions = {
17049
17083
  // we default to null, so swap it for undefined if not set
17050
17084
  resourceMetadata ?? void 0
17051
17085
  );
17052
- const metadata = await discoverOAuthMetadata(authServerUrl);
17086
+ const metadata = await discoverAuthorizationServerMetadata(authServerUrl);
17053
17087
  if (!metadata) {
17054
17088
  throw new Error("Failed to discover OAuth metadata");
17055
17089
  }
@@ -17075,11 +17109,14 @@ const oauthTransitions = {
17075
17109
  if (scopesSupported) {
17076
17110
  clientMetadata.scope = scopesSupported.join(" ");
17077
17111
  }
17078
- const fullInformation = await registerClient(context.serverUrl, {
17079
- metadata,
17080
- clientMetadata
17081
- });
17082
- context.provider.saveClientInformation(fullInformation);
17112
+ let fullInformation = await context.provider.clientInformation();
17113
+ if (!fullInformation) {
17114
+ fullInformation = await registerClient(context.serverUrl, {
17115
+ metadata,
17116
+ clientMetadata
17117
+ });
17118
+ context.provider.saveClientInformation(fullInformation);
17119
+ }
17083
17120
  context.updateState({
17084
17121
  oauthClientInfo: fullInformation,
17085
17122
  oauthStep: "authorization_redirect"
@@ -17091,16 +17128,10 @@ const oauthTransitions = {
17091
17128
  execute: async (context) => {
17092
17129
  const metadata = context.state.oauthMetadata;
17093
17130
  const clientInformation = context.state.oauthClientInfo;
17094
- let scope = void 0;
17095
- if (metadata.scopes_supported) {
17096
- scope = metadata.scopes_supported.join(" ");
17097
- }
17098
- const array = new Uint8Array(32);
17099
- crypto.getRandomValues(array);
17100
- const state = Array.from(
17101
- array,
17102
- (byte) => byte.toString(16).padStart(2, "0")
17103
- ).join("");
17131
+ const scope = await discoverScopes(
17132
+ context.serverUrl,
17133
+ context.state.resourceMetadata ?? void 0
17134
+ );
17104
17135
  const { authorizationUrl, codeVerifier } = await startAuthorization(
17105
17136
  context.serverUrl,
17106
17137
  {
@@ -17108,7 +17139,7 @@ const oauthTransitions = {
17108
17139
  clientInformation,
17109
17140
  redirectUrl: context.provider.redirectUrl,
17110
17141
  scope,
17111
- state,
17142
+ state: generateOAuthState(),
17112
17143
  resource: context.state.resource ?? void 0
17113
17144
  }
17114
17145
  );
@@ -17193,7 +17224,7 @@ function requireUri_all() {
17193
17224
  (function(module, exports) {
17194
17225
  (function(global2, factory) {
17195
17226
  factory(exports);
17196
- })(uri_all, function(exports2) {
17227
+ })(uri_all, (function(exports2) {
17197
17228
  function merge() {
17198
17229
  for (var _len = arguments.length, sets = Array(_len), _key = 0; _key < _len; _key++) {
17199
17230
  sets[_key] = arguments[_key];
@@ -17260,7 +17291,7 @@ function requireUri_all() {
17260
17291
  }
17261
17292
  var URI_PROTOCOL = buildExps(false);
17262
17293
  var IRI_PROTOCOL = buildExps(true);
17263
- var slicedToArray = /* @__PURE__ */ function() {
17294
+ var slicedToArray = /* @__PURE__ */ (function() {
17264
17295
  function sliceIterator(arr, i) {
17265
17296
  var _arr = [];
17266
17297
  var _n = true;
@@ -17292,7 +17323,7 @@ function requireUri_all() {
17292
17323
  throw new TypeError("Invalid attempt to destructure non-iterable instance");
17293
17324
  }
17294
17325
  };
17295
- }();
17326
+ })();
17296
17327
  var toConsumableArray = function(arr) {
17297
17328
  if (Array.isArray(arr)) {
17298
17329
  for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
@@ -18207,7 +18238,7 @@ function requireUri_all() {
18207
18238
  exports2.escapeComponent = escapeComponent;
18208
18239
  exports2.unescapeComponent = unescapeComponent;
18209
18240
  Object.defineProperty(exports2, "__esModule", { value: true });
18210
- });
18241
+ }));
18211
18242
  })(uri_all$1, uri_all$1.exports);
18212
18243
  return uri_all$1.exports;
18213
18244
  }
@@ -18801,7 +18832,7 @@ function requireFastJsonStableStringify() {
18801
18832
  if (!opts) opts = {};
18802
18833
  if (typeof opts === "function") opts = { cmp: opts };
18803
18834
  var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
18804
- var cmp = opts.cmp && /* @__PURE__ */ function(f) {
18835
+ var cmp = opts.cmp && /* @__PURE__ */ (function(f) {
18805
18836
  return function(node) {
18806
18837
  return function(a, b) {
18807
18838
  var aobj = { key: a, value: node[a] };
@@ -18809,9 +18840,9 @@ function requireFastJsonStableStringify() {
18809
18840
  return f(aobj, bobj);
18810
18841
  };
18811
18842
  };
18812
- }(opts.cmp);
18843
+ })(opts.cmp);
18813
18844
  var seen2 = [];
18814
- return function stringify(node) {
18845
+ return (function stringify(node) {
18815
18846
  if (node && node.toJSON && typeof node.toJSON === "function") {
18816
18847
  node = node.toJSON();
18817
18848
  }
@@ -18844,7 +18875,7 @@ function requireFastJsonStableStringify() {
18844
18875
  }
18845
18876
  seen2.splice(seenIndex, 1);
18846
18877
  return "{" + out + "}";
18847
- }(data2);
18878
+ })(data2);
18848
18879
  };
18849
18880
  return fastJsonStableStringify;
18850
18881
  }
@@ -23297,6 +23328,33 @@ function isPropertyRequired(propertyName, schema) {
23297
23328
  var _a;
23298
23329
  return ((_a = schema.required) == null ? void 0 : _a.includes(propertyName)) ?? false;
23299
23330
  }
23331
+ function normalizeUnionType(schema) {
23332
+ if (schema.anyOf && schema.anyOf.length === 2 && schema.anyOf.some((t) => t.type === "string") && schema.anyOf.some((t) => t.type === "null")) {
23333
+ return { ...schema, type: "string", anyOf: void 0 };
23334
+ }
23335
+ if (schema.anyOf && schema.anyOf.length === 2 && schema.anyOf.some((t) => t.type === "boolean") && schema.anyOf.some((t) => t.type === "null")) {
23336
+ return { ...schema, type: "boolean", anyOf: void 0 };
23337
+ }
23338
+ if (schema.anyOf && schema.anyOf.length === 2 && schema.anyOf.some((t) => t.type === "number") && schema.anyOf.some((t) => t.type === "null")) {
23339
+ return { ...schema, type: "number", anyOf: void 0 };
23340
+ }
23341
+ if (schema.anyOf && schema.anyOf.length === 2 && schema.anyOf.some((t) => t.type === "integer") && schema.anyOf.some((t) => t.type === "null")) {
23342
+ return { ...schema, type: "integer", anyOf: void 0 };
23343
+ }
23344
+ if (Array.isArray(schema.type) && schema.type.length === 2 && schema.type.includes("string") && schema.type.includes("null")) {
23345
+ return { ...schema, type: "string" };
23346
+ }
23347
+ if (Array.isArray(schema.type) && schema.type.length === 2 && schema.type.includes("boolean") && schema.type.includes("null")) {
23348
+ return { ...schema, type: "boolean" };
23349
+ }
23350
+ if (Array.isArray(schema.type) && schema.type.length === 2 && schema.type.includes("number") && schema.type.includes("null")) {
23351
+ return { ...schema, type: "number" };
23352
+ }
23353
+ if (Array.isArray(schema.type) && schema.type.length === 2 && schema.type.includes("integer") && schema.type.includes("null")) {
23354
+ return { ...schema, type: "integer" };
23355
+ }
23356
+ return schema;
23357
+ }
23300
23358
  const DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
23301
23359
  class Protocol {
23302
23360
  constructor(_options) {
@@ -24786,7 +24844,7 @@ const StdErrNotificationSchema = NotificationSchema.extend({
24786
24844
  ClientNotificationSchema.or(
24787
24845
  StdErrNotificationSchema
24788
24846
  ).or(ServerNotificationSchema).or(NotificationSchema);
24789
- const version$1 = "0.16.3";
24847
+ const version$1 = "0.16.4";
24790
24848
  const packageJson = {
24791
24849
  version: version$1
24792
24850
  };
@@ -25090,9 +25148,20 @@ function useConnection({
25090
25148
  const handleAuthError = async (error) => {
25091
25149
  if (is401Error(error)) {
25092
25150
  const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
25151
+ let scope = oauthScope == null ? void 0 : oauthScope.trim();
25152
+ if (!scope) {
25153
+ let resourceMetadata;
25154
+ try {
25155
+ resourceMetadata = await discoverOAuthProtectedResourceMetadata(
25156
+ new URL("/", sseUrl)
25157
+ );
25158
+ } catch {
25159
+ }
25160
+ scope = await discoverScopes(sseUrl, resourceMetadata);
25161
+ }
25093
25162
  const result = await auth(serverAuthProvider, {
25094
25163
  serverUrl: sseUrl,
25095
- scope: oauthScope
25164
+ scope
25096
25165
  });
25097
25166
  return result === "AUTHORIZED";
25098
25167
  }
@@ -25121,6 +25190,7 @@ function useConnection({
25121
25190
  setConnectionStatus("error-connecting-to-proxy");
25122
25191
  return;
25123
25192
  }
25193
+ let lastRequest = "";
25124
25194
  try {
25125
25195
  const headers = {};
25126
25196
  const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
@@ -25282,7 +25352,9 @@ function useConnection({
25282
25352
  });
25283
25353
  }
25284
25354
  if ((capabilities == null ? void 0 : capabilities.logging) && defaultLoggingLevel) {
25355
+ lastRequest = "logging/setLevel";
25285
25356
  await client2.setLoggingLevel(defaultLoggingLevel);
25357
+ lastRequest = "";
25286
25358
  }
25287
25359
  if (onElicitationRequest) {
25288
25360
  client2.setRequestHandler(ElicitRequestSchema, async (request) => {
@@ -25294,6 +25366,13 @@ function useConnection({
25294
25366
  setMcpClient(client2);
25295
25367
  setConnectionStatus("connected");
25296
25368
  } catch (e) {
25369
+ if (lastRequest === "logging/setLevel" && e instanceof McpError && e.code === ErrorCode.MethodNotFound) {
25370
+ toast2({
25371
+ title: "Error",
25372
+ description: `Server declares logging capability but doesn't implement method: "${lastRequest}"`,
25373
+ variant: "destructive"
25374
+ });
25375
+ }
25297
25376
  console.error(e);
25298
25377
  setConnectionStatus("error");
25299
25378
  }
@@ -31058,8 +31137,13 @@ var PopperAnchor = reactExports.forwardRef(
31058
31137
  const context = usePopperContext(ANCHOR_NAME$1, __scopePopper);
31059
31138
  const ref2 = reactExports.useRef(null);
31060
31139
  const composedRefs = useComposedRefs(forwardedRef, ref2);
31140
+ const anchorRef = reactExports.useRef(null);
31061
31141
  reactExports.useEffect(() => {
31062
- context.onAnchorChange((virtualRef == null ? void 0 : virtualRef.current) || ref2.current);
31142
+ const previousAnchor = anchorRef.current;
31143
+ anchorRef.current = (virtualRef == null ? void 0 : virtualRef.current) || ref2.current;
31144
+ if (previousAnchor !== anchorRef.current) {
31145
+ context.onAnchorChange(anchorRef.current);
31146
+ }
31063
31147
  });
31064
31148
  return virtualRef ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(Primitive.div, { ...anchorProps, ref: composedRefs });
31065
31149
  }
@@ -32435,7 +32519,7 @@ function requireLib() {
32435
32519
  };
32436
32520
  return __assign2.apply(this, arguments);
32437
32521
  };
32438
- var __createBinding = lib && lib.__createBinding || (Object.create ? function(o, m2, k2, k22) {
32522
+ var __createBinding = lib && lib.__createBinding || (Object.create ? (function(o, m2, k2, k22) {
32439
32523
  if (k22 === void 0) k22 = k2;
32440
32524
  var desc = Object.getOwnPropertyDescriptor(m2, k2);
32441
32525
  if (!desc || ("get" in desc ? !m2.__esModule : desc.writable || desc.configurable)) {
@@ -32444,13 +32528,13 @@ function requireLib() {
32444
32528
  } };
32445
32529
  }
32446
32530
  Object.defineProperty(o, k22, desc);
32447
- } : function(o, m2, k2, k22) {
32531
+ }) : (function(o, m2, k2, k22) {
32448
32532
  if (k22 === void 0) k22 = k2;
32449
32533
  o[k22] = m2[k2];
32450
- });
32451
- var __setModuleDefault = lib && lib.__setModuleDefault || (Object.create ? function(o, v) {
32534
+ }));
32535
+ var __setModuleDefault = lib && lib.__setModuleDefault || (Object.create ? (function(o, v) {
32452
32536
  Object.defineProperty(o, "default", { enumerable: true, value: v });
32453
- } : function(o, v) {
32537
+ }) : function(o, v) {
32454
32538
  o["default"] = v;
32455
32539
  });
32456
32540
  var __importStar = lib && lib.__importStar || function(mod) {
@@ -32836,7 +32920,7 @@ function requirePrism() {
32836
32920
  * @namespace
32837
32921
  * @public
32838
32922
  */
32839
- var Prism2 = function(_self2) {
32923
+ var Prism2 = (function(_self2) {
32840
32924
  var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
32841
32925
  var uniqueId = 0;
32842
32926
  var plainTextGrammar = {};
@@ -33721,7 +33805,7 @@ function requirePrism() {
33721
33805
  }
33722
33806
  }
33723
33807
  return _;
33724
- }(_self);
33808
+ })(_self);
33725
33809
  if (module.exports) {
33726
33810
  module.exports = Prism2;
33727
33811
  }
@@ -34352,12 +34436,18 @@ const JsonEditor = ({
34352
34436
  displayError && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-red-500 mt-1", children: displayError })
34353
34437
  ] });
34354
34438
  };
34439
+ const isTypeSupported = (type2, supportedTypes) => {
34440
+ if (Array.isArray(type2)) {
34441
+ return type2.every((t) => supportedTypes.includes(t));
34442
+ }
34443
+ return typeof type2 === "string" && supportedTypes.includes(type2);
34444
+ };
34355
34445
  const isSimpleObject = (schema) => {
34356
34446
  const supportedTypes = ["string", "number", "integer", "boolean", "null"];
34357
- if (schema.type && supportedTypes.includes(schema.type)) return true;
34447
+ if (schema.type && isTypeSupported(schema.type, supportedTypes)) return true;
34358
34448
  if (schema.type === "object") {
34359
34449
  return Object.values(schema.properties ?? {}).every(
34360
- (prop) => prop.type && supportedTypes.includes(prop.type)
34450
+ (prop) => prop.type && isTypeSupported(prop.type, supportedTypes)
34361
34451
  );
34362
34452
  }
34363
34453
  if (schema.type === "array") {
@@ -34480,7 +34570,11 @@ const DynamicJsonForm = ({
34480
34570
  );
34481
34571
  }
34482
34572
  const isRequired = ((_a = parentSchema == null ? void 0 : parentSchema.required) == null ? void 0 : _a.includes(propertyName || "")) ?? false;
34483
- switch (propSchema.type) {
34573
+ let fieldType = propSchema.type;
34574
+ if (Array.isArray(fieldType)) {
34575
+ fieldType = fieldType.find((t) => t !== "null") ?? fieldType[0];
34576
+ }
34577
+ switch (fieldType) {
34484
34578
  case "string": {
34485
34579
  if (propSchema.oneOf && propSchema.oneOf.every(
34486
34580
  (option) => typeof option.const === "string" && typeof option.title === "string"
@@ -34628,6 +34722,8 @@ const DynamicJsonForm = ({
34628
34722
  required: isRequired
34629
34723
  }
34630
34724
  );
34725
+ case "null":
34726
+ return null;
34631
34727
  case "object":
34632
34728
  if (!propSchema.properties) {
34633
34729
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -36286,7 +36382,7 @@ const useTheme = () => {
36286
36382
  [theme, setThemeWithSideEffect]
36287
36383
  );
36288
36384
  };
36289
- const version = "0.16.3";
36385
+ const version = "0.16.4";
36290
36386
  var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
36291
36387
  createPopperScope
36292
36388
  ]);
@@ -38063,7 +38159,7 @@ const ToolsTab = ({
38063
38159
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-400", children: selectedTool.description }),
38064
38160
  Object.entries(selectedTool.inputSchema.properties ?? []).map(
38065
38161
  ([key, value]) => {
38066
- const prop = value;
38162
+ const prop = normalizeUnionType(value);
38067
38163
  const inputSchema = selectedTool.inputSchema;
38068
38164
  const required2 = isPropertyRequired(key, inputSchema);
38069
38165
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
@@ -38108,7 +38204,7 @@ const ToolsTab = ({
38108
38204
  value: params[key] ?? "",
38109
38205
  onChange: (e) => setParams({
38110
38206
  ...params,
38111
- [key]: e.target.value
38207
+ [key]: e.target.value === "" ? void 0 : e.target.value
38112
38208
  }),
38113
38209
  className: "mt-1"
38114
38210
  }
@@ -38952,13 +39048,13 @@ const App = () => {
38952
39048
  ) });
38953
39049
  if (window.location.pathname === "/oauth/callback") {
38954
39050
  const OAuthCallback = React.lazy(
38955
- () => __vitePreload(() => import("./OAuthCallback-DCwiUoWl.js"), true ? __vite__mapDeps([0,1]) : void 0)
39051
+ () => __vitePreload(() => import("./OAuthCallback-DyaAiF-O.js"), true ? [] : void 0)
38956
39052
  );
38957
39053
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthCallback, { onConnect: onOAuthConnect }) });
38958
39054
  }
38959
39055
  if (window.location.pathname === "/oauth/callback/debug") {
38960
39056
  const OAuthDebugCallback = React.lazy(
38961
- () => __vitePreload(() => import("./OAuthDebugCallback-BNuktUej.js"), true ? __vite__mapDeps([2,1]) : void 0)
39057
+ () => __vitePreload(() => import("./OAuthDebugCallback-BD-zJllm.js"), true ? [] : void 0)
38962
39058
  );
38963
39059
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthDebugCallback, { onConnect: onOAuthDebugConnect }) });
38964
39060
  }
@@ -39326,7 +39422,9 @@ export {
39326
39422
  InspectorOAuthClientProvider as I,
39327
39423
  SESSION_KEYS as S,
39328
39424
  auth as a,
39425
+ generateOAuthErrorDescription as g,
39329
39426
  jsxRuntimeExports as j,
39427
+ parseOAuthCallbackParams as p,
39330
39428
  reactExports as r,
39331
39429
  useToast as u
39332
39430
  };
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/mcp.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>MCP Inspector</title>
8
- <script type="module" crossorigin src="/assets/index-CHDvjhl9.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-MFoeZZBS.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BWZfLo5E.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelcontextprotocol/inspector",
3
- "version": "0.16.3",
3
+ "version": "0.16.4",
4
4
  "description": "Model Context Protocol inspector",
5
5
  "license": "MIT",
6
6
  "author": "Anthropic, PBC (https://anthropic.com)",
@@ -47,10 +47,10 @@
47
47
  "check-version": "node scripts/check-version-consistency.js"
48
48
  },
49
49
  "dependencies": {
50
- "@modelcontextprotocol/inspector-cli": "^0.16.3",
51
- "@modelcontextprotocol/inspector-client": "^0.16.3",
52
- "@modelcontextprotocol/inspector-server": "^0.16.3",
53
- "@modelcontextprotocol/sdk": "^1.17.0",
50
+ "@modelcontextprotocol/inspector-cli": "^0.16.4",
51
+ "@modelcontextprotocol/inspector-client": "^0.16.4",
52
+ "@modelcontextprotocol/inspector-server": "^0.16.4",
53
+ "@modelcontextprotocol/sdk": "^1.17.2",
54
54
  "concurrently": "^9.2.0",
55
55
  "open": "^10.2.0",
56
56
  "shell-quote": "^1.8.3",
@@ -1,33 +0,0 @@
1
- const parseOAuthCallbackParams = (location) => {
2
- const params = new URLSearchParams(location);
3
- const code = params.get("code");
4
- if (code) {
5
- return { successful: true, code };
6
- }
7
- const error = params.get("error");
8
- const error_description = params.get("error_description");
9
- const error_uri = params.get("error_uri");
10
- if (error) {
11
- return { successful: false, error, error_description, error_uri };
12
- }
13
- return {
14
- successful: false,
15
- error: "invalid_request",
16
- error_description: "Missing code or error in response",
17
- error_uri: null
18
- };
19
- };
20
- const generateOAuthErrorDescription = (params) => {
21
- const error = params.error;
22
- const errorDescription = params.error_description;
23
- const errorUri = params.error_uri;
24
- return [
25
- `Error: ${error}.`,
26
- errorDescription ? `Details: ${errorDescription}.` : "",
27
- errorUri ? `More info: ${errorUri}.` : ""
28
- ].filter(Boolean).join("\n");
29
- };
30
- export {
31
- generateOAuthErrorDescription as g,
32
- parseOAuthCallbackParams as p
33
- };