@ai-sdk/mcp 2.0.85 → 2.0.86
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 +9 -0
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/tool/mcp-client.ts +33 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mcp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.86",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@ai-sdk/provider": "4.0.34",
|
|
35
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
35
|
+
"@ai-sdk/provider-utils": "5.0.70",
|
|
36
36
|
"cross-spawn": "^7.0.6",
|
|
37
37
|
"pkce-challenge": "^5.0.1"
|
|
38
38
|
},
|
package/src/tool/mcp-client.ts
CHANGED
|
@@ -706,6 +706,39 @@ class DefaultMCPClient implements Omit<MCPClient, 'experimental_events'> {
|
|
|
706
706
|
error.code != null &&
|
|
707
707
|
MODERN_PROTOCOL_ERROR_CODES.includes(error.code)
|
|
708
708
|
) {
|
|
709
|
+
if (
|
|
710
|
+
error.code === -32022 &&
|
|
711
|
+
error.data != null &&
|
|
712
|
+
typeof error.data === 'object' &&
|
|
713
|
+
'supported' in error.data &&
|
|
714
|
+
Array.isArray(error.data.supported) &&
|
|
715
|
+
error.data.supported.every(version => typeof version === 'string')
|
|
716
|
+
) {
|
|
717
|
+
const supportedVersions = error.data.supported;
|
|
718
|
+
if (
|
|
719
|
+
!supportedVersions.includes(this.protocolVersion) &&
|
|
720
|
+
supportedVersions.some(
|
|
721
|
+
version =>
|
|
722
|
+
version <= LATEST_LEGACY_PROTOCOL_VERSION &&
|
|
723
|
+
SUPPORTED_PROTOCOL_VERSIONS.includes(version),
|
|
724
|
+
)
|
|
725
|
+
) {
|
|
726
|
+
throw new MCPClientError({
|
|
727
|
+
message:
|
|
728
|
+
`MCP server rejected protocol version ${this.protocolVersion} during discovery. ` +
|
|
729
|
+
`Server-supported versions: ${supportedVersions.join(', ')}. ` +
|
|
730
|
+
'The client does not automatically switch to legacy initialization after this error. ' +
|
|
731
|
+
'If this is a known legacy server, set protocolVersionDiscovery: false to use initialize.',
|
|
732
|
+
code: error.code,
|
|
733
|
+
data: error.data,
|
|
734
|
+
statusCode: error.statusCode,
|
|
735
|
+
url: error.url,
|
|
736
|
+
responseBody: error.responseBody,
|
|
737
|
+
cause: error,
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
|
|
709
742
|
throw error;
|
|
710
743
|
}
|
|
711
744
|
|