@ai-sdk/mcp 2.0.61 → 2.0.63
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 +17 -0
- package/dist/index.d.ts +806 -800
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2637 -3357
- package/dist/index.js.map +1 -1
- package/dist/mcp-stdio/index.d.ts +125 -120
- package/dist/mcp-stdio/index.d.ts.map +1 -0
- package/dist/mcp-stdio/index.js +395 -473
- package/dist/mcp-stdio/index.js.map +1 -1
- package/package.json +8 -8
- package/src/tool/mcp-client.ts +2 -1
|
@@ -1,141 +1,146 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import "@ai-sdk/provider-utils";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
import { AISDKError } from "@ai-sdk/provider";
|
|
4
|
+
import { IOType } from "node:child_process";
|
|
5
|
+
import { Stream } from "node:stream";
|
|
6
|
+
//#region src/tool/json-rpc-message.d.ts
|
|
5
7
|
declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
9
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
10
|
+
method: z.ZodString;
|
|
11
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
12
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
13
|
+
}, z.core.$loose>>;
|
|
12
14
|
}, z.core.$strict>, z.ZodObject<{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
16
|
+
method: z.ZodString;
|
|
17
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
19
|
+
}, z.core.$loose>>;
|
|
18
20
|
}, z.core.$strict>, z.ZodObject<{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
22
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
23
|
+
result: z.ZodObject<{
|
|
24
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
25
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$loose>;
|
|
25
27
|
}, z.core.$strict>, z.ZodObject<{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
29
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
30
|
+
error: z.ZodObject<{
|
|
31
|
+
code: z.ZodNumber;
|
|
32
|
+
message: z.ZodString;
|
|
33
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
34
|
+
}, z.core.$strip>;
|
|
33
35
|
}, z.core.$strict>]>;
|
|
34
36
|
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
|
35
|
-
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/tool/mcp-transport.d.ts
|
|
36
39
|
/**
|
|
37
40
|
* Transport interface for MCP (Model Context Protocol) communication.
|
|
38
41
|
* Maps to the `Transport` interface in the MCP spec.
|
|
39
42
|
*/
|
|
40
43
|
type MCPTransportSendOptions = {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Cancels the transport operation for this message.
|
|
46
|
+
*/
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
/**
|
|
49
|
+
* Request-specific HTTP headers produced from MCP tool parameters.
|
|
50
|
+
*/
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
/**
|
|
53
|
+
* Associates an outgoing message with an incoming request.
|
|
54
|
+
*/
|
|
55
|
+
relatedRequestId?: string | number;
|
|
56
|
+
/**
|
|
57
|
+
* Resumes a previously interrupted request.
|
|
58
|
+
*/
|
|
59
|
+
resumptionToken?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Receives updated resumption tokens from transports that support them.
|
|
62
|
+
*/
|
|
63
|
+
onresumptiontoken?: (token: string) => void;
|
|
61
64
|
};
|
|
62
65
|
type MCPTransportCloseOptions = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Cancels transport cleanup.
|
|
68
|
+
*/
|
|
69
|
+
signal?: AbortSignal;
|
|
67
70
|
};
|
|
68
71
|
interface MCPTransport {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Whether this transport can probe for stateless MCP protocol versions.
|
|
74
|
+
*
|
|
75
|
+
* Custom transports default to the legacy initialization flow unless they
|
|
76
|
+
* explicitly opt in.
|
|
77
|
+
*/
|
|
78
|
+
supportsProtocolVersionDiscovery?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Whether this transport mirrors x-mcp-header tool parameters into request
|
|
81
|
+
* headers.
|
|
82
|
+
*/
|
|
83
|
+
supportsMcpToolParameterHeaders?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Initialize and start the transport
|
|
86
|
+
*/
|
|
87
|
+
start(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Send a JSON-RPC message through the transport
|
|
90
|
+
* @param message The JSON-RPC message to send
|
|
91
|
+
* @param options Optional request-scoped cancellation options
|
|
92
|
+
*/
|
|
93
|
+
send(message: JSONRPCMessage, options?: MCPTransportSendOptions): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Clean up and close the transport
|
|
96
|
+
* @param options Optional cancellation options for transport cleanup
|
|
97
|
+
*/
|
|
98
|
+
close(options?: MCPTransportCloseOptions): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Event handler for transport closure
|
|
101
|
+
*/
|
|
102
|
+
onclose?: () => void;
|
|
103
|
+
/**
|
|
104
|
+
* Event handler for transport errors
|
|
105
|
+
*/
|
|
106
|
+
onerror?: (error: Error) => void;
|
|
107
|
+
/**
|
|
108
|
+
* Event handler for received messages
|
|
109
|
+
*/
|
|
110
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
111
|
+
/**
|
|
112
|
+
* The protocol version negotiated during initialization.
|
|
113
|
+
*/
|
|
114
|
+
protocolVersion?: string;
|
|
115
|
+
/**
|
|
116
|
+
* Set the protocol version negotiated during initialization.
|
|
117
|
+
*/
|
|
118
|
+
setProtocolVersion?(version: string): void;
|
|
116
119
|
}
|
|
117
|
-
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/tool/mcp-stdio/mcp-stdio-transport.d.ts
|
|
118
122
|
interface StdioConfig {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
command: string;
|
|
124
|
+
args?: string[];
|
|
125
|
+
env?: Record<string, string>;
|
|
126
|
+
stderr?: IOType | Stream | number;
|
|
127
|
+
cwd?: string;
|
|
124
128
|
}
|
|
125
129
|
declare class StdioMCPTransport implements MCPTransport {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
130
|
+
readonly supportsProtocolVersionDiscovery = true;
|
|
131
|
+
private process?;
|
|
132
|
+
private abortController;
|
|
133
|
+
private readBuffer;
|
|
134
|
+
private serverParams;
|
|
135
|
+
onclose?: () => void;
|
|
136
|
+
onerror?: (error: unknown) => void;
|
|
137
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
138
|
+
constructor(server: StdioConfig);
|
|
139
|
+
start(): Promise<void>;
|
|
140
|
+
private processReadBuffer;
|
|
141
|
+
close(): Promise<void>;
|
|
142
|
+
send(message: JSONRPCMessage): Promise<void>;
|
|
139
143
|
}
|
|
140
|
-
|
|
144
|
+
//#endregion
|
|
141
145
|
export { StdioMCPTransport as Experimental_StdioMCPTransport, type StdioConfig };
|
|
146
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/tool/json-rpc-message.ts","../../src/tool/mcp-transport.ts","../../src/tool/mcp-stdio/mcp-stdio-transport.ts"],"mappings":";;;;;;cAsDa,sBAAoB,EAAA,mBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK/B,EAAA,KAAA;KAEU,iBAAiB,EAAE,aAAa;;;;;;;KCjDhC;;;;EAIV,SAAS;;;;EAKT,UAAU;;;;EAKV;;;;EAKA;;;;EAKA,qBAAqB;;KAGX;;;;EAIV,SAAS;;UAGM;;;;;;;EAOf;;;;;EAMA;;;;EAKA,SAAS;;;;;;EAOT,KACE,SAAS,gBACT,UAAU,0BACT;;;;;EAMH,MAAM,UAAU,2BAA2B;;;;EAK3C;;;;EAKA,WAAW,OAAO;;;;EAKlB,aAAa,SAAS;;;;EAKtB;;;;EAKA,oBAAoB;;;;UClGL;EACf;EACA;EACA,MAAM;EACN,SAAS,SAAS;EAClB;;cAGW,6BAA6B;WAC/B;UACD;UACA;UACA;UACA;EAER;EACA,WAAW;EACX,aAAa,SAAS;EAEV,YAAA,QAAQ;EAId,SAAS;UAsDD;EAgBR,SAAS;EAMf,KAAK,SAAS,iBAAiB"}
|