@modelcontextprotocol/inspector-client 0.16.0 → 0.16.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.
@@ -1,4 +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-DI7JCTeu.js";
1
+ import { u as useToast, r as reactExports, j as jsxRuntimeExports, S as SESSION_KEYS, I as InspectorOAuthClientProvider, a as auth } from "./index-CPgI0-gs.js";
2
2
  import { p as parseOAuthCallbackParams, g as generateOAuthErrorDescription } from "./oauthUtils-DTcoXpSP.js";
3
3
  const OAuthCallback = ({ onConnect }) => {
4
4
  const { toast } = useToast();
@@ -1,4 +1,4 @@
1
- import { r as reactExports, S as SESSION_KEYS, j as jsxRuntimeExports } from "./index-DI7JCTeu.js";
1
+ import { r as reactExports, S as SESSION_KEYS, j as jsxRuntimeExports } from "./index-CPgI0-gs.js";
2
2
  import { p as parseOAuthCallbackParams, g as generateOAuthErrorDescription } from "./oauthUtils-DTcoXpSP.js";
3
3
  const OAuthDebugCallback = ({ onConnect }) => {
4
4
  reactExports.useEffect(() => {
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OAuthCallback-DMQy4ibj.js","assets/oauthUtils-DTcoXpSP.js","assets/OAuthDebugCallback-9JxBAysc.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/OAuthCallback-CaDIOg8Q.js","assets/oauthUtils-DTcoXpSP.js","assets/OAuthDebugCallback-Ccjj44Wa.js"])))=>i.map(i=>d[i]);
2
2
  function _mergeNamespaces(n, m2) {
3
3
  for (var i = 0; i < m2.length; i++) {
4
4
  const e = m2[i];
@@ -16375,6 +16375,54 @@ class UnauthorizedError extends Error {
16375
16375
  super(message !== null && message !== void 0 ? message : "Unauthorized");
16376
16376
  }
16377
16377
  }
16378
+ function selectClientAuthMethod(clientInformation, supportedMethods) {
16379
+ const hasClientSecret = clientInformation.client_secret !== void 0;
16380
+ if (supportedMethods.length === 0) {
16381
+ return hasClientSecret ? "client_secret_post" : "none";
16382
+ }
16383
+ if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
16384
+ return "client_secret_basic";
16385
+ }
16386
+ if (hasClientSecret && supportedMethods.includes("client_secret_post")) {
16387
+ return "client_secret_post";
16388
+ }
16389
+ if (supportedMethods.includes("none")) {
16390
+ return "none";
16391
+ }
16392
+ return hasClientSecret ? "client_secret_post" : "none";
16393
+ }
16394
+ function applyClientAuthentication(method, clientInformation, headers, params) {
16395
+ const { client_id, client_secret } = clientInformation;
16396
+ switch (method) {
16397
+ case "client_secret_basic":
16398
+ applyBasicAuth(client_id, client_secret, headers);
16399
+ return;
16400
+ case "client_secret_post":
16401
+ applyPostAuth(client_id, client_secret, params);
16402
+ return;
16403
+ case "none":
16404
+ applyPublicAuth(client_id, params);
16405
+ return;
16406
+ default:
16407
+ throw new Error(`Unsupported client authentication method: ${method}`);
16408
+ }
16409
+ }
16410
+ function applyBasicAuth(clientId, clientSecret, headers) {
16411
+ if (!clientSecret) {
16412
+ throw new Error("client_secret_basic authentication requires a client_secret");
16413
+ }
16414
+ const credentials = btoa(`${clientId}:${clientSecret}`);
16415
+ headers.set("Authorization", `Basic ${credentials}`);
16416
+ }
16417
+ function applyPostAuth(clientId, clientSecret, params) {
16418
+ params.set("client_id", clientId);
16419
+ if (clientSecret) {
16420
+ params.set("client_secret", clientSecret);
16421
+ }
16422
+ }
16423
+ function applyPublicAuth(clientId, params) {
16424
+ params.set("client_id", clientId);
16425
+ }
16378
16426
  async function auth(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl }) {
16379
16427
  let resourceMetadata;
16380
16428
  let authorizationServerUrl = serverUrl;
@@ -16386,7 +16434,9 @@ async function auth(provider, { serverUrl, authorizationCode, scope, resourceMet
16386
16434
  } catch (_a) {
16387
16435
  }
16388
16436
  const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
16389
- const metadata = await discoverOAuthMetadata(authorizationServerUrl);
16437
+ const metadata = await discoverOAuthMetadata(serverUrl, {
16438
+ authorizationServerUrl
16439
+ });
16390
16440
  let clientInformation = await Promise.resolve(provider.clientInformation());
16391
16441
  if (!clientInformation) {
16392
16442
  if (authorizationCode !== void 0) {
@@ -16410,7 +16460,8 @@ async function auth(provider, { serverUrl, authorizationCode, scope, resourceMet
16410
16460
  authorizationCode,
16411
16461
  codeVerifier: codeVerifier2,
16412
16462
  redirectUri: provider.redirectUrl,
16413
- resource
16463
+ resource,
16464
+ addClientAuthentication: provider.addClientAuthentication
16414
16465
  });
16415
16466
  await provider.saveTokens(tokens2);
16416
16467
  return "AUTHORIZED";
@@ -16422,7 +16473,8 @@ async function auth(provider, { serverUrl, authorizationCode, scope, resourceMet
16422
16473
  metadata,
16423
16474
  clientInformation,
16424
16475
  refreshToken: tokens.refresh_token,
16425
- resource
16476
+ resource,
16477
+ addClientAuthentication: provider.addClientAuthentication
16426
16478
  });
16427
16479
  await provider.saveTokens(newTokens);
16428
16480
  return "AUTHORIZED";
@@ -16476,28 +16528,11 @@ function extractResourceMetadataUrl(res) {
16476
16528
  }
16477
16529
  }
16478
16530
  async function discoverOAuthProtectedResourceMetadata(serverUrl, opts) {
16479
- var _a;
16480
- let url;
16481
- if (opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl) {
16482
- url = new URL(opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl);
16483
- } else {
16484
- url = new URL("/.well-known/oauth-protected-resource", serverUrl);
16485
- }
16486
- let response;
16487
- try {
16488
- response = await fetch(url, {
16489
- headers: {
16490
- "MCP-Protocol-Version": (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION
16491
- }
16492
- });
16493
- } catch (error) {
16494
- if (error instanceof TypeError) {
16495
- response = await fetch(url);
16496
- } else {
16497
- throw error;
16498
- }
16499
- }
16500
- if (response.status === 404) {
16531
+ const response = await discoverMetadataWithFallback(serverUrl, "oauth-protected-resource", {
16532
+ protocolVersion: opts === null || opts === void 0 ? void 0 : opts.protocolVersion,
16533
+ metadataUrl: opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl
16534
+ });
16535
+ if (!response || response.status === 404) {
16501
16536
  throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
16502
16537
  }
16503
16538
  if (!response.ok) {
@@ -16519,8 +16554,8 @@ async function fetchWithCorsRetry(url, headers) {
16519
16554
  throw error;
16520
16555
  }
16521
16556
  }
16522
- function buildWellKnownPath(pathname) {
16523
- let wellKnownPath = `/.well-known/oauth-authorization-server${pathname}`;
16557
+ function buildWellKnownPath(wellKnownPrefix, pathname) {
16558
+ let wellKnownPath = `/.well-known/${wellKnownPrefix}${pathname}`;
16524
16559
  if (pathname.endsWith("/")) {
16525
16560
  wellKnownPath = wellKnownPath.slice(0, -1);
16526
16561
  }
@@ -16535,17 +16570,40 @@ async function tryMetadataDiscovery(url, protocolVersion) {
16535
16570
  function shouldAttemptFallback(response, pathname) {
16536
16571
  return !response || response.status === 404 && pathname !== "/";
16537
16572
  }
16538
- async function discoverOAuthMetadata(authorizationServerUrl, opts) {
16539
- var _a;
16540
- const issuer = new URL(authorizationServerUrl);
16541
- const protocolVersion = (_a = void 0) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;
16542
- const wellKnownPath = buildWellKnownPath(issuer.pathname);
16543
- const pathAwareUrl = new URL(wellKnownPath, issuer);
16544
- let response = await tryMetadataDiscovery(pathAwareUrl, protocolVersion);
16545
- if (shouldAttemptFallback(response, issuer.pathname)) {
16546
- const rootUrl = new URL("/.well-known/oauth-authorization-server", issuer);
16573
+ async function discoverMetadataWithFallback(serverUrl, wellKnownType, opts) {
16574
+ var _a, _b;
16575
+ const issuer = new URL(serverUrl);
16576
+ const protocolVersion = (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;
16577
+ let url;
16578
+ if (opts === null || opts === void 0 ? void 0 : opts.metadataUrl) {
16579
+ url = new URL(opts.metadataUrl);
16580
+ } else {
16581
+ const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
16582
+ url = new URL(wellKnownPath, (_b = opts === null || opts === void 0 ? void 0 : opts.metadataServerUrl) !== null && _b !== void 0 ? _b : issuer);
16583
+ url.search = issuer.search;
16584
+ }
16585
+ let response = await tryMetadataDiscovery(url, protocolVersion);
16586
+ if (!(opts === null || opts === void 0 ? void 0 : opts.metadataUrl) && shouldAttemptFallback(response, issuer.pathname)) {
16587
+ const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
16547
16588
  response = await tryMetadataDiscovery(rootUrl, protocolVersion);
16548
16589
  }
16590
+ return response;
16591
+ }
16592
+ async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolVersion } = {}) {
16593
+ if (typeof issuer === "string") {
16594
+ issuer = new URL(issuer);
16595
+ }
16596
+ if (!authorizationServerUrl) {
16597
+ authorizationServerUrl = issuer;
16598
+ }
16599
+ if (typeof authorizationServerUrl === "string") {
16600
+ authorizationServerUrl = new URL(authorizationServerUrl);
16601
+ }
16602
+ protocolVersion !== null && protocolVersion !== void 0 ? protocolVersion : protocolVersion = LATEST_PROTOCOL_VERSION;
16603
+ const response = await discoverMetadataWithFallback(issuer, "oauth-authorization-server", {
16604
+ protocolVersion,
16605
+ metadataServerUrl: authorizationServerUrl
16606
+ });
16549
16607
  if (!response || response.status === 404) {
16550
16608
  return void 0;
16551
16609
  }
@@ -16588,35 +16646,35 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
16588
16646
  }
16589
16647
  return { authorizationUrl, codeVerifier };
16590
16648
  }
16591
- async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource }) {
16649
+ async function exchangeAuthorization(authorizationServerUrl, { metadata, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication }) {
16650
+ var _a;
16592
16651
  const grantType = "authorization_code";
16593
- let tokenUrl;
16594
- if (metadata) {
16595
- tokenUrl = new URL(metadata.token_endpoint);
16596
- if (metadata.grant_types_supported && !metadata.grant_types_supported.includes(grantType)) {
16597
- throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);
16598
- }
16599
- } else {
16600
- tokenUrl = new URL("/token", authorizationServerUrl);
16652
+ const tokenUrl = (metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint) ? new URL(metadata.token_endpoint) : new URL("/token", authorizationServerUrl);
16653
+ if ((metadata === null || metadata === void 0 ? void 0 : metadata.grant_types_supported) && !metadata.grant_types_supported.includes(grantType)) {
16654
+ throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);
16601
16655
  }
16656
+ const headers = new Headers({
16657
+ "Content-Type": "application/x-www-form-urlencoded"
16658
+ });
16602
16659
  const params = new URLSearchParams({
16603
16660
  grant_type: grantType,
16604
- client_id: clientInformation.client_id,
16605
16661
  code: authorizationCode,
16606
16662
  code_verifier: codeVerifier,
16607
16663
  redirect_uri: String(redirectUri)
16608
16664
  });
16609
- if (clientInformation.client_secret) {
16610
- params.set("client_secret", clientInformation.client_secret);
16665
+ if (addClientAuthentication) {
16666
+ addClientAuthentication(headers, params, authorizationServerUrl, metadata);
16667
+ } else {
16668
+ const supportedMethods = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];
16669
+ const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
16670
+ applyClientAuthentication(authMethod, clientInformation, headers, params);
16611
16671
  }
16612
16672
  if (resource) {
16613
16673
  params.set("resource", resource.href);
16614
16674
  }
16615
16675
  const response = await fetch(tokenUrl, {
16616
16676
  method: "POST",
16617
- headers: {
16618
- "Content-Type": "application/x-www-form-urlencoded"
16619
- },
16677
+ headers,
16620
16678
  body: params
16621
16679
  });
16622
16680
  if (!response.ok) {
@@ -16624,7 +16682,8 @@ async function exchangeAuthorization(authorizationServerUrl, { metadata, clientI
16624
16682
  }
16625
16683
  return OAuthTokensSchema.parse(await response.json());
16626
16684
  }
16627
- async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource }) {
16685
+ async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication }) {
16686
+ var _a;
16628
16687
  const grantType = "refresh_token";
16629
16688
  let tokenUrl;
16630
16689
  if (metadata) {
@@ -16635,22 +16694,26 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
16635
16694
  } else {
16636
16695
  tokenUrl = new URL("/token", authorizationServerUrl);
16637
16696
  }
16697
+ const headers = new Headers({
16698
+ "Content-Type": "application/x-www-form-urlencoded"
16699
+ });
16638
16700
  const params = new URLSearchParams({
16639
16701
  grant_type: grantType,
16640
- client_id: clientInformation.client_id,
16641
16702
  refresh_token: refreshToken
16642
16703
  });
16643
- if (clientInformation.client_secret) {
16644
- params.set("client_secret", clientInformation.client_secret);
16704
+ if (addClientAuthentication) {
16705
+ addClientAuthentication(headers, params, authorizationServerUrl, metadata);
16706
+ } else {
16707
+ const supportedMethods = (_a = metadata === null || metadata === void 0 ? void 0 : metadata.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];
16708
+ const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
16709
+ applyClientAuthentication(authMethod, clientInformation, headers, params);
16645
16710
  }
16646
16711
  if (resource) {
16647
16712
  params.set("resource", resource.href);
16648
16713
  }
16649
16714
  const response = await fetch(tokenUrl, {
16650
16715
  method: "POST",
16651
- headers: {
16652
- "Content-Type": "application/x-www-form-urlencoded"
16653
- },
16716
+ headers,
16654
16717
  body: params
16655
16718
  });
16656
16719
  if (!response.ok) {
@@ -23930,9 +23993,7 @@ class SSEClientTransport {
23930
23993
  }
23931
23994
  async _commonHeaders() {
23932
23995
  var _a;
23933
- const headers = {
23934
- ...(_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers
23935
- };
23996
+ const headers = {};
23936
23997
  if (this._authProvider) {
23937
23998
  const tokens = await this._authProvider.tokens();
23938
23999
  if (tokens) {
@@ -23942,7 +24003,7 @@ class SSEClientTransport {
23942
24003
  if (this._protocolVersion) {
23943
24004
  headers["mcp-protocol-version"] = this._protocolVersion;
23944
24005
  }
23945
- return headers;
24006
+ return new Headers({ ...headers, ...(_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers });
23946
24007
  }
23947
24008
  _startOrAuth() {
23948
24009
  var _a, _b, _c;
@@ -23952,12 +24013,10 @@ class SSEClientTransport {
23952
24013
  ...this._eventSourceInit,
23953
24014
  fetch: async (url, init) => {
23954
24015
  const headers = await this._commonHeaders();
24016
+ headers.set("Accept", "text/event-stream");
23955
24017
  const response = await fetchImpl(url, {
23956
24018
  ...init,
23957
- headers: new Headers({
23958
- ...headers,
23959
- Accept: "text/event-stream"
23960
- })
24019
+ headers
23961
24020
  });
23962
24021
  if (response.status === 401 && response.headers.has("www-authenticate")) {
23963
24022
  this._resourceMetadataUrl = extractResourceMetadataUrl(response);
@@ -24038,8 +24097,7 @@ class SSEClientTransport {
24038
24097
  throw new Error("Not connected");
24039
24098
  }
24040
24099
  try {
24041
- const commonHeaders = await this._commonHeaders();
24042
- const headers = new Headers(commonHeaders);
24100
+ const headers = await this._commonHeaders();
24043
24101
  headers.set("content-type", "application/json");
24044
24102
  const init = {
24045
24103
  ...this._requestInit,
@@ -24421,7 +24479,7 @@ const StdErrNotificationSchema = NotificationSchema.extend({
24421
24479
  ClientNotificationSchema.or(
24422
24480
  StdErrNotificationSchema
24423
24481
  ).or(ServerNotificationSchema).or(NotificationSchema);
24424
- const version$1 = "0.16.0";
24482
+ const version$1 = "0.16.1";
24425
24483
  const packageJson = {
24426
24484
  version: version$1
24427
24485
  };
@@ -35798,7 +35856,7 @@ const useTheme = () => {
35798
35856
  [theme, setThemeWithSideEffect]
35799
35857
  );
35800
35858
  };
35801
- const version = "0.16.0";
35859
+ const version = "0.16.1";
35802
35860
  var [createTooltipContext, createTooltipScope] = createContextScope("Tooltip", [
35803
35861
  createPopperScope
35804
35862
  ]);
@@ -38031,13 +38089,13 @@ const App = () => {
38031
38089
  ) });
38032
38090
  if (window.location.pathname === "/oauth/callback") {
38033
38091
  const OAuthCallback = React.lazy(
38034
- () => __vitePreload(() => import("./OAuthCallback-DMQy4ibj.js"), true ? __vite__mapDeps([0,1]) : void 0)
38092
+ () => __vitePreload(() => import("./OAuthCallback-CaDIOg8Q.js"), true ? __vite__mapDeps([0,1]) : void 0)
38035
38093
  );
38036
38094
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthCallback, { onConnect: onOAuthConnect }) });
38037
38095
  }
38038
38096
  if (window.location.pathname === "/oauth/callback/debug") {
38039
38097
  const OAuthDebugCallback = React.lazy(
38040
- () => __vitePreload(() => import("./OAuthDebugCallback-9JxBAysc.js"), true ? __vite__mapDeps([2,1]) : void 0)
38098
+ () => __vitePreload(() => import("./OAuthDebugCallback-Ccjj44Wa.js"), true ? __vite__mapDeps([2,1]) : void 0)
38041
38099
  );
38042
38100
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthDebugCallback, { onConnect: onOAuthDebugConnect }) });
38043
38101
  }
package/dist/index.html CHANGED
@@ -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-DI7JCTeu.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-CPgI0-gs.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-BwWj6LL9.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelcontextprotocol/inspector-client",
3
- "version": "0.16.0",
3
+ "version": "0.16.1",
4
4
  "description": "Client-side application for the Model Context Protocol inspector",
5
5
  "license": "MIT",
6
6
  "author": "Anthropic, PBC (https://anthropic.com)",