tmcp 1.5.0 → 1.6.1
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/LICENSE +21 -0
- package/README.md +409 -23
- package/package.json +2 -1
- package/src/index.d.ts +31 -14
- package/src/index.js +316 -65
- package/src/internal/internal.d.ts +21 -8
- package/src/validation/index.d.ts +3864 -757
- package/src/validation/index.js +1287 -203
- package/src/validation/version.d.ts +85 -0
- package/src/validation/version.js +197 -0
package/src/validation/index.js
CHANGED
|
@@ -1,17 +1,719 @@
|
|
|
1
1
|
/* eslint-disable jsdoc/no-undefined-types */
|
|
2
2
|
import * as v from 'valibot';
|
|
3
|
+
export const LATEST_PROTOCOL_VERSION = '2025-06-18';
|
|
4
|
+
export const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';
|
|
5
|
+
export const SUPPORTED_PROTOCOL_VERSIONS = [
|
|
6
|
+
LATEST_PROTOCOL_VERSION,
|
|
7
|
+
'2025-03-26',
|
|
8
|
+
'2024-11-05',
|
|
9
|
+
'2024-10-07',
|
|
10
|
+
];
|
|
11
|
+
/* JSON-RPC types */
|
|
12
|
+
export const JSONRPC_VERSION = '2.0';
|
|
13
|
+
|
|
14
|
+
export class McpError extends Error {
|
|
15
|
+
/**
|
|
16
|
+
* @param {number} code
|
|
17
|
+
* @param {string} message
|
|
18
|
+
*/
|
|
19
|
+
constructor(code, message) {
|
|
20
|
+
super(`MCP error ${code}: ${message}`);
|
|
21
|
+
this.name = 'McpError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A progress token, used to associate progress notifications with the original request.
|
|
27
|
+
*/
|
|
28
|
+
export const ProgressTokenSchema = v.union([
|
|
29
|
+
v.string(),
|
|
30
|
+
v.pipe(v.number(), v.integer()),
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An opaque token used to represent a cursor for pagination.
|
|
35
|
+
*/
|
|
36
|
+
export const CursorSchema = v.string();
|
|
37
|
+
|
|
38
|
+
const RequestMetaSchema = v.looseObject({
|
|
39
|
+
/**
|
|
40
|
+
* If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
|
|
41
|
+
*/
|
|
42
|
+
progressToken: v.optional(ProgressTokenSchema),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const BaseRequestParamsSchema = v.looseObject({
|
|
46
|
+
_meta: v.optional(RequestMetaSchema),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export const RequestSchema = v.object({
|
|
50
|
+
method: v.string(),
|
|
51
|
+
params: v.optional(BaseRequestParamsSchema),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const BaseNotificationParamsSchema = v.looseObject({
|
|
55
|
+
/**
|
|
56
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
57
|
+
* for notes on _meta usage.
|
|
58
|
+
*/
|
|
59
|
+
_meta: v.optional(v.looseObject({})),
|
|
60
|
+
});
|
|
61
|
+
export const NotificationSchema = v.object({
|
|
62
|
+
method: v.string(),
|
|
63
|
+
params: v.optional(BaseNotificationParamsSchema),
|
|
64
|
+
});
|
|
65
|
+
export const ResultSchema = v.looseObject({
|
|
66
|
+
/**
|
|
67
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
68
|
+
* for notes on _meta usage.
|
|
69
|
+
*/
|
|
70
|
+
_meta: v.optional(v.looseObject({})),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* A uniquely identifying ID for a request in JSON-RPC.
|
|
75
|
+
*/
|
|
76
|
+
export const RequestIdSchema = v.union([
|
|
77
|
+
v.string(),
|
|
78
|
+
v.pipe(v.number(), v.integer()),
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* A request that expects a response.
|
|
83
|
+
*/
|
|
84
|
+
export const JSONRPCRequestSchema = v.object({
|
|
85
|
+
jsonrpc: v.literal(JSONRPC_VERSION),
|
|
86
|
+
id: RequestIdSchema,
|
|
87
|
+
...RequestSchema.entries,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* A notification which does not expect a response.
|
|
92
|
+
*/
|
|
93
|
+
export const JSONRPCNotificationSchema = v.object({
|
|
94
|
+
jsonrpc: v.literal(JSONRPC_VERSION),
|
|
95
|
+
...NotificationSchema.entries,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* A successful (non-error) response to a request.
|
|
100
|
+
*/
|
|
101
|
+
export const JSONRPCResponseSchema = v.strictObject({
|
|
102
|
+
jsonrpc: v.literal(JSONRPC_VERSION),
|
|
103
|
+
id: RequestIdSchema,
|
|
104
|
+
result: ResultSchema,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A response to a request that indicates an error occurred.
|
|
109
|
+
*/
|
|
110
|
+
export const JSONRPCErrorSchema = v.strictObject({
|
|
111
|
+
jsonrpc: v.literal(JSONRPC_VERSION),
|
|
112
|
+
id: RequestIdSchema,
|
|
113
|
+
error: v.object({
|
|
114
|
+
/**
|
|
115
|
+
* The error type that occurred.
|
|
116
|
+
*/
|
|
117
|
+
code: v.pipe(v.number(), v.integer()),
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A short description of the error. The message SHOULD be limited to a concise single sentence.
|
|
121
|
+
*/
|
|
122
|
+
message: v.string(),
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
|
|
126
|
+
*/
|
|
127
|
+
data: v.optional(v.unknown()),
|
|
128
|
+
}),
|
|
129
|
+
});
|
|
130
|
+
export const JSONRPCMessageSchema = v.union([
|
|
131
|
+
JSONRPCRequestSchema,
|
|
132
|
+
JSONRPCNotificationSchema,
|
|
133
|
+
JSONRPCResponseSchema,
|
|
134
|
+
JSONRPCErrorSchema,
|
|
135
|
+
]);
|
|
136
|
+
/* Empty result */
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* A response that indicates success but carries no data.
|
|
140
|
+
*/
|
|
141
|
+
export const EmptyResultSchema = v.strictObject({ ...ResultSchema.entries });
|
|
142
|
+
/* Cancellation */
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
|
|
146
|
+
*
|
|
147
|
+
* The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
|
|
148
|
+
*
|
|
149
|
+
* This notification indicates that the result will be unused, so any associated processing SHOULD cease.
|
|
150
|
+
*
|
|
151
|
+
* A client MUST NOT attempt to cancel its `initialize` request.
|
|
152
|
+
*/
|
|
153
|
+
export const CancelledNotificationSchema = v.looseObject({
|
|
154
|
+
...NotificationSchema.entries,
|
|
155
|
+
method: v.literal('notifications/cancelled'),
|
|
156
|
+
params: v.looseObject({
|
|
157
|
+
...BaseNotificationParamsSchema.entries,
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The ID of the request to cancel.
|
|
161
|
+
*
|
|
162
|
+
* This MUST correspond to the ID of a request previously issued in the same direction.
|
|
163
|
+
*/
|
|
164
|
+
requestId: RequestIdSchema,
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
|
|
168
|
+
*/
|
|
169
|
+
reason: v.optional(v.string()),
|
|
170
|
+
}),
|
|
171
|
+
});
|
|
172
|
+
/* Base Metadata */
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Base metadata interface for common properties across resources, tools, prompts, and implementations.
|
|
176
|
+
*/
|
|
177
|
+
export const BaseMetadataSchema = v.looseObject({
|
|
178
|
+
/** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
|
|
179
|
+
name: v.string(),
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
|
|
183
|
+
* even by those unfamiliar with domain-specific terminology.
|
|
184
|
+
*
|
|
185
|
+
* If not provided, the name should be used for display (except for Tool,
|
|
186
|
+
* where `annotations.title` should be given precedence over using `name`,
|
|
187
|
+
* if present).
|
|
188
|
+
*/
|
|
189
|
+
title: v.optional(v.string()),
|
|
190
|
+
});
|
|
191
|
+
/* Initialization */
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Describes the name and version of an MCP implementation.
|
|
195
|
+
*/
|
|
196
|
+
export const ImplementationSchema = v.looseObject({
|
|
197
|
+
...BaseMetadataSchema.entries,
|
|
198
|
+
version: v.string(),
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
|
|
203
|
+
*/
|
|
204
|
+
export const ClientCapabilitiesSchema = v.looseObject({
|
|
205
|
+
/**
|
|
206
|
+
* Experimental, non-standard capabilities that the client supports.
|
|
207
|
+
*/
|
|
208
|
+
experimental: v.optional(v.looseObject({})),
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Present if the client supports sampling from an LLM.
|
|
212
|
+
*/
|
|
213
|
+
sampling: v.optional(v.looseObject({})),
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Present if the client supports eliciting user input.
|
|
217
|
+
*/
|
|
218
|
+
elicitation: v.optional(v.looseObject({})),
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Present if the client supports listing roots.
|
|
222
|
+
*/
|
|
223
|
+
roots: v.optional(
|
|
224
|
+
v.looseObject({
|
|
225
|
+
/**
|
|
226
|
+
* Whether the client supports issuing notifications for changes to the roots list.
|
|
227
|
+
*/
|
|
228
|
+
listChanged: v.optional(v.boolean()),
|
|
229
|
+
}),
|
|
230
|
+
),
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
export const InitializeRequestParamsSchema = v.looseObject({
|
|
234
|
+
...BaseRequestParamsSchema.entries,
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
|
|
238
|
+
*/
|
|
239
|
+
protocolVersion: v.string(),
|
|
240
|
+
capabilities: ClientCapabilitiesSchema,
|
|
241
|
+
clientInfo: ImplementationSchema,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* This request is sent from the client to the server when it first connects, asking it to begin initialization.
|
|
246
|
+
*/
|
|
247
|
+
export const InitializeRequestSchema = v.looseObject({
|
|
248
|
+
...RequestSchema.entries,
|
|
249
|
+
method: v.literal('initialize'),
|
|
250
|
+
params: InitializeRequestParamsSchema,
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
|
|
255
|
+
*/
|
|
256
|
+
export const ServerCapabilitiesSchema = v.looseObject({
|
|
257
|
+
/**
|
|
258
|
+
* Experimental, non-standard capabilities that the server supports.
|
|
259
|
+
*/
|
|
260
|
+
experimental: v.optional(v.looseObject({})),
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Present if the server supports sending log messages to the client.
|
|
264
|
+
*/
|
|
265
|
+
logging: v.optional(v.looseObject({})),
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Present if the server supports sending completions to the client.
|
|
269
|
+
*/
|
|
270
|
+
completions: v.optional(v.looseObject({})),
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Present if the server offers any prompt templates.
|
|
274
|
+
*/
|
|
275
|
+
prompts: v.optional(
|
|
276
|
+
v.looseObject({
|
|
277
|
+
/**
|
|
278
|
+
* Whether this server supports issuing notifications for changes to the prompt list.
|
|
279
|
+
*/
|
|
280
|
+
listChanged: v.optional(v.boolean()),
|
|
281
|
+
}),
|
|
282
|
+
),
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Present if the server offers any resources to read.
|
|
286
|
+
*/
|
|
287
|
+
resources: v.optional(
|
|
288
|
+
v.looseObject({
|
|
289
|
+
/**
|
|
290
|
+
* Whether this server supports clients subscribing to resource updates.
|
|
291
|
+
*/
|
|
292
|
+
subscribe: v.optional(v.boolean()),
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Whether this server supports issuing notifications for changes to the resource list.
|
|
296
|
+
*/
|
|
297
|
+
listChanged: v.optional(v.boolean()),
|
|
298
|
+
}),
|
|
299
|
+
),
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Present if the server offers any tools to call.
|
|
303
|
+
*/
|
|
304
|
+
tools: v.optional(
|
|
305
|
+
v.looseObject({
|
|
306
|
+
/**
|
|
307
|
+
* Whether this server supports issuing notifications for changes to the tool list.
|
|
308
|
+
*/
|
|
309
|
+
listChanged: v.optional(v.boolean()),
|
|
310
|
+
}),
|
|
311
|
+
),
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* After receiving an initialize request from the client, the server sends this response.
|
|
316
|
+
*/
|
|
317
|
+
export const InitializeResultSchema = v.looseObject({
|
|
318
|
+
...ResultSchema.entries,
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
|
|
322
|
+
*/
|
|
323
|
+
protocolVersion: v.string(),
|
|
324
|
+
capabilities: ServerCapabilitiesSchema,
|
|
325
|
+
serverInfo: ImplementationSchema,
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Instructions describing how to use the server and its features.
|
|
329
|
+
*
|
|
330
|
+
* This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
|
|
331
|
+
*/
|
|
332
|
+
instructions: v.optional(v.string()),
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* This notification is sent from the client to the server after initialization has finished.
|
|
337
|
+
*/
|
|
338
|
+
export const InitializedNotificationSchema = v.looseObject({
|
|
339
|
+
...NotificationSchema.entries,
|
|
340
|
+
method: v.literal('notifications/initialized'),
|
|
341
|
+
});
|
|
342
|
+
/* Ping */
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
|
|
346
|
+
*/
|
|
347
|
+
export const PingRequestSchema = v.looseObject({
|
|
348
|
+
...RequestSchema.entries,
|
|
349
|
+
method: v.literal('ping'),
|
|
350
|
+
});
|
|
351
|
+
/* Progress notifications */
|
|
352
|
+
export const ProgressSchema = v.looseObject({
|
|
353
|
+
/**
|
|
354
|
+
* The progress thus far. This should increase every time progress is made, even if the total is unknown.
|
|
355
|
+
*/
|
|
356
|
+
progress: v.number(),
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Total number of items to process (or total progress required), if known.
|
|
360
|
+
*/
|
|
361
|
+
total: v.optional(v.number()),
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* An optional message describing the current progress.
|
|
365
|
+
*/
|
|
366
|
+
message: v.optional(v.string()),
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* An out-of-band notification used to inform the receiver of a progress update for a long-running request.
|
|
371
|
+
*/
|
|
372
|
+
export const ProgressNotificationSchema = v.looseObject({
|
|
373
|
+
...NotificationSchema.entries,
|
|
374
|
+
method: v.literal('notifications/progress'),
|
|
375
|
+
params: v.object({
|
|
376
|
+
...BaseNotificationParamsSchema.entries,
|
|
377
|
+
...ProgressSchema.entries,
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
|
|
381
|
+
*/
|
|
382
|
+
progressToken: ProgressTokenSchema,
|
|
383
|
+
}),
|
|
384
|
+
});
|
|
385
|
+
/* Pagination */
|
|
386
|
+
export const PaginatedRequestSchema = v.looseObject({
|
|
387
|
+
...RequestSchema.entries,
|
|
388
|
+
params: v.optional(
|
|
389
|
+
v.looseObject({
|
|
390
|
+
...BaseRequestParamsSchema.entries,
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* An opaque token representing the current pagination position.
|
|
394
|
+
* If provided, the server should return results starting after this cursor.
|
|
395
|
+
*/
|
|
396
|
+
cursor: v.optional(CursorSchema),
|
|
397
|
+
}),
|
|
398
|
+
),
|
|
399
|
+
});
|
|
400
|
+
export const PaginatedResultSchema = v.looseObject({
|
|
401
|
+
...ResultSchema.entries,
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* An opaque token representing the pagination position after the last returned result.
|
|
405
|
+
* If present, there may be more results available.
|
|
406
|
+
*/
|
|
407
|
+
nextCursor: v.optional(CursorSchema),
|
|
408
|
+
});
|
|
409
|
+
/* Resources */
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* The contents of a specific resource or sub-resource.
|
|
413
|
+
*/
|
|
414
|
+
export const ResourceContentsSchema = v.looseObject({
|
|
415
|
+
/**
|
|
416
|
+
* The URI of this resource.
|
|
417
|
+
*/
|
|
418
|
+
uri: v.string(),
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* The MIME type of this resource, if known.
|
|
422
|
+
*/
|
|
423
|
+
mimeType: v.optional(v.string()),
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
427
|
+
* for notes on _meta usage.
|
|
428
|
+
*/
|
|
429
|
+
_meta: v.optional(v.looseObject({})),
|
|
430
|
+
});
|
|
431
|
+
export const TextResourceContentsSchema = v.looseObject({
|
|
432
|
+
...ResourceContentsSchema.entries,
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* The text of the item. This must only be set if the item can actually be represented as text (not binary data).
|
|
436
|
+
*/
|
|
437
|
+
text: v.string(),
|
|
438
|
+
});
|
|
439
|
+
export const BlobResourceContentsSchema = v.looseObject({
|
|
440
|
+
...ResourceContentsSchema.entries,
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* A base64-encoded string representing the binary data of the item.
|
|
444
|
+
*/
|
|
445
|
+
blob: v.pipe(v.string(), v.base64()),
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* A known resource that the server is capable of reading.
|
|
450
|
+
*/
|
|
451
|
+
export const ResourceSchema = v.looseObject({
|
|
452
|
+
...BaseMetadataSchema.entries,
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* The URI of this resource.
|
|
456
|
+
*/
|
|
457
|
+
uri: v.string(),
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* A description of what this resource represents.
|
|
461
|
+
*
|
|
462
|
+
* This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
|
|
463
|
+
*/
|
|
464
|
+
description: v.optional(v.string()),
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* The MIME type of this resource, if known.
|
|
468
|
+
*/
|
|
469
|
+
mimeType: v.optional(v.string()),
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
473
|
+
* for notes on _meta usage.
|
|
474
|
+
*/
|
|
475
|
+
_meta: v.optional(v.looseObject({})),
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* A template description for resources available on the server.
|
|
480
|
+
*/
|
|
481
|
+
export const ResourceTemplateSchema = v.looseObject({
|
|
482
|
+
...BaseMetadataSchema.entries,
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* A URI template (according to RFC 6570) that can be used to construct resource URIs.
|
|
486
|
+
*/
|
|
487
|
+
uriTemplate: v.string(),
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* A description of what this template is for.
|
|
491
|
+
*
|
|
492
|
+
* This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
|
|
493
|
+
*/
|
|
494
|
+
description: v.optional(v.string()),
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
|
|
498
|
+
*/
|
|
499
|
+
mimeType: v.optional(v.string()),
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
503
|
+
* for notes on _meta usage.
|
|
504
|
+
*/
|
|
505
|
+
_meta: v.optional(v.looseObject({})),
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Sent from the client to request a list of resources the server has.
|
|
510
|
+
*/
|
|
511
|
+
export const ListResourcesRequestSchema = v.looseObject({
|
|
512
|
+
...PaginatedRequestSchema.entries,
|
|
513
|
+
method: v.literal('resources/list'),
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* The server's response to a resources/list request from the client.
|
|
518
|
+
*/
|
|
519
|
+
export const ListResourcesResultSchema = v.looseObject({
|
|
520
|
+
...PaginatedResultSchema.entries,
|
|
521
|
+
resources: v.array(ResourceSchema),
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Sent from the client to request a list of resource templates the server has.
|
|
526
|
+
*/
|
|
527
|
+
export const ListResourceTemplatesRequestSchema = v.looseObject({
|
|
528
|
+
...PaginatedRequestSchema.entries,
|
|
529
|
+
method: v.literal('resources/templates/list'),
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* The server's response to a resources/templates/list request from the client.
|
|
534
|
+
*/
|
|
535
|
+
export const ListResourceTemplatesResultSchema = v.looseObject({
|
|
536
|
+
...PaginatedResultSchema.entries,
|
|
537
|
+
resourceTemplates: v.array(ResourceTemplateSchema),
|
|
538
|
+
});
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Sent from the client to the server, to read a specific resource URI.
|
|
542
|
+
*/
|
|
543
|
+
export const ReadResourceRequestSchema = v.looseObject({
|
|
544
|
+
...RequestSchema.entries,
|
|
545
|
+
method: v.literal('resources/read'),
|
|
546
|
+
params: v.looseObject({
|
|
547
|
+
...BaseRequestParamsSchema.entries,
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
|
|
551
|
+
*/
|
|
552
|
+
uri: v.string(),
|
|
553
|
+
}),
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* The server's response to a resources/read request from the client.
|
|
558
|
+
*/
|
|
559
|
+
export const ReadResourceResultSchema = v.looseObject({
|
|
560
|
+
...ResultSchema.entries,
|
|
561
|
+
contents: v.array(
|
|
562
|
+
v.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
563
|
+
),
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
|
|
568
|
+
*/
|
|
569
|
+
export const ResourceListChangedNotificationSchema = v.looseObject({
|
|
570
|
+
...NotificationSchema.entries,
|
|
571
|
+
method: v.literal('notifications/resources/list_changed'),
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
|
|
576
|
+
*/
|
|
577
|
+
export const SubscribeRequestSchema = v.looseObject({
|
|
578
|
+
...RequestSchema.entries,
|
|
579
|
+
method: v.literal('resources/subscribe'),
|
|
580
|
+
params: v.looseObject({
|
|
581
|
+
...BaseRequestParamsSchema.entries,
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.
|
|
585
|
+
*/
|
|
586
|
+
uri: v.string(),
|
|
587
|
+
}),
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
|
|
592
|
+
*/
|
|
593
|
+
export const UnsubscribeRequestSchema = v.looseObject({
|
|
594
|
+
...RequestSchema.entries,
|
|
595
|
+
method: v.literal('resources/unsubscribe'),
|
|
596
|
+
params: v.looseObject({
|
|
597
|
+
...BaseRequestParamsSchema.entries,
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* The URI of the resource to unsubscribe from.
|
|
601
|
+
*/
|
|
602
|
+
uri: v.string(),
|
|
603
|
+
}),
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.
|
|
608
|
+
*/
|
|
609
|
+
export const ResourceUpdatedNotificationSchema = v.looseObject({
|
|
610
|
+
...NotificationSchema.entries,
|
|
611
|
+
method: v.literal('notifications/resources/updated'),
|
|
612
|
+
params: v.looseObject({
|
|
613
|
+
...BaseNotificationParamsSchema.entries,
|
|
614
|
+
|
|
615
|
+
/**
|
|
616
|
+
* The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
|
|
617
|
+
*/
|
|
618
|
+
uri: v.string(),
|
|
619
|
+
}),
|
|
620
|
+
});
|
|
621
|
+
/* Prompts */
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* Describes an argument that a prompt can accept.
|
|
625
|
+
*/
|
|
626
|
+
export const PromptArgumentSchema = v.looseObject({
|
|
627
|
+
/**
|
|
628
|
+
* The name of the argument.
|
|
629
|
+
*/
|
|
630
|
+
name: v.string(),
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* A human-readable description of the argument.
|
|
634
|
+
*/
|
|
635
|
+
description: v.optional(v.string()),
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Whether this argument must be provided.
|
|
639
|
+
*/
|
|
640
|
+
required: v.optional(v.boolean()),
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* A prompt or prompt template that the server offers.
|
|
645
|
+
*/
|
|
646
|
+
export const PromptSchema = v.looseObject({
|
|
647
|
+
...BaseMetadataSchema.entries,
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* An optional description of what this prompt provides
|
|
651
|
+
*/
|
|
652
|
+
description: v.optional(v.string()),
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* A list of arguments to use for templating the prompt.
|
|
656
|
+
*/
|
|
657
|
+
arguments: v.optional(v.array(PromptArgumentSchema)),
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
661
|
+
* for notes on _meta usage.
|
|
662
|
+
*/
|
|
663
|
+
_meta: v.optional(v.looseObject({})),
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Sent from the client to request a list of prompts and prompt templates the server has.
|
|
668
|
+
*/
|
|
669
|
+
export const ListPromptsRequestSchema = v.looseObject({
|
|
670
|
+
...PaginatedRequestSchema.entries,
|
|
671
|
+
method: v.literal('prompts/list'),
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* The server's response to a prompts/list request from the client.
|
|
676
|
+
*/
|
|
677
|
+
export const ListPromptsResultSchema = v.looseObject({
|
|
678
|
+
...PaginatedResultSchema.entries,
|
|
679
|
+
prompts: v.array(PromptSchema),
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Used by the client to get a prompt provided by the server.
|
|
684
|
+
*/
|
|
685
|
+
export const GetPromptRequestSchema = v.looseObject({
|
|
686
|
+
...RequestSchema.entries,
|
|
687
|
+
method: v.literal('prompts/get'),
|
|
688
|
+
params: v.looseObject({
|
|
689
|
+
...BaseRequestParamsSchema.entries,
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* The name of the prompt or prompt template.
|
|
693
|
+
*/
|
|
694
|
+
name: v.string(),
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Arguments to use for templating the prompt.
|
|
698
|
+
*/
|
|
699
|
+
arguments: v.optional(v.record(v.string(), v.string())),
|
|
700
|
+
}),
|
|
701
|
+
});
|
|
3
702
|
|
|
4
703
|
/**
|
|
5
704
|
* Text provided to or from an LLM.
|
|
6
705
|
*/
|
|
7
706
|
export const TextContentSchema = v.looseObject({
|
|
8
707
|
type: v.literal('text'),
|
|
708
|
+
|
|
9
709
|
/**
|
|
10
710
|
* The text content of the message.
|
|
11
711
|
*/
|
|
12
712
|
text: v.string(),
|
|
713
|
+
|
|
13
714
|
/**
|
|
14
|
-
* See [MCP specification]
|
|
715
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
716
|
+
* for notes on _meta usage.
|
|
15
717
|
*/
|
|
16
718
|
_meta: v.optional(v.looseObject({})),
|
|
17
719
|
});
|
|
@@ -21,16 +723,20 @@ export const TextContentSchema = v.looseObject({
|
|
|
21
723
|
*/
|
|
22
724
|
export const ImageContentSchema = v.looseObject({
|
|
23
725
|
type: v.literal('image'),
|
|
726
|
+
|
|
24
727
|
/**
|
|
25
728
|
* The base64-encoded image data.
|
|
26
729
|
*/
|
|
27
730
|
data: v.pipe(v.string(), v.base64()),
|
|
731
|
+
|
|
28
732
|
/**
|
|
29
733
|
* The MIME type of the image. Different providers may support different image types.
|
|
30
734
|
*/
|
|
31
735
|
mimeType: v.string(),
|
|
736
|
+
|
|
32
737
|
/**
|
|
33
|
-
* See [MCP specification]
|
|
738
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
739
|
+
* for notes on _meta usage.
|
|
34
740
|
*/
|
|
35
741
|
_meta: v.optional(v.looseObject({})),
|
|
36
742
|
});
|
|
@@ -40,409 +746,787 @@ export const ImageContentSchema = v.looseObject({
|
|
|
40
746
|
*/
|
|
41
747
|
export const AudioContentSchema = v.looseObject({
|
|
42
748
|
type: v.literal('audio'),
|
|
749
|
+
|
|
43
750
|
/**
|
|
44
751
|
* The base64-encoded audio data.
|
|
45
752
|
*/
|
|
46
753
|
data: v.pipe(v.string(), v.base64()),
|
|
754
|
+
|
|
47
755
|
/**
|
|
48
756
|
* The MIME type of the audio. Different providers may support different audio types.
|
|
49
757
|
*/
|
|
50
758
|
mimeType: v.string(),
|
|
759
|
+
|
|
51
760
|
/**
|
|
52
|
-
* See [MCP specification]
|
|
761
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
762
|
+
* for notes on _meta usage.
|
|
53
763
|
*/
|
|
54
764
|
_meta: v.optional(v.looseObject({})),
|
|
55
765
|
});
|
|
56
766
|
|
|
57
767
|
/**
|
|
58
|
-
* The contents of a
|
|
768
|
+
* The contents of a resource, embedded into a prompt or tool call result.
|
|
59
769
|
*/
|
|
60
|
-
export const
|
|
770
|
+
export const EmbeddedResourceSchema = v.looseObject({
|
|
771
|
+
type: v.literal('resource'),
|
|
772
|
+
resource: v.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
773
|
+
|
|
61
774
|
/**
|
|
62
|
-
*
|
|
775
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
776
|
+
* for notes on _meta usage.
|
|
63
777
|
*/
|
|
64
|
-
|
|
778
|
+
_meta: v.optional(v.looseObject({})),
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* A resource that the server is capable of reading, included in a prompt or tool call result.
|
|
783
|
+
*
|
|
784
|
+
* Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
|
|
785
|
+
*/
|
|
786
|
+
export const ResourceLinkSchema = v.looseObject({
|
|
787
|
+
...ResourceSchema.entries,
|
|
788
|
+
type: v.literal('resource_link'),
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* A content block that can be used in prompts and tool results.
|
|
793
|
+
*/
|
|
794
|
+
export const ContentBlockSchema = v.union([
|
|
795
|
+
TextContentSchema,
|
|
796
|
+
ImageContentSchema,
|
|
797
|
+
AudioContentSchema,
|
|
798
|
+
ResourceLinkSchema,
|
|
799
|
+
EmbeddedResourceSchema,
|
|
800
|
+
]);
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Describes a message returned as part of a prompt.
|
|
804
|
+
*/
|
|
805
|
+
export const PromptMessageSchema = v.looseObject({
|
|
806
|
+
role: v.picklist(['user', 'assistant']),
|
|
807
|
+
content: ContentBlockSchema,
|
|
808
|
+
});
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* The server's response to a prompts/get request from the client.
|
|
812
|
+
*/
|
|
813
|
+
export const GetPromptResultSchema = v.looseObject({
|
|
814
|
+
...ResultSchema.entries,
|
|
815
|
+
|
|
65
816
|
/**
|
|
66
|
-
*
|
|
817
|
+
* An optional description for the prompt.
|
|
67
818
|
*/
|
|
68
|
-
|
|
819
|
+
description: v.optional(v.string()),
|
|
820
|
+
messages: v.array(PromptMessageSchema),
|
|
821
|
+
});
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
825
|
+
*/
|
|
826
|
+
export const PromptListChangedNotificationSchema = v.looseObject({
|
|
827
|
+
...NotificationSchema.entries,
|
|
828
|
+
method: v.literal('notifications/prompts/list_changed'),
|
|
829
|
+
});
|
|
830
|
+
/* Tools */
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Additional properties describing a Tool to clients.
|
|
834
|
+
*
|
|
835
|
+
* NOTE: all properties in ToolAnnotations are **hints**.
|
|
836
|
+
* They are not guaranteed to provide a faithful description of
|
|
837
|
+
* tool behavior (including descriptive properties like `title`).
|
|
838
|
+
*
|
|
839
|
+
* Clients should never make tool use decisions based on ToolAnnotations
|
|
840
|
+
* received from untrusted servers.
|
|
841
|
+
*/
|
|
842
|
+
export const ToolAnnotationsSchema = v.looseObject({
|
|
69
843
|
/**
|
|
70
|
-
*
|
|
844
|
+
* A human-readable title for the tool.
|
|
71
845
|
*/
|
|
72
|
-
|
|
73
|
-
});
|
|
846
|
+
title: v.optional(v.string()),
|
|
74
847
|
|
|
75
|
-
export const TextResourceContentsSchema = v.looseObject({
|
|
76
848
|
/**
|
|
77
|
-
*
|
|
849
|
+
* If true, the tool does not modify its environment.
|
|
850
|
+
*
|
|
851
|
+
* Default: false
|
|
78
852
|
*/
|
|
79
|
-
|
|
853
|
+
readOnlyHint: v.optional(v.boolean()),
|
|
854
|
+
|
|
80
855
|
/**
|
|
81
|
-
*
|
|
856
|
+
* If true, the tool may perform destructive updates to its environment.
|
|
857
|
+
* If false, the tool performs only additive updates.
|
|
858
|
+
*
|
|
859
|
+
* (This property is meaningful only when `readOnlyHint == false`)
|
|
860
|
+
*
|
|
861
|
+
* Default: true
|
|
82
862
|
*/
|
|
83
|
-
|
|
863
|
+
destructiveHint: v.optional(v.boolean()),
|
|
864
|
+
|
|
84
865
|
/**
|
|
85
|
-
*
|
|
866
|
+
* If true, calling the tool repeatedly with the same arguments
|
|
867
|
+
* will have no additional effect on the its environment.
|
|
868
|
+
*
|
|
869
|
+
* (This property is meaningful only when `readOnlyHint == false`)
|
|
870
|
+
*
|
|
871
|
+
* Default: false
|
|
86
872
|
*/
|
|
87
|
-
|
|
873
|
+
idempotentHint: v.optional(v.boolean()),
|
|
874
|
+
|
|
88
875
|
/**
|
|
89
|
-
*
|
|
876
|
+
* If true, this tool may interact with an "open world" of external
|
|
877
|
+
* entities. If false, the tool's domain of interaction is closed.
|
|
878
|
+
* For example, the world of a web search tool is open, whereas that
|
|
879
|
+
* of a memory tool is not.
|
|
880
|
+
*
|
|
881
|
+
* Default: true
|
|
90
882
|
*/
|
|
91
|
-
|
|
883
|
+
openWorldHint: v.optional(v.boolean()),
|
|
92
884
|
});
|
|
93
885
|
|
|
94
|
-
|
|
886
|
+
/**
|
|
887
|
+
* Definition for a tool the client can call.
|
|
888
|
+
*/
|
|
889
|
+
export const ToolSchema = v.looseObject({
|
|
890
|
+
...BaseMetadataSchema.entries,
|
|
891
|
+
|
|
95
892
|
/**
|
|
96
|
-
*
|
|
893
|
+
* A human-readable description of the tool.
|
|
97
894
|
*/
|
|
98
|
-
|
|
895
|
+
description: v.optional(v.string()),
|
|
896
|
+
|
|
99
897
|
/**
|
|
100
|
-
*
|
|
898
|
+
* A JSON Schema object defining the expected parameters for the tool.
|
|
101
899
|
*/
|
|
102
|
-
|
|
900
|
+
inputSchema: v.looseObject({
|
|
901
|
+
type: v.literal('object'),
|
|
902
|
+
properties: v.optional(v.looseObject({})),
|
|
903
|
+
required: v.optional(v.array(v.string())),
|
|
904
|
+
}),
|
|
905
|
+
|
|
103
906
|
/**
|
|
104
|
-
*
|
|
907
|
+
* An optional JSON Schema object defining the structure of the tool's output returned in
|
|
908
|
+
* the structuredContent field of a CallToolResult.
|
|
105
909
|
*/
|
|
106
|
-
|
|
910
|
+
outputSchema: v.optional(
|
|
911
|
+
v.looseObject({
|
|
912
|
+
type: v.literal('object'),
|
|
913
|
+
properties: v.optional(v.looseObject({})),
|
|
914
|
+
required: v.optional(v.array(v.string())),
|
|
915
|
+
}),
|
|
916
|
+
),
|
|
917
|
+
|
|
107
918
|
/**
|
|
108
|
-
*
|
|
919
|
+
* Optional additional tool information.
|
|
920
|
+
*/
|
|
921
|
+
annotations: v.optional(ToolAnnotationsSchema),
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
925
|
+
* for notes on _meta usage.
|
|
109
926
|
*/
|
|
110
927
|
_meta: v.optional(v.looseObject({})),
|
|
111
928
|
});
|
|
112
929
|
|
|
113
930
|
/**
|
|
114
|
-
*
|
|
931
|
+
* Sent from the client to request a list of tools the server has.
|
|
932
|
+
*/
|
|
933
|
+
export const ListToolsRequestSchema = v.looseObject({
|
|
934
|
+
...PaginatedRequestSchema.entries,
|
|
935
|
+
method: v.literal('tools/list'),
|
|
936
|
+
});
|
|
937
|
+
|
|
938
|
+
/**
|
|
939
|
+
* The server's response to a tools/list request from the client.
|
|
940
|
+
*/
|
|
941
|
+
export const ListToolsResultSchema = v.looseObject({
|
|
942
|
+
...PaginatedResultSchema.entries,
|
|
943
|
+
tools: v.array(ToolSchema),
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* The server's response to a tool call.
|
|
948
|
+
*/
|
|
949
|
+
export const CallToolResultSchema = v.looseObject({
|
|
950
|
+
...ResultSchema.entries,
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* A list of content objects that represent the result of the tool call.
|
|
954
|
+
*
|
|
955
|
+
* If the Tool does not define an outputSchema, this field MUST be present in the result.
|
|
956
|
+
* For backwards compatibility, this field is always present, but it may be empty.
|
|
957
|
+
*/
|
|
958
|
+
content: v.optional(v.array(ContentBlockSchema), []),
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* An object containing structured tool output.
|
|
962
|
+
*
|
|
963
|
+
* If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
|
|
964
|
+
*/
|
|
965
|
+
structuredContent: v.optional(v.looseObject({})),
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* Whether the tool call ended in an error.
|
|
969
|
+
*
|
|
970
|
+
* If not set, this is assumed to be false (the call was successful).
|
|
971
|
+
*
|
|
972
|
+
* Any errors that originate from the tool SHOULD be reported inside the result
|
|
973
|
+
* object, with `isError` set to true, _not_ as an MCP protocol-level error
|
|
974
|
+
* response. Otherwise, the LLM would not be able to see that an error occurred
|
|
975
|
+
* and self-correct.
|
|
976
|
+
*
|
|
977
|
+
* However, any errors in _finding_ the tool, an error indicating that the
|
|
978
|
+
* server does not support tool calls, or any other exceptional conditions,
|
|
979
|
+
* should be reported as an MCP error response.
|
|
980
|
+
*/
|
|
981
|
+
isError: v.optional(v.boolean()),
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
|
|
986
|
+
*/
|
|
987
|
+
export const CompatibilityCallToolResultSchema = v.union([
|
|
988
|
+
CallToolResultSchema,
|
|
989
|
+
v.looseObject({ ...ResultSchema.entries, toolResult: v.unknown() }),
|
|
990
|
+
]);
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* Used by the client to invoke a tool provided by the server.
|
|
115
994
|
*/
|
|
116
|
-
export const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
995
|
+
export const CallToolRequestSchema = v.looseObject({
|
|
996
|
+
...RequestSchema.entries,
|
|
997
|
+
method: v.literal('tools/call'),
|
|
998
|
+
params: v.looseObject({
|
|
999
|
+
...BaseRequestParamsSchema.entries,
|
|
1000
|
+
name: v.string(),
|
|
1001
|
+
arguments: v.optional(v.record(v.string(), v.unknown())),
|
|
1002
|
+
}),
|
|
123
1003
|
});
|
|
124
1004
|
|
|
125
1005
|
/**
|
|
126
|
-
*
|
|
1006
|
+
* An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
|
|
127
1007
|
*/
|
|
128
|
-
export const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
title: v.optional(v.string()),
|
|
132
|
-
/**
|
|
133
|
-
* The URI of this resource.
|
|
134
|
-
*/
|
|
135
|
-
uri: v.string(),
|
|
136
|
-
/**
|
|
137
|
-
* A description of what this resource represents.
|
|
138
|
-
*/
|
|
139
|
-
description: v.optional(v.string()),
|
|
140
|
-
/**
|
|
141
|
-
* The MIME type of this resource, if known.
|
|
142
|
-
*/
|
|
143
|
-
mimeType: v.optional(v.string()),
|
|
144
|
-
type: v.literal('resource_link'),
|
|
145
|
-
/**
|
|
146
|
-
* See [MCP specification] for notes on _meta usage.
|
|
147
|
-
*/
|
|
148
|
-
_meta: v.optional(v.looseObject({})),
|
|
1008
|
+
export const ToolListChangedNotificationSchema = v.looseObject({
|
|
1009
|
+
...NotificationSchema.entries,
|
|
1010
|
+
method: v.literal('notifications/tools/list_changed'),
|
|
149
1011
|
});
|
|
1012
|
+
/* Logging */
|
|
150
1013
|
|
|
151
1014
|
/**
|
|
152
|
-
*
|
|
1015
|
+
* The severity of a log message.
|
|
153
1016
|
*/
|
|
154
|
-
export const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
1017
|
+
export const LoggingLevelSchema = v.picklist([
|
|
1018
|
+
'debug',
|
|
1019
|
+
'info',
|
|
1020
|
+
'notice',
|
|
1021
|
+
'warning',
|
|
1022
|
+
'error',
|
|
1023
|
+
'critical',
|
|
1024
|
+
'alert',
|
|
1025
|
+
'emergency',
|
|
160
1026
|
]);
|
|
161
1027
|
|
|
162
1028
|
/**
|
|
163
|
-
*
|
|
1029
|
+
* A request from the client to the server, to enable or adjust logging.
|
|
164
1030
|
*/
|
|
165
|
-
export const
|
|
166
|
-
|
|
167
|
-
|
|
1031
|
+
export const SetLevelRequestSchema = v.looseObject({
|
|
1032
|
+
...RequestSchema.entries,
|
|
1033
|
+
method: v.literal('logging/setLevel'),
|
|
1034
|
+
params: v.looseObject({
|
|
1035
|
+
...BaseRequestParamsSchema.entries,
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.
|
|
1039
|
+
*/
|
|
1040
|
+
level: LoggingLevelSchema,
|
|
1041
|
+
}),
|
|
168
1042
|
});
|
|
169
1043
|
|
|
170
1044
|
/**
|
|
171
|
-
*
|
|
1045
|
+
* Notification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.
|
|
172
1046
|
*/
|
|
173
|
-
export const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
1047
|
+
export const LoggingMessageNotificationSchema = v.looseObject({
|
|
1048
|
+
...NotificationSchema.entries,
|
|
1049
|
+
method: v.literal('notifications/message'),
|
|
1050
|
+
params: v.looseObject({
|
|
1051
|
+
...BaseNotificationParamsSchema.entries,
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* The severity of this log message.
|
|
1055
|
+
*/
|
|
1056
|
+
level: LoggingLevelSchema,
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* An optional name of the logger issuing this message.
|
|
1060
|
+
*/
|
|
1061
|
+
logger: v.optional(v.string()),
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
|
|
1065
|
+
*/
|
|
1066
|
+
data: v.unknown(),
|
|
1067
|
+
}),
|
|
178
1068
|
});
|
|
1069
|
+
/* Sampling */
|
|
179
1070
|
|
|
180
1071
|
/**
|
|
181
|
-
*
|
|
1072
|
+
* Hints to use for model selection.
|
|
182
1073
|
*/
|
|
183
|
-
export const
|
|
184
|
-
|
|
185
|
-
|
|
1074
|
+
export const ModelHintSchema = v.looseObject({
|
|
1075
|
+
/**
|
|
1076
|
+
* A hint for a model name.
|
|
1077
|
+
*/
|
|
1078
|
+
name: v.optional(v.string()),
|
|
186
1079
|
});
|
|
187
1080
|
|
|
188
1081
|
/**
|
|
189
|
-
*
|
|
1082
|
+
* The server's preferences for model selection, requested of the client during sampling.
|
|
190
1083
|
*/
|
|
191
1084
|
export const ModelPreferencesSchema = v.looseObject({
|
|
192
1085
|
/**
|
|
193
|
-
* Optional hints
|
|
1086
|
+
* Optional hints to use for model selection.
|
|
194
1087
|
*/
|
|
195
1088
|
hints: v.optional(v.array(ModelHintSchema)),
|
|
1089
|
+
|
|
196
1090
|
/**
|
|
197
|
-
*
|
|
1091
|
+
* How much to prioritize cost when selecting a model.
|
|
198
1092
|
*/
|
|
199
|
-
costPriority: v.optional(v.number()),
|
|
1093
|
+
costPriority: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1))),
|
|
1094
|
+
|
|
200
1095
|
/**
|
|
201
|
-
*
|
|
1096
|
+
* How much to prioritize sampling speed (latency) when selecting a model.
|
|
202
1097
|
*/
|
|
203
|
-
speedPriority: v.optional(v.number()),
|
|
1098
|
+
speedPriority: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1))),
|
|
1099
|
+
|
|
204
1100
|
/**
|
|
205
|
-
*
|
|
1101
|
+
* How much to prioritize intelligence and capabilities when selecting a model.
|
|
206
1102
|
*/
|
|
207
|
-
intelligencePriority: v.optional(
|
|
1103
|
+
intelligencePriority: v.optional(
|
|
1104
|
+
v.pipe(v.number(), v.minValue(0), v.maxValue(1)),
|
|
1105
|
+
),
|
|
208
1106
|
});
|
|
209
1107
|
|
|
210
1108
|
/**
|
|
211
|
-
*
|
|
1109
|
+
* Describes a message issued to or received from an LLM API.
|
|
212
1110
|
*/
|
|
213
|
-
export const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
1111
|
+
export const SamplingMessageSchema = v.looseObject({
|
|
1112
|
+
role: v.picklist(['user', 'assistant']),
|
|
1113
|
+
content: v.union([
|
|
1114
|
+
TextContentSchema,
|
|
1115
|
+
ImageContentSchema,
|
|
1116
|
+
AudioContentSchema,
|
|
1117
|
+
]),
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
export const CreateMessageRequestParamsSchema = v.looseObject({
|
|
1121
|
+
...BaseRequestParamsSchema.entries,
|
|
217
1122
|
messages: v.array(SamplingMessageSchema),
|
|
1123
|
+
|
|
218
1124
|
/**
|
|
219
|
-
*
|
|
1125
|
+
* An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
|
|
220
1126
|
*/
|
|
221
1127
|
systemPrompt: v.optional(v.string()),
|
|
1128
|
+
|
|
222
1129
|
/**
|
|
223
|
-
*
|
|
1130
|
+
* A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.
|
|
224
1131
|
*/
|
|
225
1132
|
includeContext: v.optional(
|
|
226
1133
|
v.picklist(['none', 'thisServer', 'allServers']),
|
|
227
1134
|
),
|
|
228
|
-
/**
|
|
229
|
-
* Optional temperature for generation.
|
|
230
|
-
*/
|
|
231
1135
|
temperature: v.optional(v.number()),
|
|
1136
|
+
|
|
232
1137
|
/**
|
|
233
|
-
*
|
|
234
|
-
*/
|
|
235
|
-
maxTokens: v.pipe(v.number(), v.integer(), v.minValue(1)),
|
|
236
|
-
/**
|
|
237
|
-
* Optional stop sequences.
|
|
1138
|
+
* The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.
|
|
238
1139
|
*/
|
|
1140
|
+
maxTokens: v.pipe(v.number(), v.integer()),
|
|
239
1141
|
stopSequences: v.optional(v.array(v.string())),
|
|
1142
|
+
|
|
240
1143
|
/**
|
|
241
|
-
* Optional metadata
|
|
1144
|
+
* Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
|
|
242
1145
|
*/
|
|
243
1146
|
metadata: v.optional(v.looseObject({})),
|
|
1147
|
+
|
|
244
1148
|
/**
|
|
245
|
-
*
|
|
1149
|
+
* The server's preferences for which model to select.
|
|
246
1150
|
*/
|
|
247
1151
|
modelPreferences: v.optional(ModelPreferencesSchema),
|
|
248
1152
|
});
|
|
249
1153
|
|
|
250
1154
|
/**
|
|
251
|
-
*
|
|
1155
|
+
* A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
|
|
1156
|
+
*/
|
|
1157
|
+
export const CreateMessageRequestSchema = v.looseObject({
|
|
1158
|
+
...RequestSchema.entries,
|
|
1159
|
+
method: v.literal('sampling/createMessage'),
|
|
1160
|
+
params: CreateMessageRequestParamsSchema,
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* The client's response to a sampling/create_message request from the server. The client should inform the user before returning the sampled message, to allow them to inspect the response (human in the loop) and decide whether to allow the server to see it.
|
|
252
1165
|
*/
|
|
253
1166
|
export const CreateMessageResultSchema = v.looseObject({
|
|
1167
|
+
...ResultSchema.entries,
|
|
1168
|
+
|
|
254
1169
|
/**
|
|
255
|
-
* The model that generated the message.
|
|
1170
|
+
* The name of the model that generated the message.
|
|
256
1171
|
*/
|
|
257
1172
|
model: v.string(),
|
|
1173
|
+
|
|
258
1174
|
/**
|
|
259
|
-
*
|
|
1175
|
+
* The reason why sampling stopped.
|
|
260
1176
|
*/
|
|
261
1177
|
stopReason: v.optional(
|
|
262
1178
|
v.union([
|
|
263
|
-
v.
|
|
264
|
-
v.literal('stopSequence'),
|
|
265
|
-
v.literal('maxTokens'),
|
|
1179
|
+
v.picklist(['endTurn', 'stopSequence', 'maxTokens']),
|
|
266
1180
|
v.string(),
|
|
267
1181
|
]),
|
|
268
1182
|
),
|
|
269
|
-
/**
|
|
270
|
-
* The role of the generated message.
|
|
271
|
-
*/
|
|
272
1183
|
role: v.picklist(['user', 'assistant']),
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
1184
|
+
content: v.variant('type', [
|
|
1185
|
+
TextContentSchema,
|
|
1186
|
+
ImageContentSchema,
|
|
1187
|
+
AudioContentSchema,
|
|
1188
|
+
]),
|
|
277
1189
|
});
|
|
1190
|
+
/* Elicitation */
|
|
278
1191
|
|
|
279
1192
|
/**
|
|
280
|
-
*
|
|
1193
|
+
* Primitive schema definition for boolean fields.
|
|
281
1194
|
*/
|
|
282
|
-
export const
|
|
1195
|
+
export const BooleanSchemaSchema = v.looseObject({
|
|
1196
|
+
type: v.literal('boolean'),
|
|
1197
|
+
title: v.optional(v.string()),
|
|
1198
|
+
description: v.optional(v.string()),
|
|
1199
|
+
default: v.optional(v.boolean()),
|
|
1200
|
+
});
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Primitive schema definition for string fields.
|
|
1204
|
+
*/
|
|
1205
|
+
export const StringSchemaSchema = v.looseObject({
|
|
1206
|
+
type: v.literal('string'),
|
|
1207
|
+
title: v.optional(v.string()),
|
|
1208
|
+
description: v.optional(v.string()),
|
|
1209
|
+
minLength: v.optional(v.number()),
|
|
1210
|
+
maxLength: v.optional(v.number()),
|
|
1211
|
+
format: v.optional(v.picklist(['email', 'uri', 'date', 'date-time'])),
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
/**
|
|
1215
|
+
* Primitive schema definition for number fields.
|
|
1216
|
+
*/
|
|
1217
|
+
export const NumberSchemaSchema = v.looseObject({
|
|
1218
|
+
type: v.picklist(['number', 'integer']),
|
|
1219
|
+
title: v.optional(v.string()),
|
|
1220
|
+
description: v.optional(v.string()),
|
|
1221
|
+
minimum: v.optional(v.number()),
|
|
1222
|
+
maximum: v.optional(v.number()),
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* Primitive schema definition for enum fields.
|
|
1227
|
+
*/
|
|
1228
|
+
export const EnumSchemaSchema = v.looseObject({
|
|
1229
|
+
type: v.literal('string'),
|
|
1230
|
+
title: v.optional(v.string()),
|
|
1231
|
+
description: v.optional(v.string()),
|
|
1232
|
+
enum: v.array(v.string()),
|
|
1233
|
+
enumNames: v.optional(v.array(v.string())),
|
|
1234
|
+
});
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* Union of all primitive schema definitions.
|
|
1238
|
+
*/
|
|
1239
|
+
export const PrimitiveSchemaDefinitionSchema = v.union([
|
|
1240
|
+
BooleanSchemaSchema,
|
|
1241
|
+
StringSchemaSchema,
|
|
1242
|
+
NumberSchemaSchema,
|
|
1243
|
+
EnumSchemaSchema,
|
|
1244
|
+
]);
|
|
1245
|
+
|
|
1246
|
+
/**
|
|
1247
|
+
* A request from the server to elicit user input via the client.
|
|
1248
|
+
* The client should present the message and form fields to the user.
|
|
1249
|
+
*/
|
|
1250
|
+
export const ElicitRequestSchema = v.looseObject({
|
|
1251
|
+
...RequestSchema.entries,
|
|
1252
|
+
method: v.literal('elicitation/create'),
|
|
1253
|
+
params: v.looseObject({
|
|
1254
|
+
...BaseRequestParamsSchema.entries,
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* The message to present to the user.
|
|
1258
|
+
*/
|
|
1259
|
+
message: v.string(),
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* The schema for the requested user input.
|
|
1263
|
+
*/
|
|
1264
|
+
requestedSchema: v.looseObject({
|
|
1265
|
+
type: v.literal('object'),
|
|
1266
|
+
properties: v.record(v.string(), PrimitiveSchemaDefinitionSchema),
|
|
1267
|
+
required: v.optional(v.array(v.string())),
|
|
1268
|
+
}),
|
|
1269
|
+
}),
|
|
1270
|
+
});
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* The client's response to an elicitation/create request from the server.
|
|
1274
|
+
*/
|
|
1275
|
+
export const ElicitResultSchema = v.looseObject({
|
|
1276
|
+
...ResultSchema.entries,
|
|
1277
|
+
|
|
283
1278
|
/**
|
|
284
|
-
*
|
|
1279
|
+
* The user's response action.
|
|
285
1280
|
*/
|
|
286
|
-
|
|
1281
|
+
action: v.picklist(['accept', 'decline', 'cancel']),
|
|
287
1282
|
|
|
288
1283
|
/**
|
|
289
|
-
*
|
|
1284
|
+
* The collected user input content (only present if action is "accept").
|
|
290
1285
|
*/
|
|
291
|
-
|
|
1286
|
+
content: v.optional(v.record(v.string(), v.unknown())),
|
|
1287
|
+
});
|
|
1288
|
+
/* Autocomplete */
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* A reference to a resource or resource template definition.
|
|
1292
|
+
*/
|
|
1293
|
+
export const ResourceTemplateReferenceSchema = v.looseObject({
|
|
1294
|
+
type: v.literal('ref/resource'),
|
|
292
1295
|
|
|
293
1296
|
/**
|
|
294
|
-
*
|
|
1297
|
+
* The URI or URI template of the resource.
|
|
295
1298
|
*/
|
|
296
|
-
|
|
297
|
-
_meta: v.optional(v.looseObject({})),
|
|
1299
|
+
uri: v.string(),
|
|
298
1300
|
});
|
|
299
1301
|
|
|
300
1302
|
/**
|
|
301
|
-
*
|
|
1303
|
+
* @deprecated Use ResourceTemplateReferenceSchema instead
|
|
302
1304
|
*/
|
|
303
|
-
export const
|
|
304
|
-
contents: v.array(
|
|
305
|
-
v.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
|
|
306
|
-
),
|
|
307
|
-
_meta: v.optional(v.looseObject({})),
|
|
308
|
-
});
|
|
1305
|
+
export const ResourceReferenceSchema = ResourceTemplateReferenceSchema;
|
|
309
1306
|
|
|
310
1307
|
/**
|
|
311
|
-
*
|
|
1308
|
+
* Identifies a prompt.
|
|
312
1309
|
*/
|
|
313
|
-
export const
|
|
1310
|
+
export const PromptReferenceSchema = v.looseObject({
|
|
1311
|
+
type: v.literal('ref/prompt'),
|
|
1312
|
+
|
|
314
1313
|
/**
|
|
315
|
-
*
|
|
1314
|
+
* The name of the prompt or prompt template
|
|
316
1315
|
*/
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
1316
|
+
name: v.string(),
|
|
1317
|
+
});
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* A request from the client to the server, to ask for completion options.
|
|
1321
|
+
*/
|
|
1322
|
+
export const CompleteRequestSchema = v.looseObject({
|
|
1323
|
+
...RequestSchema.entries,
|
|
1324
|
+
method: v.literal('completion/complete'),
|
|
1325
|
+
params: v.looseObject({
|
|
1326
|
+
...BaseRequestParamsSchema.entries,
|
|
1327
|
+
ref: v.union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
|
|
1328
|
+
|
|
1329
|
+
/**
|
|
1330
|
+
* The argument's information
|
|
1331
|
+
*/
|
|
1332
|
+
argument: v.looseObject({
|
|
1333
|
+
/**
|
|
1334
|
+
* The name of the argument
|
|
1335
|
+
*/
|
|
1336
|
+
name: v.string(),
|
|
1337
|
+
|
|
1338
|
+
/**
|
|
1339
|
+
* The value of the argument to use for completion matching.
|
|
1340
|
+
*/
|
|
1341
|
+
value: v.string(),
|
|
1342
|
+
}),
|
|
1343
|
+
context: v.optional(
|
|
1344
|
+
v.object({
|
|
1345
|
+
/**
|
|
1346
|
+
* Previously-resolved variables in a URI template or prompt.
|
|
1347
|
+
*/
|
|
1348
|
+
arguments: v.optional(v.record(v.string(), v.string())),
|
|
1349
|
+
}),
|
|
1350
|
+
),
|
|
1351
|
+
}),
|
|
320
1352
|
});
|
|
321
1353
|
|
|
322
1354
|
/**
|
|
323
1355
|
* The server's response to a completion/complete request
|
|
324
1356
|
*/
|
|
325
1357
|
export const CompleteResultSchema = v.looseObject({
|
|
1358
|
+
...ResultSchema.entries,
|
|
326
1359
|
completion: v.looseObject({
|
|
327
1360
|
/**
|
|
328
1361
|
* An array of completion values. Must not exceed 100 items.
|
|
329
1362
|
*/
|
|
330
1363
|
values: v.pipe(v.array(v.string()), v.maxLength(100)),
|
|
1364
|
+
|
|
331
1365
|
/**
|
|
332
1366
|
* The total number of completion options available. This can exceed the number of values actually sent in the response.
|
|
333
1367
|
*/
|
|
334
1368
|
total: v.optional(v.pipe(v.number(), v.integer())),
|
|
1369
|
+
|
|
335
1370
|
/**
|
|
336
1371
|
* Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
|
|
337
1372
|
*/
|
|
338
1373
|
hasMore: v.optional(v.boolean()),
|
|
339
1374
|
}),
|
|
340
|
-
_meta: v.optional(v.looseObject({})),
|
|
341
1375
|
});
|
|
1376
|
+
/* Roots */
|
|
342
1377
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
1378
|
+
/**
|
|
1379
|
+
* Represents a root directory or file that the server can operate on.
|
|
1380
|
+
*/
|
|
1381
|
+
export const RootSchema = v.looseObject({
|
|
1382
|
+
/**
|
|
1383
|
+
* The URI identifying the root. This *must* start with file:// for now.
|
|
1384
|
+
*/
|
|
1385
|
+
uri: v.pipe(v.string(), v.startsWith('file://')),
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* An optional name for the root.
|
|
1389
|
+
*/
|
|
1390
|
+
name: v.optional(v.string()),
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
|
|
1394
|
+
* for notes on _meta usage.
|
|
1395
|
+
*/
|
|
1396
|
+
_meta: v.optional(v.looseObject({})),
|
|
351
1397
|
});
|
|
352
1398
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
1399
|
+
/**
|
|
1400
|
+
* Sent from the server to request a list of root URIs from the client.
|
|
1401
|
+
*/
|
|
1402
|
+
export const ListRootsRequestSchema = v.looseObject({
|
|
1403
|
+
...RequestSchema.entries,
|
|
1404
|
+
method: v.literal('roots/list'),
|
|
356
1405
|
});
|
|
357
1406
|
|
|
358
1407
|
/**
|
|
359
|
-
*
|
|
1408
|
+
* The client's response to a roots/list request from the server.
|
|
360
1409
|
*/
|
|
1410
|
+
export const ListRootsResultSchema = v.looseObject({
|
|
1411
|
+
...ResultSchema.entries,
|
|
1412
|
+
roots: v.array(RootSchema),
|
|
1413
|
+
});
|
|
361
1414
|
|
|
362
1415
|
/**
|
|
363
|
-
*
|
|
1416
|
+
* A notification from the client to the server, informing it that the list of roots has changed.
|
|
364
1417
|
*/
|
|
1418
|
+
export const RootsListChangedNotificationSchema = v.looseObject({
|
|
1419
|
+
...NotificationSchema.entries,
|
|
1420
|
+
method: v.literal('notifications/roots/list_changed'),
|
|
1421
|
+
});
|
|
1422
|
+
/* Client messages */
|
|
1423
|
+
export const ClientRequestSchema = v.union([
|
|
1424
|
+
PingRequestSchema,
|
|
1425
|
+
InitializeRequestSchema,
|
|
1426
|
+
CompleteRequestSchema,
|
|
1427
|
+
SetLevelRequestSchema,
|
|
1428
|
+
GetPromptRequestSchema,
|
|
1429
|
+
ListPromptsRequestSchema,
|
|
1430
|
+
ListResourcesRequestSchema,
|
|
1431
|
+
ListResourceTemplatesRequestSchema,
|
|
1432
|
+
ReadResourceRequestSchema,
|
|
1433
|
+
SubscribeRequestSchema,
|
|
1434
|
+
UnsubscribeRequestSchema,
|
|
1435
|
+
CallToolRequestSchema,
|
|
1436
|
+
ListToolsRequestSchema,
|
|
1437
|
+
]);
|
|
1438
|
+
export const ClientNotificationSchema = v.union([
|
|
1439
|
+
CancelledNotificationSchema,
|
|
1440
|
+
ProgressNotificationSchema,
|
|
1441
|
+
InitializedNotificationSchema,
|
|
1442
|
+
RootsListChangedNotificationSchema,
|
|
1443
|
+
]);
|
|
1444
|
+
export const ClientResultSchema = v.union([
|
|
1445
|
+
EmptyResultSchema,
|
|
1446
|
+
CreateMessageResultSchema,
|
|
1447
|
+
ElicitResultSchema,
|
|
1448
|
+
ListRootsResultSchema,
|
|
1449
|
+
]);
|
|
1450
|
+
/* Server messages */
|
|
1451
|
+
export const ServerRequestSchema = v.union([
|
|
1452
|
+
PingRequestSchema,
|
|
1453
|
+
CreateMessageRequestSchema,
|
|
1454
|
+
ElicitRequestSchema,
|
|
1455
|
+
ListRootsRequestSchema,
|
|
1456
|
+
]);
|
|
1457
|
+
export const ServerNotificationSchema = v.union([
|
|
1458
|
+
CancelledNotificationSchema,
|
|
1459
|
+
ProgressNotificationSchema,
|
|
1460
|
+
LoggingMessageNotificationSchema,
|
|
1461
|
+
ResourceUpdatedNotificationSchema,
|
|
1462
|
+
ResourceListChangedNotificationSchema,
|
|
1463
|
+
ToolListChangedNotificationSchema,
|
|
1464
|
+
PromptListChangedNotificationSchema,
|
|
1465
|
+
]);
|
|
1466
|
+
export const ServerResultSchema = v.union([
|
|
1467
|
+
EmptyResultSchema,
|
|
1468
|
+
InitializeResultSchema,
|
|
1469
|
+
CompleteResultSchema,
|
|
1470
|
+
GetPromptResultSchema,
|
|
1471
|
+
ListPromptsResultSchema,
|
|
1472
|
+
ListResourcesResultSchema,
|
|
1473
|
+
ListResourceTemplatesResultSchema,
|
|
1474
|
+
ReadResourceResultSchema,
|
|
1475
|
+
CallToolResultSchema,
|
|
1476
|
+
ListToolsResultSchema,
|
|
1477
|
+
]);
|
|
365
1478
|
|
|
1479
|
+
/**
|
|
1480
|
+
* @typedef {v.InferInput<typeof ClientCapabilitiesSchema>} ClientCapabilities
|
|
1481
|
+
*/
|
|
1482
|
+
/**
|
|
1483
|
+
* @typedef {v.InferInput<typeof ServerCapabilitiesSchema>} ServerCapabilities
|
|
1484
|
+
*/
|
|
1485
|
+
/**
|
|
1486
|
+
* @typedef {v.InferInput<typeof ImplementationSchema>} ClientInfo
|
|
1487
|
+
*/
|
|
1488
|
+
/**
|
|
1489
|
+
* @typedef {v.InferInput<typeof ImplementationSchema>} ServerInfo
|
|
1490
|
+
*/
|
|
1491
|
+
/**
|
|
1492
|
+
* @typedef {v.InferInput<typeof InitializeRequestParamsSchema>} InitializeRequestParams
|
|
1493
|
+
*/
|
|
366
1494
|
/**
|
|
367
1495
|
* @typedef {v.InferInput<typeof CallToolResultSchema>} CallToolResult
|
|
368
1496
|
*/
|
|
369
|
-
|
|
370
1497
|
/**
|
|
371
1498
|
* @typedef {v.InferInput<typeof ReadResourceResultSchema>} ReadResourceResult
|
|
372
1499
|
*/
|
|
373
|
-
|
|
374
1500
|
/**
|
|
375
1501
|
* @typedef {v.InferInput<typeof GetPromptResultSchema>} GetPromptResult
|
|
376
1502
|
*/
|
|
377
|
-
|
|
378
1503
|
/**
|
|
379
1504
|
* @typedef {v.InferInput<typeof CompleteResultSchema>} CompleteResult
|
|
380
1505
|
*/
|
|
381
|
-
|
|
382
1506
|
/**
|
|
383
|
-
* @typedef {v.InferInput<typeof
|
|
1507
|
+
* @typedef {v.InferInput<typeof CreateMessageRequestParamsSchema>} CreateMessageRequestParams
|
|
384
1508
|
*/
|
|
385
|
-
|
|
386
1509
|
/**
|
|
387
1510
|
* @typedef {v.InferInput<typeof CreateMessageResultSchema>} CreateMessageResult
|
|
388
1511
|
*/
|
|
389
|
-
|
|
390
1512
|
/**
|
|
391
1513
|
* @typedef {v.InferInput<typeof ModelPreferencesSchema>} ModelPreferences
|
|
392
1514
|
*/
|
|
393
|
-
|
|
394
1515
|
/**
|
|
395
1516
|
* @typedef {v.InferInput<typeof SamplingMessageSchema>} SamplingMessage
|
|
396
1517
|
*/
|
|
397
|
-
|
|
398
1518
|
/**
|
|
399
1519
|
* @typedef {v.InferInput<typeof ModelHintSchema>} ModelHint
|
|
400
1520
|
*/
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* JSON-RPC 2.0 Request
|
|
404
|
-
*/
|
|
405
|
-
export const JSONRPCRequestSchema = v.looseObject({
|
|
406
|
-
jsonrpc: v.literal('2.0'),
|
|
407
|
-
method: v.string(),
|
|
408
|
-
params: v.optional(v.union([v.array(v.unknown()), v.looseObject({})])),
|
|
409
|
-
id: v.optional(v.union([v.string(), v.number(), v.null()])),
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
/**
|
|
413
|
-
* JSON-RPC 2.0 Response Success
|
|
414
|
-
*/
|
|
415
|
-
export const JSONRPCResponseSuccessSchema = v.looseObject({
|
|
416
|
-
jsonrpc: v.literal('2.0'),
|
|
417
|
-
result: v.unknown(),
|
|
418
|
-
id: v.union([v.string(), v.number(), v.null()]),
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* JSON-RPC 2.0 Response Error
|
|
423
|
-
*/
|
|
424
|
-
export const JSONRPCResponseErrorSchema = v.looseObject({
|
|
425
|
-
jsonrpc: v.literal('2.0'),
|
|
426
|
-
error: v.looseObject({
|
|
427
|
-
code: v.number(),
|
|
428
|
-
message: v.string(),
|
|
429
|
-
data: v.optional(v.unknown()),
|
|
430
|
-
}),
|
|
431
|
-
id: v.union([v.string(), v.number(), v.null()]),
|
|
432
|
-
});
|
|
433
|
-
|
|
434
1521
|
/**
|
|
435
|
-
*
|
|
1522
|
+
* @typedef {v.InferInput<typeof ResourceSchema>} Resource
|
|
436
1523
|
*/
|
|
437
|
-
export const JSONRPCResponseSchema = v.union([
|
|
438
|
-
JSONRPCResponseSuccessSchema,
|
|
439
|
-
JSONRPCResponseErrorSchema,
|
|
440
|
-
]);
|
|
441
|
-
|
|
442
1524
|
/**
|
|
443
1525
|
* @typedef {v.InferInput<typeof JSONRPCRequestSchema>} JSONRPCRequest
|
|
444
1526
|
*/
|
|
445
|
-
|
|
446
1527
|
/**
|
|
447
1528
|
* @typedef {v.InferInput<typeof JSONRPCResponseSchema>} JSONRPCResponse
|
|
448
1529
|
*/
|
|
1530
|
+
/**
|
|
1531
|
+
* @typedef {v.InferInput<typeof LoggingLevelSchema>} LoggingLevel
|
|
1532
|
+
*/
|