@ai-sdk/mcp 2.0.56 → 2.0.57
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 +10 -0
- package/dist/index.js +36 -63
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/tool/mcp-client.ts +37 -65
- package/src/tool/oauth.ts +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mcp",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.57",
|
|
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.18",
|
|
35
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
35
|
+
"@ai-sdk/provider-utils": "5.0.47",
|
|
36
36
|
"cross-spawn": "^7.0.6",
|
|
37
37
|
"pkce-challenge": "^5.0.1"
|
|
38
38
|
},
|
package/src/tool/mcp-client.ts
CHANGED
|
@@ -100,8 +100,6 @@ function getErrorStatusCode(error: unknown): number | undefined {
|
|
|
100
100
|
) {
|
|
101
101
|
return error.statusCode;
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
return undefined;
|
|
105
103
|
}
|
|
106
104
|
|
|
107
105
|
function getStringErrorCode(error: unknown): string | undefined {
|
|
@@ -113,8 +111,6 @@ function getStringErrorCode(error: unknown): string | undefined {
|
|
|
113
111
|
) {
|
|
114
112
|
return error.code;
|
|
115
113
|
}
|
|
116
|
-
|
|
117
|
-
return undefined;
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
function isRetryableMCPToolCallError(error: unknown): boolean {
|
|
@@ -1018,22 +1014,18 @@ class DefaultMCPClient implements MCPClient {
|
|
|
1018
1014
|
arguments?: Record<string, unknown>;
|
|
1019
1015
|
options?: RequestOptions;
|
|
1020
1016
|
}): Promise<CallToolResult> {
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
});
|
|
1034
|
-
} catch (error) {
|
|
1035
|
-
throw error;
|
|
1036
|
-
}
|
|
1017
|
+
return this.callToolWithRetry({
|
|
1018
|
+
options,
|
|
1019
|
+
execute: () =>
|
|
1020
|
+
this.request({
|
|
1021
|
+
request: {
|
|
1022
|
+
method: 'tools/call',
|
|
1023
|
+
params: { name, arguments: args },
|
|
1024
|
+
},
|
|
1025
|
+
resultSchema: CallToolResultSchema,
|
|
1026
|
+
options,
|
|
1027
|
+
}),
|
|
1028
|
+
});
|
|
1037
1029
|
}
|
|
1038
1030
|
|
|
1039
1031
|
private async listResourcesInternal({
|
|
@@ -1043,15 +1035,11 @@ class DefaultMCPClient implements MCPClient {
|
|
|
1043
1035
|
params?: PaginatedRequest['params'];
|
|
1044
1036
|
options?: RequestOptions;
|
|
1045
1037
|
} = {}): Promise<ListResourcesResult> {
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
});
|
|
1052
|
-
} catch (error) {
|
|
1053
|
-
throw error;
|
|
1054
|
-
}
|
|
1038
|
+
return this.request({
|
|
1039
|
+
request: { method: 'resources/list', params },
|
|
1040
|
+
resultSchema: ListResourcesResultSchema,
|
|
1041
|
+
options,
|
|
1042
|
+
});
|
|
1055
1043
|
}
|
|
1056
1044
|
|
|
1057
1045
|
private async readResourceInternal({
|
|
@@ -1061,15 +1049,11 @@ class DefaultMCPClient implements MCPClient {
|
|
|
1061
1049
|
uri: string;
|
|
1062
1050
|
options?: RequestOptions;
|
|
1063
1051
|
}): Promise<ReadResourceResult> {
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
});
|
|
1070
|
-
} catch (error) {
|
|
1071
|
-
throw error;
|
|
1072
|
-
}
|
|
1052
|
+
return this.request({
|
|
1053
|
+
request: { method: 'resources/read', params: { uri } },
|
|
1054
|
+
resultSchema: ReadResourceResultSchema,
|
|
1055
|
+
options,
|
|
1056
|
+
});
|
|
1073
1057
|
}
|
|
1074
1058
|
|
|
1075
1059
|
private async listResourceTemplatesInternal({
|
|
@@ -1077,15 +1061,11 @@ class DefaultMCPClient implements MCPClient {
|
|
|
1077
1061
|
}: {
|
|
1078
1062
|
options?: RequestOptions;
|
|
1079
1063
|
} = {}): Promise<ListResourceTemplatesResult> {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
});
|
|
1086
|
-
} catch (error) {
|
|
1087
|
-
throw error;
|
|
1088
|
-
}
|
|
1064
|
+
return this.request({
|
|
1065
|
+
request: { method: 'resources/templates/list' },
|
|
1066
|
+
resultSchema: ListResourceTemplatesResultSchema,
|
|
1067
|
+
options,
|
|
1068
|
+
});
|
|
1089
1069
|
}
|
|
1090
1070
|
|
|
1091
1071
|
private async listPromptsInternal({
|
|
@@ -1095,15 +1075,11 @@ class DefaultMCPClient implements MCPClient {
|
|
|
1095
1075
|
params?: PaginatedRequest['params'];
|
|
1096
1076
|
options?: RequestOptions;
|
|
1097
1077
|
} = {}): Promise<ListPromptsResult> {
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
});
|
|
1104
|
-
} catch (error) {
|
|
1105
|
-
throw error;
|
|
1106
|
-
}
|
|
1078
|
+
return this.request({
|
|
1079
|
+
request: { method: 'prompts/list', params },
|
|
1080
|
+
resultSchema: ListPromptsResultSchema,
|
|
1081
|
+
options,
|
|
1082
|
+
});
|
|
1107
1083
|
}
|
|
1108
1084
|
|
|
1109
1085
|
private async getPromptInternal({
|
|
@@ -1115,15 +1091,11 @@ class DefaultMCPClient implements MCPClient {
|
|
|
1115
1091
|
args?: Record<string, unknown>;
|
|
1116
1092
|
options?: RequestOptions;
|
|
1117
1093
|
}): Promise<GetPromptResult> {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
});
|
|
1124
|
-
} catch (error) {
|
|
1125
|
-
throw error;
|
|
1126
|
-
}
|
|
1094
|
+
return this.request({
|
|
1095
|
+
request: { method: 'prompts/get', params: { name, arguments: args } },
|
|
1096
|
+
resultSchema: GetPromptResultSchema,
|
|
1097
|
+
options,
|
|
1098
|
+
});
|
|
1127
1099
|
}
|
|
1128
1100
|
|
|
1129
1101
|
private async completeInternal({
|