@ai-sdk/mcp 1.0.30 → 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/CHANGELOG.md +21 -8
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
- package/src/tool/oauth.ts +7 -3
- package/src/util/oauth-util.ts +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 1.0.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 47c6af0: fix(mcp): strip trailing slash from OAuth resource parameter
|
|
8
|
+
|
|
9
|
+
## 1.0.31
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [0469aed]
|
|
14
|
+
- @ai-sdk/provider-utils@4.0.22
|
|
15
|
+
|
|
3
16
|
## 1.0.30
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -221,15 +234,15 @@
|
|
|
221
234
|
This change replaces
|
|
222
235
|
|
|
223
236
|
```ts
|
|
224
|
-
import { experimental_createMCPClient } from
|
|
225
|
-
import { Experimental_StdioMCPTransport } from
|
|
237
|
+
import { experimental_createMCPClient } from "ai";
|
|
238
|
+
import { Experimental_StdioMCPTransport } from "ai/mcp-stdio";
|
|
226
239
|
```
|
|
227
240
|
|
|
228
241
|
with
|
|
229
242
|
|
|
230
243
|
```ts
|
|
231
|
-
import { experimental_createMCPClient } from
|
|
232
|
-
import { Experimental_StdioMCPTransport } from
|
|
244
|
+
import { experimental_createMCPClient } from "@ai-sdk/mcp";
|
|
245
|
+
import { Experimental_StdioMCPTransport } from "@ai-sdk/mcp/mcp-stdio";
|
|
233
246
|
```
|
|
234
247
|
|
|
235
248
|
### Patch Changes
|
|
@@ -595,13 +608,13 @@
|
|
|
595
608
|
This change replaces
|
|
596
609
|
|
|
597
610
|
```ts
|
|
598
|
-
import { experimental_createMCPClient } from
|
|
599
|
-
import { Experimental_StdioMCPTransport } from
|
|
611
|
+
import { experimental_createMCPClient } from "ai";
|
|
612
|
+
import { Experimental_StdioMCPTransport } from "ai/mcp-stdio";
|
|
600
613
|
```
|
|
601
614
|
|
|
602
615
|
with
|
|
603
616
|
|
|
604
617
|
```ts
|
|
605
|
-
import { experimental_createMCPClient } from
|
|
606
|
-
import { Experimental_StdioMCPTransport } from
|
|
618
|
+
import { experimental_createMCPClient } from "@ai-sdk/mcp";
|
|
619
|
+
import { Experimental_StdioMCPTransport } from "@ai-sdk/mcp/mcp-stdio";
|
|
607
620
|
```
|
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(
|
|
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
|
|
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
|
|
880
|
+
params.set("resource", resourceUrlStripSlash(resource));
|
|
871
881
|
}
|
|
872
882
|
const response = await (fetchFn != null ? fetchFn : fetch)(tokenUrl, {
|
|
873
883
|
method: "POST",
|