@ai-sdk/mcp 2.0.62 → 2.0.64

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.
@@ -1,141 +1,146 @@
1
- import { IOType } from 'node:child_process';
2
- import { Stream } from 'node:stream';
3
- import { z } from 'zod/v4';
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
- jsonrpc: z.ZodLiteral<"2.0">;
7
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
8
- method: z.ZodString;
9
- params: z.ZodOptional<z.ZodObject<{
10
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
11
- }, z.core.$loose>>;
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
- jsonrpc: z.ZodLiteral<"2.0">;
14
- method: z.ZodString;
15
- params: z.ZodOptional<z.ZodObject<{
16
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
17
- }, z.core.$loose>>;
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
- jsonrpc: z.ZodLiteral<"2.0">;
20
- id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
21
- result: z.ZodObject<{
22
- _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
23
- resultType: z.ZodOptional<z.ZodString>;
24
- }, z.core.$loose>;
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
- jsonrpc: z.ZodLiteral<"2.0">;
27
- id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
28
- error: z.ZodObject<{
29
- code: z.ZodNumber;
30
- message: z.ZodString;
31
- data: z.ZodOptional<z.ZodUnknown>;
32
- }, z.core.$strip>;
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
- * Cancels the transport operation for this message.
43
- */
44
- signal?: AbortSignal;
45
- /**
46
- * Request-specific HTTP headers produced from MCP tool parameters.
47
- */
48
- headers?: Record<string, string>;
49
- /**
50
- * Associates an outgoing message with an incoming request.
51
- */
52
- relatedRequestId?: string | number;
53
- /**
54
- * Resumes a previously interrupted request.
55
- */
56
- resumptionToken?: string;
57
- /**
58
- * Receives updated resumption tokens from transports that support them.
59
- */
60
- onresumptiontoken?: (token: string) => void;
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
- * Cancels transport cleanup.
65
- */
66
- signal?: AbortSignal;
66
+ /**
67
+ * Cancels transport cleanup.
68
+ */
69
+ signal?: AbortSignal;
67
70
  };
68
71
  interface MCPTransport {
69
- /**
70
- * Whether this transport can probe for stateless MCP protocol versions.
71
- *
72
- * Custom transports default to the legacy initialization flow unless they
73
- * explicitly opt in.
74
- */
75
- supportsProtocolVersionDiscovery?: boolean;
76
- /**
77
- * Whether this transport mirrors x-mcp-header tool parameters into request
78
- * headers.
79
- */
80
- supportsMcpToolParameterHeaders?: boolean;
81
- /**
82
- * Initialize and start the transport
83
- */
84
- start(): Promise<void>;
85
- /**
86
- * Send a JSON-RPC message through the transport
87
- * @param message The JSON-RPC message to send
88
- * @param options Optional request-scoped cancellation options
89
- */
90
- send(message: JSONRPCMessage, options?: MCPTransportSendOptions): Promise<void>;
91
- /**
92
- * Clean up and close the transport
93
- * @param options Optional cancellation options for transport cleanup
94
- */
95
- close(options?: MCPTransportCloseOptions): Promise<void>;
96
- /**
97
- * Event handler for transport closure
98
- */
99
- onclose?: () => void;
100
- /**
101
- * Event handler for transport errors
102
- */
103
- onerror?: (error: Error) => void;
104
- /**
105
- * Event handler for received messages
106
- */
107
- onmessage?: (message: JSONRPCMessage) => void;
108
- /**
109
- * The protocol version negotiated during initialization.
110
- */
111
- protocolVersion?: string;
112
- /**
113
- * Set the protocol version negotiated during initialization.
114
- */
115
- setProtocolVersion?(version: string): void;
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
- command: string;
120
- args?: string[];
121
- env?: Record<string, string>;
122
- stderr?: IOType | Stream | number;
123
- cwd?: string;
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
- readonly supportsProtocolVersionDiscovery = true;
127
- private process?;
128
- private abortController;
129
- private readBuffer;
130
- private serverParams;
131
- onclose?: () => void;
132
- onerror?: (error: unknown) => void;
133
- onmessage?: (message: JSONRPCMessage) => void;
134
- constructor(server: StdioConfig);
135
- start(): Promise<void>;
136
- private processReadBuffer;
137
- close(): Promise<void>;
138
- send(message: JSONRPCMessage): Promise<void>;
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"}