@ai-sdk/mcp 2.0.62 → 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 +9 -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/dist/index.d.ts
CHANGED
|
@@ -1,102 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { JSONObject } from
|
|
4
|
-
|
|
1
|
+
import { FetchFunction, FlexibleSchema, Tool } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
import { AISDKError, JSONObject } from "@ai-sdk/provider";
|
|
4
|
+
//#region src/tool/json-rpc-message.d.ts
|
|
5
5
|
declare const JSONRPCRequestSchema: z.ZodObject<{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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>>;
|
|
12
12
|
}, z.core.$strict>;
|
|
13
13
|
type JSONRPCRequest = z.infer<typeof JSONRPCRequestSchema>;
|
|
14
14
|
declare const JSONRPCResponseSchema: z.ZodObject<{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
16
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
17
|
+
result: z.ZodObject<{
|
|
18
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
19
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$loose>;
|
|
21
21
|
}, z.core.$strict>;
|
|
22
22
|
type JSONRPCResponse = z.infer<typeof JSONRPCResponseSchema>;
|
|
23
23
|
declare const JSONRPCErrorSchema: z.ZodObject<{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
25
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
26
|
+
error: z.ZodObject<{
|
|
27
|
+
code: z.ZodNumber;
|
|
28
|
+
message: z.ZodString;
|
|
29
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
31
|
}, z.core.$strict>;
|
|
32
32
|
type JSONRPCError = z.infer<typeof JSONRPCErrorSchema>;
|
|
33
33
|
declare const JSONRPCNotificationSchema: z.ZodObject<{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
35
|
+
method: z.ZodString;
|
|
36
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
38
|
+
}, z.core.$loose>>;
|
|
39
39
|
}, z.core.$strict>;
|
|
40
40
|
type JSONRPCNotification = z.infer<typeof JSONRPCNotificationSchema>;
|
|
41
41
|
declare const JSONRPCMessageSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
42
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
43
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
44
|
+
method: z.ZodString;
|
|
45
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
47
|
+
}, z.core.$loose>>;
|
|
48
48
|
}, z.core.$strict>, z.ZodObject<{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
50
|
+
method: z.ZodString;
|
|
51
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
53
|
+
}, z.core.$loose>>;
|
|
54
54
|
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
56
|
+
id: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
57
|
+
result: z.ZodObject<{
|
|
58
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
59
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$loose>;
|
|
61
61
|
}, z.core.$strict>, z.ZodObject<{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
63
|
+
id: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
|
|
64
|
+
error: z.ZodObject<{
|
|
65
|
+
code: z.ZodNumber;
|
|
66
|
+
message: z.ZodString;
|
|
67
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
69
|
}, z.core.$strict>]>;
|
|
70
70
|
type JSONRPCMessage = z.infer<typeof JSONRPCMessageSchema>;
|
|
71
|
-
declare function validateJSONRPCMessage(message: unknown): JSONRPCMessage;
|
|
72
|
-
|
|
71
|
+
export declare function validateJSONRPCMessage(message: unknown): JSONRPCMessage;
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/tool/oauth-types.d.ts
|
|
73
74
|
/**
|
|
74
75
|
* OAuth 2.1 token response
|
|
75
76
|
*/
|
|
76
77
|
declare const OAuthTokensSchema: z.ZodObject<{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
access_token: z.ZodString;
|
|
79
|
+
id_token: z.ZodOptional<z.ZodString>;
|
|
80
|
+
token_type: z.ZodString;
|
|
81
|
+
expires_in: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
83
|
+
refresh_token: z.ZodOptional<z.ZodString>;
|
|
84
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
85
|
+
authorization_server: z.ZodOptional<z.ZodString>;
|
|
86
|
+
token_endpoint: z.ZodOptional<z.ZodString>;
|
|
86
87
|
}, z.core.$strip>;
|
|
87
88
|
declare const OAuthMetadataSchema: z.ZodObject<{
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
issuer: z.ZodString;
|
|
90
|
+
authorization_endpoint: z.ZodString;
|
|
91
|
+
token_endpoint: z.ZodString;
|
|
92
|
+
registration_endpoint: z.ZodOptional<z.ZodString>;
|
|
93
|
+
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
95
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
96
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
97
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
98
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
100
|
+
token_endpoint_auth_signing_alg_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
100
101
|
}, z.core.$loose>;
|
|
101
102
|
/**
|
|
102
103
|
* OpenID Connect Discovery metadata that may include OAuth 2.0 fields
|
|
@@ -104,50 +105,50 @@ declare const OAuthMetadataSchema: z.ZodObject<{
|
|
|
104
105
|
* return a mix of OpenID Connect and OAuth 2.0 metadata fields
|
|
105
106
|
*/
|
|
106
107
|
declare const OpenIdProviderDiscoveryMetadataSchema: z.ZodObject<{
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
108
|
+
issuer: z.ZodString;
|
|
109
|
+
authorization_endpoint: z.ZodString;
|
|
110
|
+
token_endpoint: z.ZodString;
|
|
111
|
+
userinfo_endpoint: z.ZodOptional<z.ZodString>;
|
|
112
|
+
jwks_uri: z.ZodString;
|
|
113
|
+
registration_endpoint: z.ZodOptional<z.ZodString>;
|
|
114
|
+
authorization_response_iss_parameter_supported: z.ZodOptional<z.ZodBoolean>;
|
|
115
|
+
client_id_metadata_document_supported: z.ZodOptional<z.ZodBoolean>;
|
|
116
|
+
scopes_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
117
|
+
response_types_supported: z.ZodArray<z.ZodString>;
|
|
118
|
+
grant_types_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
119
|
+
subject_types_supported: z.ZodArray<z.ZodString>;
|
|
120
|
+
id_token_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
121
|
+
claims_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
122
|
+
token_endpoint_auth_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
123
|
+
code_challenge_methods_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
123
124
|
}, z.core.$loose>;
|
|
124
125
|
declare const OAuthClientInformationSchema: z.ZodObject<{
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
client_id: z.ZodString;
|
|
127
|
+
client_secret: z.ZodOptional<z.ZodString>;
|
|
128
|
+
client_id_issued_at: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
client_secret_expires_at: z.ZodOptional<z.ZodNumber>;
|
|
130
|
+
issuer: z.ZodOptional<z.ZodString>;
|
|
131
|
+
authorization_server: z.ZodOptional<z.ZodString>;
|
|
132
|
+
token_endpoint: z.ZodOptional<z.ZodString>;
|
|
132
133
|
}, z.core.$strip>;
|
|
133
134
|
declare const OAuthClientMetadataSchema: z.ZodObject<{
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
135
|
+
redirect_uris: z.ZodArray<z.ZodString>;
|
|
136
|
+
application_type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"native">, z.ZodLiteral<"web">]>>;
|
|
137
|
+
token_endpoint_auth_method: z.ZodOptional<z.ZodString>;
|
|
138
|
+
grant_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
139
|
+
response_types: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
140
|
+
client_name: z.ZodOptional<z.ZodString>;
|
|
141
|
+
client_uri: z.ZodOptional<z.ZodString>;
|
|
142
|
+
logo_uri: z.ZodOptional<z.ZodString>;
|
|
143
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
144
|
+
contacts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
145
|
+
tos_uri: z.ZodOptional<z.ZodString>;
|
|
146
|
+
policy_uri: z.ZodOptional<z.ZodString>;
|
|
147
|
+
jwks_uri: z.ZodOptional<z.ZodString>;
|
|
148
|
+
jwks: z.ZodOptional<z.ZodAny>;
|
|
149
|
+
software_id: z.ZodOptional<z.ZodString>;
|
|
150
|
+
software_version: z.ZodOptional<z.ZodString>;
|
|
151
|
+
software_statement: z.ZodOptional<z.ZodString>;
|
|
151
152
|
}, z.core.$strip>;
|
|
152
153
|
type OAuthMetadata = z.infer<typeof OAuthMetadataSchema>;
|
|
153
154
|
type OpenIdProviderDiscoveryMetadata = z.infer<typeof OpenIdProviderDiscoveryMetadataSchema>;
|
|
@@ -155,236 +156,239 @@ type OAuthTokens = z.infer<typeof OAuthTokensSchema>;
|
|
|
155
156
|
type OAuthClientInformation = z.infer<typeof OAuthClientInformationSchema>;
|
|
156
157
|
type AuthorizationServerMetadata = OAuthMetadata | OpenIdProviderDiscoveryMetadata;
|
|
157
158
|
type OAuthClientMetadata = z.infer<typeof OAuthClientMetadataSchema>;
|
|
158
|
-
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/tool/oauth.d.ts
|
|
159
161
|
type AuthResult = 'AUTHORIZED' | 'REDIRECT';
|
|
160
162
|
interface OAuthAuthorizationServerInformation {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
issuer?: string;
|
|
164
|
+
authorizationServerUrl: string;
|
|
165
|
+
tokenEndpoint: string;
|
|
164
166
|
}
|
|
165
167
|
interface OAuthClientProvider {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Returns current access token if present; undefined otherwise.
|
|
170
|
+
*/
|
|
171
|
+
tokens(): OAuthTokens | undefined | Promise<OAuthTokens | undefined>;
|
|
172
|
+
saveTokens(tokens: OAuthTokens): void | Promise<void>;
|
|
173
|
+
redirectToAuthorization(authorizationUrl: URL): void | Promise<void>;
|
|
174
|
+
saveCodeVerifier(codeVerifier: string): void | Promise<void>;
|
|
175
|
+
codeVerifier(): string | Promise<string>;
|
|
176
|
+
/**
|
|
177
|
+
* Adds custom client authentication to OAuth token requests.
|
|
178
|
+
*
|
|
179
|
+
* This optional method allows implementations to customize how client credentials
|
|
180
|
+
* are included in token exchange and refresh requests. When provided, this method
|
|
181
|
+
* is called instead of the default authentication logic, giving full control over
|
|
182
|
+
* the authentication mechanism.
|
|
183
|
+
*
|
|
184
|
+
* Common use cases include:
|
|
185
|
+
* - Supporting authentication methods beyond the standard OAuth 2.0 methods
|
|
186
|
+
* - Adding custom headers for proprietary authentication schemes
|
|
187
|
+
* - Implementing client assertion-based authentication (e.g., JWT bearer tokens)
|
|
188
|
+
*
|
|
189
|
+
* @param headers - The request headers (can be modified to add authentication)
|
|
190
|
+
* @param params - The request body parameters (can be modified to add credentials)
|
|
191
|
+
* @param url - The token endpoint URL being called
|
|
192
|
+
* @param metadata - Optional OAuth metadata for the server, which may include supported authentication methods
|
|
193
|
+
*/
|
|
194
|
+
addClientAuthentication?(headers: Headers, params: URLSearchParams, url: string | URL, metadata?: AuthorizationServerMetadata): void | Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* If implemented, provides a way for the client to invalidate (e.g. delete) the specified
|
|
197
|
+
* credentials, in the case where the server has indicated that they are no longer valid.
|
|
198
|
+
* This avoids requiring the user to intervene manually.
|
|
199
|
+
*/
|
|
200
|
+
invalidateCredentials?(scope: 'all' | 'client' | 'tokens' | 'verifier'): void | Promise<void>;
|
|
201
|
+
get redirectUrl(): string | URL;
|
|
202
|
+
get clientMetadata(): OAuthClientMetadata;
|
|
203
|
+
clientInformation(): OAuthClientInformation | undefined | Promise<OAuthClientInformation | undefined>;
|
|
204
|
+
/**
|
|
205
|
+
* Returns whether the current client information was obtained through
|
|
206
|
+
* dynamic client registration.
|
|
207
|
+
*
|
|
208
|
+
* Return `true` only when the current client information was saved after a
|
|
209
|
+
* dynamic registration response. When this method is omitted or returns
|
|
210
|
+
* `false`, the client information is treated as pre-registered and is not
|
|
211
|
+
* automatically invalidated after client authentication errors.
|
|
212
|
+
*/
|
|
213
|
+
isClientInformationDynamicallyRegistered?(): boolean | Promise<boolean>;
|
|
214
|
+
saveClientInformation?(clientInformation: OAuthClientInformation): void | Promise<void>;
|
|
215
|
+
authorizationServerInformation?(): OAuthAuthorizationServerInformation | undefined | Promise<OAuthAuthorizationServerInformation | undefined>;
|
|
216
|
+
saveAuthorizationServerInformation?(authorizationServerInformation: OAuthAuthorizationServerInformation): void | Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Validates an authorization server URL discovered from MCP protected resource
|
|
219
|
+
* metadata before the client fetches its OAuth metadata.
|
|
220
|
+
*/
|
|
221
|
+
validateAuthorizationServerURL?(serverUrl: string | URL, authorizationServerUrl: string | URL): void | Promise<void>;
|
|
222
|
+
state?(): string | Promise<string>;
|
|
223
|
+
saveState?(state: string): void | Promise<void>;
|
|
224
|
+
storedState?(): string | undefined | Promise<string | undefined>;
|
|
225
|
+
validateResourceURL?(serverUrl: string | URL, resource?: string): Promise<URL | undefined>;
|
|
224
226
|
}
|
|
225
|
-
declare class UnauthorizedError extends Error {
|
|
226
|
-
|
|
227
|
+
export declare class UnauthorizedError extends Error {
|
|
228
|
+
constructor(message?: string);
|
|
227
229
|
}
|
|
228
|
-
declare function auth(provider: OAuthClientProvider, options: {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
230
|
+
export declare function auth(provider: OAuthClientProvider, options: {
|
|
231
|
+
serverUrl: string | URL;
|
|
232
|
+
authorizationCode?: string;
|
|
233
|
+
callbackState?: string;
|
|
234
|
+
/**
|
|
235
|
+
* Value of the `iss` parameter from the authorization response.
|
|
236
|
+
*/
|
|
237
|
+
callbackIssuer?: string;
|
|
238
|
+
scope?: string;
|
|
239
|
+
resourceMetadataUrl?: URL;
|
|
240
|
+
fetchFn?: FetchFunction;
|
|
239
241
|
}): Promise<AuthResult>;
|
|
240
|
-
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/tool/mcp-transport.d.ts
|
|
241
244
|
/**
|
|
242
245
|
* Transport interface for MCP (Model Context Protocol) communication.
|
|
243
246
|
* Maps to the `Transport` interface in the MCP spec.
|
|
244
247
|
*/
|
|
245
248
|
type MCPTransportSendOptions = {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
249
|
+
/**
|
|
250
|
+
* Cancels the transport operation for this message.
|
|
251
|
+
*/
|
|
252
|
+
signal?: AbortSignal;
|
|
253
|
+
/**
|
|
254
|
+
* Request-specific HTTP headers produced from MCP tool parameters.
|
|
255
|
+
*/
|
|
256
|
+
headers?: Record<string, string>;
|
|
257
|
+
/**
|
|
258
|
+
* Associates an outgoing message with an incoming request.
|
|
259
|
+
*/
|
|
260
|
+
relatedRequestId?: string | number;
|
|
261
|
+
/**
|
|
262
|
+
* Resumes a previously interrupted request.
|
|
263
|
+
*/
|
|
264
|
+
resumptionToken?: string;
|
|
265
|
+
/**
|
|
266
|
+
* Receives updated resumption tokens from transports that support them.
|
|
267
|
+
*/
|
|
268
|
+
onresumptiontoken?: (token: string) => void;
|
|
266
269
|
};
|
|
267
270
|
type MCPTransportCloseOptions = {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
/**
|
|
272
|
+
* Cancels transport cleanup.
|
|
273
|
+
*/
|
|
274
|
+
signal?: AbortSignal;
|
|
272
275
|
};
|
|
273
276
|
interface MCPTransport {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Whether this transport can probe for stateless MCP protocol versions.
|
|
279
|
+
*
|
|
280
|
+
* Custom transports default to the legacy initialization flow unless they
|
|
281
|
+
* explicitly opt in.
|
|
282
|
+
*/
|
|
283
|
+
supportsProtocolVersionDiscovery?: boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Whether this transport mirrors x-mcp-header tool parameters into request
|
|
286
|
+
* headers.
|
|
287
|
+
*/
|
|
288
|
+
supportsMcpToolParameterHeaders?: boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Initialize and start the transport
|
|
291
|
+
*/
|
|
292
|
+
start(): Promise<void>;
|
|
293
|
+
/**
|
|
294
|
+
* Send a JSON-RPC message through the transport
|
|
295
|
+
* @param message The JSON-RPC message to send
|
|
296
|
+
* @param options Optional request-scoped cancellation options
|
|
297
|
+
*/
|
|
298
|
+
send(message: JSONRPCMessage, options?: MCPTransportSendOptions): Promise<void>;
|
|
299
|
+
/**
|
|
300
|
+
* Clean up and close the transport
|
|
301
|
+
* @param options Optional cancellation options for transport cleanup
|
|
302
|
+
*/
|
|
303
|
+
close(options?: MCPTransportCloseOptions): Promise<void>;
|
|
304
|
+
/**
|
|
305
|
+
* Event handler for transport closure
|
|
306
|
+
*/
|
|
307
|
+
onclose?: () => void;
|
|
308
|
+
/**
|
|
309
|
+
* Event handler for transport errors
|
|
310
|
+
*/
|
|
311
|
+
onerror?: (error: Error) => void;
|
|
312
|
+
/**
|
|
313
|
+
* Event handler for received messages
|
|
314
|
+
*/
|
|
315
|
+
onmessage?: (message: JSONRPCMessage) => void;
|
|
316
|
+
/**
|
|
317
|
+
* The protocol version negotiated during initialization.
|
|
318
|
+
*/
|
|
319
|
+
protocolVersion?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Set the protocol version negotiated during initialization.
|
|
322
|
+
*/
|
|
323
|
+
setProtocolVersion?(version: string): void;
|
|
321
324
|
}
|
|
322
325
|
type MCPTransportConfig = {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
326
|
+
type: 'sse' | 'http';
|
|
327
|
+
/**
|
|
328
|
+
* The URL of the MCP server.
|
|
329
|
+
*/
|
|
330
|
+
url: string;
|
|
331
|
+
/**
|
|
332
|
+
* Additional HTTP headers to be sent with requests.
|
|
333
|
+
*/
|
|
334
|
+
headers?: Record<string, string>;
|
|
335
|
+
/**
|
|
336
|
+
* An optional OAuth client provider to use for authentication for MCP servers.
|
|
337
|
+
*/
|
|
338
|
+
authProvider?: OAuthClientProvider;
|
|
339
|
+
/**
|
|
340
|
+
* Controls how HTTP redirects are handled for transport requests.
|
|
341
|
+
* - `'follow'`: Follow redirects automatically (standard fetch behavior).
|
|
342
|
+
* - `'error'`: Reject any redirect response with an error.
|
|
343
|
+
* @default 'error'
|
|
344
|
+
*/
|
|
345
|
+
redirect?: 'follow' | 'error';
|
|
346
|
+
/**
|
|
347
|
+
* Initial MCP session id to send with resumed Streamable HTTP requests after
|
|
348
|
+
* initialization.
|
|
349
|
+
* Only used by the HTTP transport.
|
|
350
|
+
*/
|
|
351
|
+
initialSessionId?: string;
|
|
352
|
+
/**
|
|
353
|
+
* Initial MCP protocol version to send before initialize negotiates one.
|
|
354
|
+
* Only used by the HTTP transport.
|
|
355
|
+
*/
|
|
356
|
+
initialProtocolVersion?: string;
|
|
357
|
+
/**
|
|
358
|
+
* Called when the Streamable HTTP server creates, changes, or clears the MCP
|
|
359
|
+
* session id.
|
|
360
|
+
* Only used by the HTTP transport.
|
|
361
|
+
*/
|
|
362
|
+
onSessionIdChange?: (sessionId: string | undefined) => void;
|
|
363
|
+
/**
|
|
364
|
+
* Called when a Streamable HTTP request returns 404 for an existing MCP
|
|
365
|
+
* session id. The transport clears the session id before reporting the
|
|
366
|
+
* underlying HTTP error.
|
|
367
|
+
* Only used by the HTTP transport.
|
|
368
|
+
*/
|
|
369
|
+
onSessionExpired?: (sessionId: string) => void;
|
|
370
|
+
/**
|
|
371
|
+
* Whether close() should send DELETE for the current MCP session id.
|
|
372
|
+
* Set to false when the application intends to reattach to the session later.
|
|
373
|
+
* Only used by the HTTP transport.
|
|
374
|
+
* @default true
|
|
375
|
+
*/
|
|
376
|
+
terminateSessionOnClose?: boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Optional custom fetch implementation to use for HTTP requests.
|
|
379
|
+
* Useful for runtimes that need a request-local fetch.
|
|
380
|
+
* @default globalThis.fetch
|
|
381
|
+
*/
|
|
382
|
+
fetch?: FetchFunction;
|
|
380
383
|
};
|
|
381
|
-
|
|
384
|
+
//#endregion
|
|
385
|
+
//#region src/tool/types.d.ts
|
|
382
386
|
type McpProviderMetadata = {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
387
|
+
clientName?: string;
|
|
388
|
+
title?: string;
|
|
389
|
+
toolName?: string;
|
|
390
|
+
annotations?: McpToolAnnotations;
|
|
391
|
+
app?: JSONObject;
|
|
388
392
|
};
|
|
389
393
|
/**
|
|
390
394
|
* Behavioral hints reported by an MCP server for a tool.
|
|
@@ -394,583 +398,584 @@ type McpProviderMetadata = {
|
|
|
394
398
|
* @see https://modelcontextprotocol.io/specification/2026-07-28/schema#toolannotations
|
|
395
399
|
*/
|
|
396
400
|
type McpToolAnnotations = {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
401
|
+
title?: string;
|
|
402
|
+
readOnlyHint?: boolean;
|
|
403
|
+
destructiveHint?: boolean;
|
|
404
|
+
idempotentHint?: boolean;
|
|
405
|
+
openWorldHint?: boolean;
|
|
402
406
|
};
|
|
403
407
|
/** MCP tool metadata - keys should follow MCP _meta key format specification */
|
|
404
408
|
declare const ToolMetaSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
405
409
|
type ToolMeta = z.infer<typeof ToolMetaSchema>;
|
|
406
410
|
type ToolSchemas = Record<string, {
|
|
407
|
-
|
|
408
|
-
|
|
411
|
+
inputSchema: FlexibleSchema<JSONObject | unknown>;
|
|
412
|
+
outputSchema?: FlexibleSchema<JSONObject | unknown>;
|
|
409
413
|
}> | 'automatic' | undefined;
|
|
410
414
|
/** Base MCP tool type with execute and _meta */
|
|
411
415
|
type McpToolBase<INPUT = unknown, OUTPUT = CallToolResult> = Tool<INPUT, OUTPUT> & Required<Pick<Tool<INPUT, OUTPUT>, 'execute'>> & {
|
|
412
|
-
|
|
416
|
+
_meta?: ToolMeta;
|
|
413
417
|
};
|
|
414
418
|
type McpToolSet<TOOL_SCHEMAS extends ToolSchemas = 'automatic'> = TOOL_SCHEMAS extends Record<string, {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
}> ? {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
} ? McpToolBase<INPUT, CallToolResult> : never;
|
|
424
|
-
} : Record<string, McpToolBase<unknown, CallToolResult>>;
|
|
419
|
+
inputSchema: FlexibleSchema<any>;
|
|
420
|
+
outputSchema?: FlexibleSchema<any>;
|
|
421
|
+
}> ? { [K in keyof TOOL_SCHEMAS]: TOOL_SCHEMAS[K] extends {
|
|
422
|
+
inputSchema: FlexibleSchema<infer INPUT>;
|
|
423
|
+
outputSchema: FlexibleSchema<infer OUTPUT>;
|
|
424
|
+
} ? McpToolBase<INPUT, OUTPUT> : TOOL_SCHEMAS[K] extends {
|
|
425
|
+
inputSchema: FlexibleSchema<infer INPUT>;
|
|
426
|
+
} ? McpToolBase<INPUT, CallToolResult> : never; } : Record<string, McpToolBase<unknown, CallToolResult>>;
|
|
425
427
|
declare const ClientOrServerImplementationSchema: z.ZodObject<{
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
428
|
+
name: z.ZodString;
|
|
429
|
+
version: z.ZodString;
|
|
430
|
+
title: z.ZodOptional<z.ZodString>;
|
|
429
431
|
}, z.core.$loose>;
|
|
430
432
|
type Configuration = z.infer<typeof ClientOrServerImplementationSchema>;
|
|
431
433
|
declare const BaseParamsSchema: z.ZodObject<{
|
|
432
|
-
|
|
434
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
433
435
|
}, z.core.$loose>;
|
|
434
436
|
type BaseParams = z.infer<typeof BaseParamsSchema>;
|
|
435
437
|
declare const RequestSchema: z.ZodObject<{
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
438
|
+
method: z.ZodString;
|
|
439
|
+
params: z.ZodOptional<z.ZodObject<{
|
|
440
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
441
|
+
}, z.core.$loose>>;
|
|
440
442
|
}, z.core.$strip>;
|
|
441
443
|
type Request = z.infer<typeof RequestSchema>;
|
|
442
444
|
type RequestOptions = {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
445
|
+
signal?: AbortSignal;
|
|
446
|
+
timeout?: number;
|
|
447
|
+
maxTotalTimeout?: number;
|
|
446
448
|
};
|
|
447
449
|
declare const ClientCapabilitiesSchema: z.ZodObject<{
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
450
|
+
elicitation: z.ZodOptional<z.ZodObject<{
|
|
451
|
+
applyDefaults: z.ZodOptional<z.ZodBoolean>;
|
|
452
|
+
}, z.core.$loose>>;
|
|
451
453
|
}, z.core.$loose>;
|
|
452
454
|
type ClientCapabilities = z.infer<typeof ClientCapabilitiesSchema>;
|
|
453
455
|
declare const InitializeResultSchema: z.ZodObject<{
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
456
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
457
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
458
|
+
protocolVersion: z.ZodString;
|
|
459
|
+
capabilities: z.ZodObject<{
|
|
460
|
+
experimental: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
461
|
+
logging: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
462
|
+
completions: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
463
|
+
prompts: z.ZodOptional<z.ZodObject<{
|
|
464
|
+
listChanged: z.ZodOptional<z.ZodBoolean>;
|
|
465
|
+
}, z.core.$loose>>;
|
|
466
|
+
resources: z.ZodOptional<z.ZodObject<{
|
|
467
|
+
subscribe: z.ZodOptional<z.ZodBoolean>;
|
|
468
|
+
listChanged: z.ZodOptional<z.ZodBoolean>;
|
|
469
|
+
}, z.core.$loose>>;
|
|
470
|
+
tools: z.ZodOptional<z.ZodObject<{
|
|
471
|
+
listChanged: z.ZodOptional<z.ZodBoolean>;
|
|
472
|
+
}, z.core.$loose>>;
|
|
473
|
+
elicitation: z.ZodOptional<z.ZodObject<{
|
|
474
|
+
applyDefaults: z.ZodOptional<z.ZodBoolean>;
|
|
475
|
+
}, z.core.$loose>>;
|
|
476
|
+
}, z.core.$loose>;
|
|
477
|
+
serverInfo: z.ZodObject<{
|
|
478
|
+
name: z.ZodString;
|
|
479
|
+
version: z.ZodString;
|
|
480
|
+
title: z.ZodOptional<z.ZodString>;
|
|
481
|
+
}, z.core.$loose>;
|
|
482
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
481
483
|
}, z.core.$loose>;
|
|
482
484
|
type InitializeResult = z.infer<typeof InitializeResultSchema>;
|
|
483
485
|
type PaginatedRequest = Request & {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
486
|
+
params?: BaseParams & {
|
|
487
|
+
cursor?: string;
|
|
488
|
+
};
|
|
487
489
|
};
|
|
488
490
|
declare const ListToolsResultSchema: z.ZodObject<{
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}, z.core.$loose>>;
|
|
508
|
-
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
491
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
492
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
493
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
494
|
+
tools: z.ZodArray<z.ZodObject<{
|
|
495
|
+
name: z.ZodString;
|
|
496
|
+
title: z.ZodOptional<z.ZodString>;
|
|
497
|
+
description: z.ZodOptional<z.ZodString>;
|
|
498
|
+
inputSchema: z.ZodObject<{
|
|
499
|
+
type: z.ZodOptional<z.ZodUnknown>;
|
|
500
|
+
properties: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
501
|
+
}, z.core.$loose>;
|
|
502
|
+
outputSchema: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
503
|
+
annotations: z.ZodOptional<z.ZodObject<{
|
|
504
|
+
title: z.ZodOptional<z.ZodString>;
|
|
505
|
+
readOnlyHint: z.ZodOptional<z.ZodBoolean>;
|
|
506
|
+
destructiveHint: z.ZodOptional<z.ZodBoolean>;
|
|
507
|
+
idempotentHint: z.ZodOptional<z.ZodBoolean>;
|
|
508
|
+
openWorldHint: z.ZodOptional<z.ZodBoolean>;
|
|
509
509
|
}, z.core.$loose>>;
|
|
510
|
+
_meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
511
|
+
}, z.core.$loose>>;
|
|
510
512
|
}, z.core.$loose>;
|
|
511
513
|
type ListToolsResult = z.infer<typeof ListToolsResultSchema>;
|
|
512
514
|
declare const ListResourcesResultSchema: z.ZodObject<{
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
515
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
516
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
517
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
518
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
519
|
+
uri: z.ZodString;
|
|
520
|
+
name: z.ZodString;
|
|
521
|
+
title: z.ZodOptional<z.ZodString>;
|
|
522
|
+
description: z.ZodOptional<z.ZodString>;
|
|
523
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
524
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
525
|
+
}, z.core.$loose>>;
|
|
524
526
|
}, z.core.$loose>;
|
|
525
527
|
type ListResourcesResult = z.infer<typeof ListResourcesResultSchema>;
|
|
526
528
|
declare const CallToolResultSchema: z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}, z.core.$loose>, z.ZodObject<{
|
|
545
|
-
uri: z.ZodString;
|
|
546
|
-
name: z.ZodOptional<z.ZodString>;
|
|
547
|
-
title: z.ZodOptional<z.ZodString>;
|
|
548
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
|
549
|
-
blob: z.ZodBase64;
|
|
550
|
-
}, z.core.$loose>]>;
|
|
529
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
530
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
531
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
532
|
+
type: z.ZodLiteral<"text">;
|
|
533
|
+
text: z.ZodString;
|
|
534
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
535
|
+
type: z.ZodLiteral<"image">;
|
|
536
|
+
data: z.ZodBase64;
|
|
537
|
+
mimeType: z.ZodString;
|
|
538
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
539
|
+
type: z.ZodLiteral<"resource">;
|
|
540
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
541
|
+
uri: z.ZodString;
|
|
542
|
+
name: z.ZodOptional<z.ZodString>;
|
|
543
|
+
title: z.ZodOptional<z.ZodString>;
|
|
544
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
545
|
+
text: z.ZodString;
|
|
551
546
|
}, z.core.$loose>, z.ZodObject<{
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}, z.core.$loose
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
547
|
+
uri: z.ZodString;
|
|
548
|
+
name: z.ZodOptional<z.ZodString>;
|
|
549
|
+
title: z.ZodOptional<z.ZodString>;
|
|
550
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
551
|
+
blob: z.ZodBase64;
|
|
552
|
+
}, z.core.$loose>]>;
|
|
553
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
554
|
+
type: z.ZodLiteral<"resource_link">;
|
|
555
|
+
uri: z.ZodString;
|
|
556
|
+
name: z.ZodString;
|
|
557
|
+
description: z.ZodOptional<z.ZodString>;
|
|
558
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
559
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
560
|
+
type: z.ZodString;
|
|
561
|
+
}, z.core.$loose>]>>;
|
|
562
|
+
structuredContent: z.ZodOptional<z.ZodUnknown>;
|
|
563
|
+
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
562
564
|
}, z.core.$loose>, z.ZodPipe<z.ZodPipe<z.ZodObject<{
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
565
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
566
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
567
|
+
content: z.ZodOptional<z.ZodNever>;
|
|
568
|
+
structuredContent: z.ZodJSONSchema;
|
|
569
|
+
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
568
570
|
}, z.core.$loose>, z.ZodTransform<{
|
|
571
|
+
[x: string]: unknown;
|
|
572
|
+
content: ({
|
|
569
573
|
[x: string]: unknown;
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
title?: string | undefined;
|
|
588
|
-
mimeType?: string | undefined;
|
|
589
|
-
} | {
|
|
590
|
-
[x: string]: unknown;
|
|
591
|
-
uri: string;
|
|
592
|
-
blob: string;
|
|
593
|
-
name?: string | undefined;
|
|
594
|
-
title?: string | undefined;
|
|
595
|
-
mimeType?: string | undefined;
|
|
596
|
-
};
|
|
597
|
-
} | {
|
|
598
|
-
[x: string]: unknown;
|
|
599
|
-
type: "resource_link";
|
|
600
|
-
uri: string;
|
|
601
|
-
name: string;
|
|
602
|
-
description?: string | undefined;
|
|
603
|
-
mimeType?: string | undefined;
|
|
574
|
+
type: "text";
|
|
575
|
+
text: string;
|
|
576
|
+
} | {
|
|
577
|
+
[x: string]: unknown;
|
|
578
|
+
type: "image";
|
|
579
|
+
data: string;
|
|
580
|
+
mimeType: string;
|
|
581
|
+
} | {
|
|
582
|
+
[x: string]: unknown;
|
|
583
|
+
type: "resource";
|
|
584
|
+
resource: {
|
|
585
|
+
[x: string]: unknown;
|
|
586
|
+
uri: string;
|
|
587
|
+
text: string;
|
|
588
|
+
name?: string | undefined;
|
|
589
|
+
title?: string | undefined;
|
|
590
|
+
mimeType?: string | undefined;
|
|
604
591
|
} | {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
592
|
+
[x: string]: unknown;
|
|
593
|
+
uri: string;
|
|
594
|
+
blob: string;
|
|
595
|
+
name?: string | undefined;
|
|
596
|
+
title?: string | undefined;
|
|
597
|
+
mimeType?: string | undefined;
|
|
598
|
+
};
|
|
599
|
+
} | {
|
|
600
|
+
[x: string]: unknown;
|
|
601
|
+
type: "resource_link";
|
|
602
|
+
uri: string;
|
|
603
|
+
name: string;
|
|
604
|
+
description?: string | undefined;
|
|
605
|
+
mimeType?: string | undefined;
|
|
606
|
+
} | {
|
|
607
|
+
[x: string]: unknown;
|
|
608
|
+
type: string;
|
|
609
|
+
})[];
|
|
610
|
+
_meta?: {
|
|
611
|
+
[x: string]: unknown;
|
|
612
|
+
} | undefined;
|
|
613
|
+
resultType?: string | undefined;
|
|
614
|
+
structuredContent?: unknown;
|
|
615
|
+
isError?: boolean | undefined;
|
|
614
616
|
}, {
|
|
617
|
+
[x: string]: unknown;
|
|
618
|
+
structuredContent: z.core.util.JSONType;
|
|
619
|
+
_meta?: {
|
|
615
620
|
[x: string]: unknown;
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
resultType?: string | undefined;
|
|
621
|
-
content?: undefined;
|
|
622
|
-
isError?: boolean | undefined;
|
|
621
|
+
} | undefined;
|
|
622
|
+
resultType?: string | undefined;
|
|
623
|
+
content?: undefined;
|
|
624
|
+
isError?: boolean | undefined;
|
|
623
625
|
}>>, z.ZodObject<{
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
}, z.core.$loose>, z.ZodObject<{
|
|
642
|
-
uri: z.ZodString;
|
|
643
|
-
name: z.ZodOptional<z.ZodString>;
|
|
644
|
-
title: z.ZodOptional<z.ZodString>;
|
|
645
|
-
mimeType: z.ZodOptional<z.ZodString>;
|
|
646
|
-
blob: z.ZodBase64;
|
|
647
|
-
}, z.core.$loose>]>;
|
|
626
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
627
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
628
|
+
content: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
629
|
+
type: z.ZodLiteral<"text">;
|
|
630
|
+
text: z.ZodString;
|
|
631
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
632
|
+
type: z.ZodLiteral<"image">;
|
|
633
|
+
data: z.ZodBase64;
|
|
634
|
+
mimeType: z.ZodString;
|
|
635
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
636
|
+
type: z.ZodLiteral<"resource">;
|
|
637
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
638
|
+
uri: z.ZodString;
|
|
639
|
+
name: z.ZodOptional<z.ZodString>;
|
|
640
|
+
title: z.ZodOptional<z.ZodString>;
|
|
641
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
642
|
+
text: z.ZodString;
|
|
648
643
|
}, z.core.$loose>, z.ZodObject<{
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
}, z.core.$loose
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
644
|
+
uri: z.ZodString;
|
|
645
|
+
name: z.ZodOptional<z.ZodString>;
|
|
646
|
+
title: z.ZodOptional<z.ZodString>;
|
|
647
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
648
|
+
blob: z.ZodBase64;
|
|
649
|
+
}, z.core.$loose>]>;
|
|
650
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
651
|
+
type: z.ZodLiteral<"resource_link">;
|
|
652
|
+
uri: z.ZodString;
|
|
653
|
+
name: z.ZodString;
|
|
654
|
+
description: z.ZodOptional<z.ZodString>;
|
|
655
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
656
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
657
|
+
type: z.ZodString;
|
|
658
|
+
}, z.core.$loose>]>>;
|
|
659
|
+
structuredContent: z.ZodOptional<z.ZodUnknown>;
|
|
660
|
+
isError: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
659
661
|
}, z.core.$loose>>]>, z.ZodObject<{
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
662
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
663
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
664
|
+
toolResult: z.ZodNonOptional<z.ZodUnknown>;
|
|
663
665
|
}, z.core.$loose>]>;
|
|
664
666
|
type CallToolResult = z.infer<typeof CallToolResultSchema>;
|
|
665
667
|
declare const ListResourceTemplatesResultSchema: z.ZodObject<{
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
668
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
669
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
670
|
+
resourceTemplates: z.ZodArray<z.ZodObject<{
|
|
671
|
+
uriTemplate: z.ZodString;
|
|
672
|
+
name: z.ZodString;
|
|
673
|
+
title: z.ZodOptional<z.ZodString>;
|
|
674
|
+
description: z.ZodOptional<z.ZodString>;
|
|
675
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
676
|
+
}, z.core.$loose>>;
|
|
675
677
|
}, z.core.$loose>;
|
|
676
678
|
type ListResourceTemplatesResult = z.infer<typeof ListResourceTemplatesResultSchema>;
|
|
677
679
|
declare const ReadResourceResultSchema: z.ZodObject<{
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
680
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
681
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
682
|
+
contents: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
683
|
+
uri: z.ZodString;
|
|
684
|
+
name: z.ZodOptional<z.ZodString>;
|
|
685
|
+
title: z.ZodOptional<z.ZodString>;
|
|
686
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
687
|
+
text: z.ZodString;
|
|
688
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
689
|
+
uri: z.ZodString;
|
|
690
|
+
name: z.ZodOptional<z.ZodString>;
|
|
691
|
+
title: z.ZodOptional<z.ZodString>;
|
|
692
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
693
|
+
blob: z.ZodBase64;
|
|
694
|
+
}, z.core.$loose>]>>;
|
|
693
695
|
}, z.core.$loose>;
|
|
694
696
|
type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
|
|
695
697
|
declare const CompleteRequestParamsSchema: z.ZodObject<{
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
698
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
699
|
+
ref: z.ZodUnion<readonly [z.ZodObject<{
|
|
700
|
+
type: z.ZodLiteral<"ref/prompt">;
|
|
701
|
+
name: z.ZodString;
|
|
702
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
703
|
+
type: z.ZodLiteral<"ref/resource">;
|
|
704
|
+
uri: z.ZodString;
|
|
705
|
+
}, z.core.$loose>]>;
|
|
706
|
+
argument: z.ZodObject<{
|
|
707
|
+
name: z.ZodString;
|
|
708
|
+
value: z.ZodString;
|
|
709
|
+
}, z.core.$loose>;
|
|
710
|
+
context: z.ZodOptional<z.ZodObject<{
|
|
711
|
+
arguments: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
712
|
+
}, z.core.$loose>>;
|
|
711
713
|
}, z.core.$loose>;
|
|
712
714
|
type CompleteRequestParams = z.infer<typeof CompleteRequestParamsSchema>;
|
|
713
715
|
declare const CompleteResultSchema: z.ZodObject<{
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
716
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
717
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
718
|
+
completion: z.ZodObject<{
|
|
719
|
+
values: z.ZodArray<z.ZodString>;
|
|
720
|
+
total: z.ZodOptional<z.ZodNumber>;
|
|
721
|
+
hasMore: z.ZodOptional<z.ZodBoolean>;
|
|
722
|
+
}, z.core.$loose>;
|
|
721
723
|
}, z.core.$loose>;
|
|
722
724
|
type CompleteResult = z.infer<typeof CompleteResultSchema>;
|
|
723
725
|
declare const ListPromptsResultSchema: z.ZodObject<{
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
726
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
727
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
728
|
+
nextCursor: z.ZodOptional<z.ZodString>;
|
|
729
|
+
prompts: z.ZodArray<z.ZodObject<{
|
|
730
|
+
name: z.ZodString;
|
|
731
|
+
title: z.ZodOptional<z.ZodString>;
|
|
732
|
+
description: z.ZodOptional<z.ZodString>;
|
|
733
|
+
arguments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
734
|
+
name: z.ZodString;
|
|
735
|
+
description: z.ZodOptional<z.ZodString>;
|
|
736
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
737
|
+
}, z.core.$loose>>>;
|
|
738
|
+
}, z.core.$loose>>;
|
|
737
739
|
}, z.core.$loose>;
|
|
738
740
|
type ListPromptsResult = z.infer<typeof ListPromptsResultSchema>;
|
|
739
741
|
declare const GetPromptResultSchema: z.ZodObject<{
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
742
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
743
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
744
|
+
description: z.ZodOptional<z.ZodString>;
|
|
745
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
746
|
+
role: z.ZodUnion<readonly [z.ZodLiteral<"user">, z.ZodLiteral<"assistant">]>;
|
|
747
|
+
content: z.ZodUnion<readonly [z.ZodObject<{
|
|
748
|
+
type: z.ZodLiteral<"text">;
|
|
749
|
+
text: z.ZodString;
|
|
750
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
751
|
+
type: z.ZodLiteral<"image">;
|
|
752
|
+
data: z.ZodBase64;
|
|
753
|
+
mimeType: z.ZodString;
|
|
754
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
755
|
+
type: z.ZodLiteral<"resource">;
|
|
756
|
+
resource: z.ZodUnion<readonly [z.ZodObject<{
|
|
757
|
+
uri: z.ZodString;
|
|
758
|
+
name: z.ZodOptional<z.ZodString>;
|
|
759
|
+
title: z.ZodOptional<z.ZodString>;
|
|
760
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
761
|
+
text: z.ZodString;
|
|
762
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
763
|
+
uri: z.ZodString;
|
|
764
|
+
name: z.ZodOptional<z.ZodString>;
|
|
765
|
+
title: z.ZodOptional<z.ZodString>;
|
|
766
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
767
|
+
blob: z.ZodBase64;
|
|
768
|
+
}, z.core.$loose>]>;
|
|
769
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
770
|
+
type: z.ZodLiteral<"resource_link">;
|
|
771
|
+
uri: z.ZodString;
|
|
772
|
+
name: z.ZodString;
|
|
773
|
+
description: z.ZodOptional<z.ZodString>;
|
|
774
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
775
|
+
}, z.core.$loose>]>;
|
|
776
|
+
}, z.core.$loose>>;
|
|
775
777
|
}, z.core.$loose>;
|
|
776
778
|
type GetPromptResult = z.infer<typeof GetPromptResultSchema>;
|
|
777
|
-
declare const ElicitationRequestSchema: z.ZodObject<{
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
779
|
+
export declare const ElicitationRequestSchema: z.ZodObject<{
|
|
780
|
+
method: z.ZodLiteral<"elicitation/create">;
|
|
781
|
+
params: z.ZodObject<{
|
|
782
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
783
|
+
message: z.ZodString;
|
|
784
|
+
requestedSchema: z.ZodUnknown;
|
|
785
|
+
}, z.core.$loose>;
|
|
784
786
|
}, z.core.$strip>;
|
|
785
787
|
type ElicitationRequest = z.infer<typeof ElicitationRequestSchema>;
|
|
786
|
-
declare const ElicitResultSchema: z.ZodObject<{
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
788
|
+
export declare const ElicitResultSchema: z.ZodObject<{
|
|
789
|
+
_meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
|
|
790
|
+
resultType: z.ZodOptional<z.ZodString>;
|
|
791
|
+
action: z.ZodUnion<readonly [z.ZodLiteral<"accept">, z.ZodLiteral<"decline">, z.ZodLiteral<"cancel">]>;
|
|
792
|
+
content: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
791
793
|
}, z.core.$loose>;
|
|
792
794
|
type ElicitResult = z.infer<typeof ElicitResultSchema>;
|
|
793
|
-
|
|
795
|
+
//#endregion
|
|
796
|
+
//#region src/tool/mcp-client.d.ts
|
|
794
797
|
interface MCPClientConfig {
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
798
|
+
/** Transport configuration for connecting to the MCP server */
|
|
799
|
+
transport: MCPTransportConfig | MCPTransport;
|
|
800
|
+
/**
|
|
801
|
+
* Whether transports that support stateless protocol discovery should probe
|
|
802
|
+
* with `server/discover` before falling back to legacy initialization.
|
|
803
|
+
*
|
|
804
|
+
* Disable this for legacy servers that require `initialize` to be the first
|
|
805
|
+
* request.
|
|
806
|
+
*
|
|
807
|
+
* @default true
|
|
808
|
+
*/
|
|
809
|
+
protocolVersionDiscovery?: boolean;
|
|
810
|
+
/**
|
|
811
|
+
* Options that bound or cancel transport startup and the initialize request.
|
|
812
|
+
*/
|
|
813
|
+
initializationOptions?: RequestOptions;
|
|
814
|
+
/** Optional callback for uncaught errors */
|
|
815
|
+
onUncaughtError?: (error: unknown) => void;
|
|
816
|
+
/**
|
|
817
|
+
* Maximum number of retries for transient MCP tool call failures.
|
|
818
|
+
*
|
|
819
|
+
* Set to 0 to disable retries. Retries only apply to tools/call requests.
|
|
820
|
+
* JSON-RPC application errors, such as invalid params, are not retried.
|
|
821
|
+
*
|
|
822
|
+
* @default 0
|
|
823
|
+
*/
|
|
824
|
+
maxRetries?: number;
|
|
825
|
+
/**
|
|
826
|
+
* Initialize result from a previous MCP session. When provided, the client
|
|
827
|
+
* starts the transport and reuses this metadata without sending a new
|
|
828
|
+
* initialize request.
|
|
829
|
+
*/
|
|
830
|
+
initialInitializeResult?: InitializeResult;
|
|
831
|
+
/** Optional client name, defaults to 'ai-sdk-mcp-client' */
|
|
832
|
+
clientName?: string;
|
|
833
|
+
/**
|
|
834
|
+
* Optional client name, defaults to 'ai-sdk-mcp-client'
|
|
835
|
+
*
|
|
836
|
+
* @deprecated Use `clientName` instead.
|
|
837
|
+
*/
|
|
838
|
+
name?: string;
|
|
839
|
+
/** Optional client version, defaults to '1.0.0' */
|
|
840
|
+
version?: string;
|
|
841
|
+
/**
|
|
842
|
+
* Optional client capabilities to advertise during initialization
|
|
843
|
+
*
|
|
844
|
+
* NOTE: It is up to the client application to handle the requests properly. This parameter just helps surface the request from the server
|
|
845
|
+
*/
|
|
846
|
+
capabilities?: ClientCapabilities;
|
|
844
847
|
}
|
|
845
|
-
declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
848
|
+
export declare function createMCPClient(config: MCPClientConfig): Promise<MCPClient>;
|
|
846
849
|
interface MCPClient {
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
850
|
+
/**
|
|
851
|
+
* Information about the connected MCP server, as reported during initialization.
|
|
852
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/schema#implementation
|
|
853
|
+
*/
|
|
854
|
+
readonly serverInfo: Configuration;
|
|
855
|
+
/**
|
|
856
|
+
* The full initialize result used by this client, either from the server
|
|
857
|
+
* during initialization or from `initialInitializeResult`.
|
|
858
|
+
*/
|
|
859
|
+
readonly initializeResult: InitializeResult;
|
|
860
|
+
/**
|
|
861
|
+
* Optional instructions provided by the server during the initialize handshake.
|
|
862
|
+
*
|
|
863
|
+
* These describe how to use the server and its features, and can be used by clients
|
|
864
|
+
* to improve LLM interactions (e.g. by including them in the system prompt).
|
|
865
|
+
*
|
|
866
|
+
* @see https://modelcontextprotocol.io/specification/2025-11-25/schema#initializeresult
|
|
867
|
+
*/
|
|
868
|
+
readonly instructions?: string;
|
|
869
|
+
tools<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(options?: {
|
|
870
|
+
schemas?: TOOL_SCHEMAS;
|
|
871
|
+
}): Promise<McpToolSet<TOOL_SCHEMAS>>;
|
|
872
|
+
/**
|
|
873
|
+
* Lists available tools from the MCP server.
|
|
874
|
+
*/
|
|
875
|
+
listTools(options?: {
|
|
876
|
+
params?: PaginatedRequest['params'];
|
|
877
|
+
options?: RequestOptions;
|
|
878
|
+
}): Promise<ListToolsResult>;
|
|
879
|
+
/**
|
|
880
|
+
* Calls a tool on the MCP server.
|
|
881
|
+
*/
|
|
882
|
+
callTool(args: {
|
|
883
|
+
name: string;
|
|
884
|
+
arguments?: Record<string, unknown>;
|
|
885
|
+
options?: RequestOptions;
|
|
886
|
+
}): Promise<CallToolResult>;
|
|
887
|
+
/**
|
|
888
|
+
* Creates AI SDK tools from tool definitions.
|
|
889
|
+
*/
|
|
890
|
+
toolsFromDefinitions<TOOL_SCHEMAS extends ToolSchemas = 'automatic'>(definitions: ListToolsResult, options?: {
|
|
891
|
+
schemas?: TOOL_SCHEMAS;
|
|
892
|
+
}): McpToolSet<TOOL_SCHEMAS>;
|
|
893
|
+
listResources(options?: {
|
|
894
|
+
params?: PaginatedRequest['params'];
|
|
895
|
+
options?: RequestOptions;
|
|
896
|
+
}): Promise<ListResourcesResult>;
|
|
897
|
+
readResource(args: {
|
|
898
|
+
uri: string;
|
|
899
|
+
options?: RequestOptions;
|
|
900
|
+
}): Promise<ReadResourceResult>;
|
|
901
|
+
listResourceTemplates(options?: {
|
|
902
|
+
options?: RequestOptions;
|
|
903
|
+
}): Promise<ListResourceTemplatesResult>;
|
|
904
|
+
experimental_listPrompts(options?: {
|
|
905
|
+
params?: PaginatedRequest['params'];
|
|
906
|
+
options?: RequestOptions;
|
|
907
|
+
}): Promise<ListPromptsResult>;
|
|
908
|
+
experimental_getPrompt(args: {
|
|
909
|
+
name: string;
|
|
910
|
+
arguments?: Record<string, unknown>;
|
|
911
|
+
options?: RequestOptions;
|
|
912
|
+
}): Promise<GetPromptResult>;
|
|
913
|
+
complete(args: CompleteRequestParams & {
|
|
914
|
+
options?: RequestOptions;
|
|
915
|
+
}): Promise<CompleteResult>;
|
|
916
|
+
onElicitationRequest(schema: typeof ElicitationRequestSchema, handler: (request: ElicitationRequest) => Promise<ElicitResult> | ElicitResult): void;
|
|
917
|
+
close: () => Promise<void>;
|
|
915
918
|
}
|
|
916
|
-
|
|
919
|
+
//#endregion
|
|
920
|
+
//#region src/tool/mcp-apps.d.ts
|
|
917
921
|
/**
|
|
918
922
|
* MIME type for HTML resources that are meant to be rendered as MCP Apps.
|
|
919
923
|
*/
|
|
920
|
-
declare const MCP_APP_MIME_TYPE: "text/html;profile=mcp-app";
|
|
924
|
+
export declare const MCP_APP_MIME_TYPE: "text/html;profile=mcp-app";
|
|
921
925
|
/**
|
|
922
926
|
* Client capabilities to pass to `createMCPClient` when the host supports MCP Apps.
|
|
923
927
|
*/
|
|
924
|
-
declare const mcpAppClientCapabilities: {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
};
|
|
928
|
+
export declare const mcpAppClientCapabilities: {
|
|
929
|
+
readonly extensions: {
|
|
930
|
+
readonly "io.modelcontextprotocol/ui": {
|
|
931
|
+
readonly mimeTypes: readonly ["text/html;profile=mcp-app"];
|
|
929
932
|
};
|
|
933
|
+
};
|
|
930
934
|
};
|
|
931
935
|
/**
|
|
932
936
|
* Content security policy metadata requested by an MCP App resource.
|
|
933
937
|
*/
|
|
934
938
|
type MCPAppResourceCSP = {
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
+
connectDomains?: string[];
|
|
940
|
+
resourceDomains?: string[];
|
|
941
|
+
frameDomains?: string[];
|
|
942
|
+
[key: string]: unknown;
|
|
939
943
|
};
|
|
940
944
|
/**
|
|
941
945
|
* Host rendering metadata from an MCP App resource.
|
|
942
946
|
*/
|
|
943
947
|
type MCPAppResourceMeta = {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
+
prefersBorder?: boolean;
|
|
949
|
+
csp?: MCPAppResourceCSP;
|
|
950
|
+
permissions?: Record<string, unknown>;
|
|
951
|
+
[key: string]: unknown;
|
|
948
952
|
};
|
|
949
953
|
/**
|
|
950
954
|
* HTML and metadata needed by a host to render an MCP App.
|
|
951
955
|
*/
|
|
952
956
|
type MCPAppResource = {
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
+
uri: string;
|
|
958
|
+
mimeType: typeof MCP_APP_MIME_TYPE;
|
|
959
|
+
html: string;
|
|
960
|
+
meta?: MCPAppResourceMeta;
|
|
957
961
|
};
|
|
958
962
|
/**
|
|
959
963
|
* Splits tool definitions into model-visible tools and app-visible tools.
|
|
960
964
|
*/
|
|
961
|
-
declare function splitMCPAppTools(definitions: ListToolsResult): {
|
|
962
|
-
|
|
963
|
-
|
|
965
|
+
export declare function splitMCPAppTools(definitions: ListToolsResult): {
|
|
966
|
+
modelVisible: ListToolsResult;
|
|
967
|
+
appVisible: ListToolsResult;
|
|
964
968
|
};
|
|
965
969
|
/**
|
|
966
970
|
* Reads a `ui://` resource from an MCP server and normalizes it for rendering.
|
|
967
971
|
*/
|
|
968
|
-
declare function readMCPAppResource({ client, uri, options
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
+
export declare function readMCPAppResource({ client, uri, options }: {
|
|
973
|
+
client: Pick<MCPClient, 'readResource'>;
|
|
974
|
+
uri: string;
|
|
975
|
+
options?: RequestOptions;
|
|
972
976
|
}): Promise<MCPAppResource>;
|
|
973
|
-
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region src/tool/mcp-app-fingerprint.d.ts
|
|
974
979
|
/**
|
|
975
980
|
* Stable SHA-256 digest (base64url) over an MCP App resource's `html`, `csp`,
|
|
976
981
|
* and `permissions`.
|
|
@@ -979,11 +984,12 @@ declare function readMCPAppResource({ client, uri, options, }: {
|
|
|
979
984
|
* {@link detectMCPAppResourceDrift} to detect a changed resource. Baseline
|
|
980
985
|
* storage and the response are the host's concern, mirroring `fingerprintTools`.
|
|
981
986
|
*/
|
|
982
|
-
declare function fingerprintMCPAppResource(resource: MCPAppResource): Promise<string>;
|
|
987
|
+
export declare function fingerprintMCPAppResource(resource: MCPAppResource): Promise<string>;
|
|
983
988
|
/**
|
|
984
989
|
* Compares two fingerprints from {@link fingerprintMCPAppResource}. Returns
|
|
985
990
|
* `true` when the current resource differs from its baseline.
|
|
986
991
|
*/
|
|
987
|
-
declare function detectMCPAppResourceDrift(current: string, baseline: string): boolean;
|
|
988
|
-
|
|
989
|
-
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult,
|
|
992
|
+
export declare function detectMCPAppResourceDrift(current: string, baseline: string): boolean;
|
|
993
|
+
//#endregion
|
|
994
|
+
export { type CallToolResult, type CompleteRequestParams, type CompleteResult, type Configuration, type ElicitResult, type ElicitationRequest, type InitializeResult, type JSONRPCError, type JSONRPCMessage, type JSONRPCNotification, type JSONRPCRequest, type JSONRPCResponse, type ListToolsResult, type MCPAppResource, type MCPAppResourceCSP, type MCPAppResourceMeta, type MCPClient, type MCPClient as experimental_MCPClient, type ClientCapabilities as MCPClientCapabilities, type ClientCapabilities as experimental_MCPClientCapabilities, type MCPClientConfig, type MCPClientConfig as experimental_MCPClientConfig, type MCPTransport, type MCPTransportCloseOptions, type MCPTransportSendOptions, type McpProviderMetadata, type McpToolAnnotations, type OAuthAuthorizationServerInformation, type OAuthClientInformation, type OAuthClientMetadata, type OAuthClientProvider, type OAuthTokens, createMCPClient as experimental_createMCPClient };
|
|
995
|
+
//# sourceMappingURL=index.d.ts.map
|