@ai-sdk/mcp 2.0.0-beta.9 → 2.0.0-canary.39
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 +253 -8
- package/dist/index.d.ts +27 -1
- package/dist/index.js +297 -282
- package/dist/index.js.map +1 -1
- package/dist/mcp-stdio/index.js +149 -170
- package/dist/mcp-stdio/index.js.map +1 -1
- package/package.json +14 -15
- package/src/index.ts +1 -0
- package/src/tool/json-rpc-message.ts +7 -0
- package/src/tool/mcp-client.ts +71 -33
- package/src/tool/mcp-http-transport.ts +19 -8
- package/src/tool/mcp-sse-transport.ts +17 -10
- package/src/tool/mcp-stdio/create-child-process.ts +2 -2
- package/src/tool/mcp-stdio/mcp-stdio-transport.ts +17 -14
- package/src/tool/mcp-transport.ts +10 -2
- package/src/tool/mock-mcp-transport.ts +6 -8
- package/src/tool/oauth.ts +17 -12
- package/src/tool/types.ts +4 -2
- package/src/util/oauth-util.ts +13 -0
- package/dist/index.d.mts +0 -516
- package/dist/index.mjs +0 -2137
- package/dist/index.mjs.map +0 -1
- package/dist/mcp-stdio/index.d.mts +0 -89
- package/dist/mcp-stdio/index.mjs +0 -426
- package/dist/mcp-stdio/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,250 @@
|
|
|
1
1
|
# @ai-sdk/mcp
|
|
2
2
|
|
|
3
|
+
## 2.0.0-canary.39
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5463d0d: feat(provider): align tool result output content file part types with top-level message file part types
|
|
8
|
+
- Updated dependencies [5463d0d]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.0-canary.32
|
|
10
|
+
- @ai-sdk/provider@4.0.0-canary.16
|
|
11
|
+
|
|
12
|
+
## 2.0.0-canary.38
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 0c4c275: trigger initial canary release
|
|
17
|
+
- Updated dependencies [0c4c275]
|
|
18
|
+
- @ai-sdk/provider-utils@5.0.0-canary.31
|
|
19
|
+
- @ai-sdk/provider@4.0.0-canary.15
|
|
20
|
+
|
|
21
|
+
## 2.0.0-beta.37
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 08d2129: feat(mcp): propagate the server name through dynamic tool parts
|
|
26
|
+
- Updated dependencies [08d2129]
|
|
27
|
+
- @ai-sdk/provider-utils@5.0.0-beta.30
|
|
28
|
+
|
|
29
|
+
## 2.0.0-beta.36
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
34
|
+
- Updated dependencies [9bd6512]
|
|
35
|
+
- Updated dependencies [258c093]
|
|
36
|
+
- Updated dependencies [b6783da]
|
|
37
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
38
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
39
|
+
|
|
40
|
+
## 2.0.0-beta.35
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
45
|
+
- Updated dependencies [9f0e36c]
|
|
46
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
47
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
48
|
+
|
|
49
|
+
## 2.0.0-beta.34
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 93afb28: feat(mcp): expose server instructions to be accessible through client
|
|
54
|
+
- 9b0bc8a: fix(mcp): prevent prototype pollution by using secureJsonParse
|
|
55
|
+
- Updated dependencies [785fe16]
|
|
56
|
+
- Updated dependencies [67df0a0]
|
|
57
|
+
- Updated dependencies [befb78c]
|
|
58
|
+
- Updated dependencies [0458559]
|
|
59
|
+
- Updated dependencies [5852c0a]
|
|
60
|
+
- Updated dependencies [fc92055]
|
|
61
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
62
|
+
|
|
63
|
+
## 2.0.0-beta.33
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [2e98477]
|
|
68
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
69
|
+
|
|
70
|
+
## 2.0.0-beta.32
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [eea8d98]
|
|
75
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
76
|
+
|
|
77
|
+
## 2.0.0-beta.31
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- Updated dependencies [f807e45]
|
|
82
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
83
|
+
|
|
84
|
+
## 2.0.0-beta.30
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- Updated dependencies [350ea38]
|
|
89
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
90
|
+
|
|
91
|
+
## 2.0.0-beta.29
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [083947b]
|
|
96
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
97
|
+
|
|
98
|
+
## 2.0.0-beta.28
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [add1126]
|
|
103
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
104
|
+
|
|
105
|
+
## 2.0.0-beta.27
|
|
106
|
+
|
|
107
|
+
### Patch Changes
|
|
108
|
+
|
|
109
|
+
- ff5eba1: feat: roll `image-*` tool output types into their equivalent `file-*` types
|
|
110
|
+
- Updated dependencies [b3976a2]
|
|
111
|
+
- Updated dependencies [ff5eba1]
|
|
112
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
113
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
114
|
+
|
|
115
|
+
## 2.0.0-beta.26
|
|
116
|
+
|
|
117
|
+
### Major Changes
|
|
118
|
+
|
|
119
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies [ef992f8]
|
|
124
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
125
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
126
|
+
|
|
127
|
+
## 2.0.0-beta.25
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
132
|
+
- Updated dependencies [90e2d8a]
|
|
133
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
134
|
+
|
|
135
|
+
## 2.0.0-beta.24
|
|
136
|
+
|
|
137
|
+
### Patch Changes
|
|
138
|
+
|
|
139
|
+
- Updated dependencies [3ae1786]
|
|
140
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
141
|
+
|
|
142
|
+
## 2.0.0-beta.23
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- a98bf66: feat(mcp): surface 'serverInfo' exposed from the MCP server
|
|
147
|
+
|
|
148
|
+
## 2.0.0-beta.22
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [176466a]
|
|
153
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
154
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
155
|
+
|
|
156
|
+
## 2.0.0-beta.21
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- Updated dependencies [e311194]
|
|
161
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
162
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
163
|
+
|
|
164
|
+
## 2.0.0-beta.20
|
|
165
|
+
|
|
166
|
+
### Patch Changes
|
|
167
|
+
|
|
168
|
+
- Updated dependencies [34bd95d]
|
|
169
|
+
- Updated dependencies [008271d]
|
|
170
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
171
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
172
|
+
|
|
173
|
+
## 2.0.0-beta.19
|
|
174
|
+
|
|
175
|
+
### Patch Changes
|
|
176
|
+
|
|
177
|
+
- Updated dependencies [b0c2869]
|
|
178
|
+
- Updated dependencies [7e26e81]
|
|
179
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
180
|
+
|
|
181
|
+
## 2.0.0-beta.18
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- e3ea484: fix(mcp): bypass outputSchema validation when tool returns isError
|
|
186
|
+
|
|
187
|
+
## 2.0.0-beta.17
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- a00d1d3: feat(mcp): allow custom fetch for HTTP and SSE transports
|
|
192
|
+
|
|
193
|
+
## 2.0.0-beta.16
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- Updated dependencies [46d1149]
|
|
198
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
199
|
+
|
|
200
|
+
## 2.0.0-beta.15
|
|
201
|
+
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- Updated dependencies [6fd51c0]
|
|
205
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
206
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
207
|
+
|
|
208
|
+
## 2.0.0-beta.14
|
|
209
|
+
|
|
210
|
+
### Patch Changes
|
|
211
|
+
|
|
212
|
+
- 1e89d62: fix(mcp): strip trailing slash from OAuth resource parameter
|
|
213
|
+
- Updated dependencies [c29a26f]
|
|
214
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
215
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
216
|
+
|
|
217
|
+
## 2.0.0-beta.13
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- Updated dependencies [2e17091]
|
|
222
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
223
|
+
|
|
224
|
+
## 2.0.0-beta.12
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- Updated dependencies [986c6fd]
|
|
229
|
+
- Updated dependencies [493295c]
|
|
230
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
231
|
+
|
|
232
|
+
## 2.0.0-beta.11
|
|
233
|
+
|
|
234
|
+
### Patch Changes
|
|
235
|
+
|
|
236
|
+
- Updated dependencies [1f509d4]
|
|
237
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
238
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
239
|
+
|
|
240
|
+
## 2.0.0-beta.10
|
|
241
|
+
|
|
242
|
+
### Patch Changes
|
|
243
|
+
|
|
244
|
+
- Updated dependencies [3887c70]
|
|
245
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
246
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
247
|
+
|
|
3
248
|
## 2.0.0-beta.9
|
|
4
249
|
|
|
5
250
|
### Patch Changes
|
|
@@ -262,15 +507,15 @@
|
|
|
262
507
|
This change replaces
|
|
263
508
|
|
|
264
509
|
```ts
|
|
265
|
-
import { experimental_createMCPClient } from
|
|
266
|
-
import { Experimental_StdioMCPTransport } from
|
|
510
|
+
import { experimental_createMCPClient } from "ai";
|
|
511
|
+
import { Experimental_StdioMCPTransport } from "ai/mcp-stdio";
|
|
267
512
|
```
|
|
268
513
|
|
|
269
514
|
with
|
|
270
515
|
|
|
271
516
|
```ts
|
|
272
|
-
import { experimental_createMCPClient } from
|
|
273
|
-
import { Experimental_StdioMCPTransport } from
|
|
517
|
+
import { experimental_createMCPClient } from "@ai-sdk/mcp";
|
|
518
|
+
import { Experimental_StdioMCPTransport } from "@ai-sdk/mcp/mcp-stdio";
|
|
274
519
|
```
|
|
275
520
|
|
|
276
521
|
### Patch Changes
|
|
@@ -636,13 +881,13 @@
|
|
|
636
881
|
This change replaces
|
|
637
882
|
|
|
638
883
|
```ts
|
|
639
|
-
import { experimental_createMCPClient } from
|
|
640
|
-
import { Experimental_StdioMCPTransport } from
|
|
884
|
+
import { experimental_createMCPClient } from "ai";
|
|
885
|
+
import { Experimental_StdioMCPTransport } from "ai/mcp-stdio";
|
|
641
886
|
```
|
|
642
887
|
|
|
643
888
|
with
|
|
644
889
|
|
|
645
890
|
```ts
|
|
646
|
-
import { experimental_createMCPClient } from
|
|
647
|
-
import { Experimental_StdioMCPTransport } from
|
|
891
|
+
import { experimental_createMCPClient } from "@ai-sdk/mcp";
|
|
892
|
+
import { Experimental_StdioMCPTransport } from "@ai-sdk/mcp/mcp-stdio";
|
|
648
893
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -250,6 +250,12 @@ type MCPTransportConfig = {
|
|
|
250
250
|
* @default 'error'
|
|
251
251
|
*/
|
|
252
252
|
redirect?: 'follow' | 'error';
|
|
253
|
+
/**
|
|
254
|
+
* Optional custom fetch implementation to use for HTTP requests.
|
|
255
|
+
* Useful for runtimes that need a request-local fetch.
|
|
256
|
+
* @default globalThis.fetch
|
|
257
|
+
*/
|
|
258
|
+
fetch?: FetchFunction;
|
|
253
259
|
};
|
|
254
260
|
|
|
255
261
|
/** MCP tool metadata - keys should follow MCP _meta key format specification */
|
|
@@ -274,6 +280,12 @@ type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS e
|
|
|
274
280
|
inputSchema: FlexibleSchema<infer INPUT>;
|
|
275
281
|
} ? McpToolBase<INPUT, CallToolResult> : never;
|
|
276
282
|
} : Record<string, McpToolBase<unknown, CallToolResult>>;
|
|
283
|
+
declare const ClientOrServerImplementationSchema: z.ZodObject<{
|
|
284
|
+
name: z.ZodString;
|
|
285
|
+
version: z.ZodString;
|
|
286
|
+
title: z.ZodOptional<z.ZodString>;
|
|
287
|
+
}, z.core.$loose>;
|
|
288
|
+
type Configuration = z.infer<typeof ClientOrServerImplementationSchema>;
|
|
277
289
|
declare const BaseParamsSchema: z.ZodObject<{
|
|
278
290
|
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
279
291
|
}, z.core.$loose>;
|
|
@@ -473,6 +485,20 @@ interface MCPClientConfig {
|
|
|
473
485
|
}
|
|
474
486
|
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
475
487
|
interface MCPClient {
|
|
488
|
+
/**
|
|
489
|
+
* Information about the connected MCP server, as reported during initialization.
|
|
490
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation
|
|
491
|
+
*/
|
|
492
|
+
readonly serverInfo: Configuration;
|
|
493
|
+
/**
|
|
494
|
+
* Optional instructions provided by the server during the initialize handshake.
|
|
495
|
+
*
|
|
496
|
+
* These describe how to use the server and its features, and can be used by clients
|
|
497
|
+
* to improve LLM interactions (e.g. by including them in the system prompt).
|
|
498
|
+
*
|
|
499
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/schema#initializeresult
|
|
500
|
+
*/
|
|
501
|
+
readonly instructions?: string;
|
|
476
502
|
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
|
|
477
503
|
schemas?: TOOL_SCHEMAS;
|
|
478
504
|
}): Promise<McpToolSet<TOOL_SCHEMAS>>;
|
|
@@ -513,4 +539,4 @@ interface MCPClient {
|
|
|
513
539
|
close: () => Promise<void>;
|
|
514
540
|
}
|
|
515
541
|
|
|
516
|
-
export { type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPClient, type ClientCapabilities as MCPClientCapabilities, type MCPClientConfig, type MCPTransport, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, createMCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient };
|
|
542
|
+
export { type Configuration, type ElicitResult, ElicitResultSchema, type ElicitationRequest, ElicitationRequestSchema, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPClient, type ClientCapabilities as MCPClientCapabilities, type MCPClientConfig, type MCPTransport, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, UnauthorizedError, auth, createMCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig as experimental_MCPClientConfig, createMCPClient as experimental_createMCPClient };
|