@ai-sdk/mcp 1.0.31 → 1.0.32

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
@@ -438,6 +438,13 @@ function resourceUrlFromServerUrl(url) {
438
438
  resourceURL.hash = "";
439
439
  return resourceURL;
440
440
  }
441
+ function resourceUrlStripSlash(resource) {
442
+ const href = resource.href;
443
+ if (resource.pathname === "/" && href.endsWith("/")) {
444
+ return href.slice(0, -1);
445
+ }
446
+ return href;
447
+ }
441
448
  function checkResourceAllowed({
442
449
  requestedResource,
443
450
  configuredResource
@@ -676,7 +683,10 @@ async function startAuthorization(authorizationServerUrl, {
676
683
  authorizationUrl.searchParams.append("prompt", "consent");
677
684
  }
678
685
  if (resource) {
679
- authorizationUrl.searchParams.set("resource", resource.href);
686
+ authorizationUrl.searchParams.set(
687
+ "resource",
688
+ resourceUrlStripSlash(resource)
689
+ );
680
690
  }
681
691
  return { authorizationUrl, codeVerifier };
682
692
  }
@@ -785,7 +795,7 @@ async function exchangeAuthorization(authorizationServerUrl, {
785
795
  applyClientAuthentication(authMethod, clientInformation, headers, params);
786
796
  }
787
797
  if (resource) {
788
- params.set("resource", resource.href);
798
+ params.set("resource", resourceUrlStripSlash(resource));
789
799
  }
790
800
  const response = await (fetchFn != null ? fetchFn : fetch)(tokenUrl, {
791
801
  method: "POST",
@@ -837,7 +847,7 @@ async function refreshAuthorization(authorizationServerUrl, {
837
847
  applyClientAuthentication(authMethod, clientInformation, headers, params);
838
848
  }
839
849
  if (resource) {
840
- params.set("resource", resource.href);
850
+ params.set("resource", resourceUrlStripSlash(resource));
841
851
  }
842
852
  const response = await (fetchFn != null ? fetchFn : fetch)(tokenUrl, {
843
853
  method: "POST",