@ai-sdk/mcp 2.0.0-beta.13 → 2.0.0-beta.14

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @ai-sdk/mcp
2
2
 
3
+ ## 2.0.0-beta.14
4
+
5
+ ### Patch Changes
6
+
7
+ - 1e89d62: fix(mcp): strip trailing slash from OAuth resource parameter
8
+ - Updated dependencies [c29a26f]
9
+ - @ai-sdk/provider-utils@5.0.0-beta.10
10
+ - @ai-sdk/provider@4.0.0-beta.6
11
+
3
12
  ## 2.0.0-beta.13
4
13
 
5
14
  ### Patch Changes
package/dist/index.js CHANGED
@@ -468,6 +468,13 @@ function resourceUrlFromServerUrl(url) {
468
468
  resourceURL.hash = "";
469
469
  return resourceURL;
470
470
  }
471
+ function resourceUrlStripSlash(resource) {
472
+ const href = resource.href;
473
+ if (resource.pathname === "/" && href.endsWith("/")) {
474
+ return href.slice(0, -1);
475
+ }
476
+ return href;
477
+ }
471
478
  function checkResourceAllowed({
472
479
  requestedResource,
473
480
  configuredResource
@@ -706,7 +713,10 @@ async function startAuthorization(authorizationServerUrl, {
706
713
  authorizationUrl.searchParams.append("prompt", "consent");
707
714
  }
708
715
  if (resource) {
709
- authorizationUrl.searchParams.set("resource", resource.href);
716
+ authorizationUrl.searchParams.set(
717
+ "resource",
718
+ resourceUrlStripSlash(resource)
719
+ );
710
720
  }
711
721
  return { authorizationUrl, codeVerifier };
712
722
  }
@@ -815,7 +825,7 @@ async function exchangeAuthorization(authorizationServerUrl, {
815
825
  applyClientAuthentication(authMethod, clientInformation, headers, params);
816
826
  }
817
827
  if (resource) {
818
- params.set("resource", resource.href);
828
+ params.set("resource", resourceUrlStripSlash(resource));
819
829
  }
820
830
  const response = await (fetchFn != null ? fetchFn : fetch)(tokenUrl, {
821
831
  method: "POST",
@@ -867,7 +877,7 @@ async function refreshAuthorization(authorizationServerUrl, {
867
877
  applyClientAuthentication(authMethod, clientInformation, headers, params);
868
878
  }
869
879
  if (resource) {
870
- params.set("resource", resource.href);
880
+ params.set("resource", resourceUrlStripSlash(resource));
871
881
  }
872
882
  const response = await (fetchFn != null ? fetchFn : fetch)(tokenUrl, {
873
883
  method: "POST",