@ai-sdk/mcp 1.0.91 → 1.0.93

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/index.mjs CHANGED
@@ -835,8 +835,10 @@ function buildDiscoveryUrls(authorizationServerUrl) {
835
835
  type: "oidc",
836
836
  expectedIssuer: pathIssuer
837
837
  });
838
+ const oidcDiscoveryUrl = new URL(url.origin);
839
+ oidcDiscoveryUrl.pathname = `${pathname}/.well-known/openid-configuration`;
838
840
  urlsToTry.push({
839
- url: new URL(`${pathname}/.well-known/openid-configuration`, url.origin),
841
+ url: oidcDiscoveryUrl,
840
842
  type: "oidc",
841
843
  expectedIssuer: pathIssuer
842
844
  });
@@ -857,7 +859,13 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, {
857
859
  } = {}) {
858
860
  var _a3;
859
861
  const headers = { "MCP-Protocol-Version": protocolVersion };
862
+ const authorizationServerOrigin = new URL(authorizationServerUrl).origin;
860
863
  const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
864
+ if (urlsToTry.some(({ url }) => url.origin !== authorizationServerOrigin)) {
865
+ throw new MCPClientOAuthError({
866
+ message: "OAuth discovery URL changed authorization-server origin"
867
+ });
868
+ }
861
869
  for (const { url: endpointUrl, type, expectedIssuer } of urlsToTry) {
862
870
  const response = await fetchWithCorsRetry(
863
871
  endpointUrl,