@alcyone-labs/arg-parser 1.1.0 → 1.2.0

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.
Files changed (60) hide show
  1. package/README.md +150 -24
  2. package/dist/index.cjs +21863 -2500
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.min.mjs +14541 -1827
  5. package/dist/index.min.mjs.map +1 -1
  6. package/dist/index.mjs +21865 -2502
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/src/ArgParser.d.ts +2 -10
  9. package/dist/src/ArgParser.d.ts.map +1 -1
  10. package/dist/src/ArgParserBase.d.ts.map +1 -1
  11. package/dist/src/mcp-integration.d.ts.map +1 -1
  12. package/dist/src/types.d.ts +11 -0
  13. package/dist/src/types.d.ts.map +1 -1
  14. package/package.json +25 -5
  15. package/dist/examples/fuzzy-demo.d.ts +0 -8
  16. package/dist/examples/fuzzy-demo.d.ts.map +0 -1
  17. package/dist/examples/fuzzy-test-example.d.ts +0 -8
  18. package/dist/examples/fuzzy-test-example.d.ts.map +0 -1
  19. package/dist/examples/fzf-search-cli.d.ts +0 -8
  20. package/dist/examples/fzf-search-cli.d.ts.map +0 -1
  21. package/dist/examples/getting-started.d.ts +0 -27
  22. package/dist/examples/getting-started.d.ts.map +0 -1
  23. package/dist/examples/mcp-preset-transports.d.ts +0 -19
  24. package/dist/examples/mcp-preset-transports.d.ts.map +0 -1
  25. package/dist/examples/simple-cli.d.ts +0 -26
  26. package/dist/examples/simple-cli.d.ts.map +0 -1
  27. package/dist/examples/v1.1.0-showcase.d.ts +0 -16
  28. package/dist/examples/v1.1.0-showcase.d.ts.map +0 -1
  29. package/dist/examples/with-env-example.d.ts +0 -3
  30. package/dist/examples/with-env-example.d.ts.map +0 -1
  31. package/dist/index-6G9StDO_.js +0 -6445
  32. package/dist/index-6G9StDO_.js.map +0 -1
  33. package/dist/index-CqU7Fj3C.cjs +0 -6444
  34. package/dist/index-CqU7Fj3C.cjs.map +0 -1
  35. package/dist/index-Dx_q1msW.js +0 -4682
  36. package/dist/index-Dx_q1msW.js.map +0 -1
  37. package/dist/sse-B5Jf_YpG.cjs +0 -121
  38. package/dist/sse-B5Jf_YpG.cjs.map +0 -1
  39. package/dist/sse-BDL3h2Ll.js +0 -121
  40. package/dist/sse-BDL3h2Ll.js.map +0 -1
  41. package/dist/sse-DSjLfGFo.js +0 -107
  42. package/dist/sse-DSjLfGFo.js.map +0 -1
  43. package/dist/stdio-Cf19UQO7.js +0 -70
  44. package/dist/stdio-Cf19UQO7.js.map +0 -1
  45. package/dist/stdio-DESvSONI.cjs +0 -94
  46. package/dist/stdio-DESvSONI.cjs.map +0 -1
  47. package/dist/stdio-DLOResWr.js +0 -94
  48. package/dist/stdio-DLOResWr.js.map +0 -1
  49. package/dist/streamableHttp-DXIdDSbF.js +0 -342
  50. package/dist/streamableHttp-DXIdDSbF.js.map +0 -1
  51. package/dist/streamableHttp-DsXlAnqJ.cjs +0 -456
  52. package/dist/streamableHttp-DsXlAnqJ.cjs.map +0 -1
  53. package/dist/streamableHttp-Vd4Qsgko.js +0 -456
  54. package/dist/streamableHttp-Vd4Qsgko.js.map +0 -1
  55. package/dist/types-DSxPEImy.cjs +0 -943
  56. package/dist/types-DSxPEImy.cjs.map +0 -1
  57. package/dist/types-DdsPVLQ5.js +0 -846
  58. package/dist/types-DdsPVLQ5.js.map +0 -1
  59. package/dist/types-DpK81FWv.js +0 -944
  60. package/dist/types-DpK81FWv.js.map +0 -1
@@ -1,944 +0,0 @@
1
- import { z } from "zod";
2
- const LATEST_PROTOCOL_VERSION = "2025-06-18";
3
- const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
4
- const SUPPORTED_PROTOCOL_VERSIONS = [
5
- LATEST_PROTOCOL_VERSION,
6
- "2025-03-26",
7
- "2024-11-05",
8
- "2024-10-07"
9
- ];
10
- const JSONRPC_VERSION = "2.0";
11
- const ProgressTokenSchema = z.union([z.string(), z.number().int()]);
12
- const CursorSchema = z.string();
13
- const RequestMetaSchema = z.object({
14
- /**
15
- * 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.
16
- */
17
- progressToken: z.optional(ProgressTokenSchema)
18
- }).passthrough();
19
- const BaseRequestParamsSchema = z.object({
20
- _meta: z.optional(RequestMetaSchema)
21
- }).passthrough();
22
- const RequestSchema = z.object({
23
- method: z.string(),
24
- params: z.optional(BaseRequestParamsSchema)
25
- });
26
- const BaseNotificationParamsSchema = z.object({
27
- /**
28
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
29
- * for notes on _meta usage.
30
- */
31
- _meta: z.optional(z.object({}).passthrough())
32
- }).passthrough();
33
- const NotificationSchema = z.object({
34
- method: z.string(),
35
- params: z.optional(BaseNotificationParamsSchema)
36
- });
37
- const ResultSchema = z.object({
38
- /**
39
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
40
- * for notes on _meta usage.
41
- */
42
- _meta: z.optional(z.object({}).passthrough())
43
- }).passthrough();
44
- const RequestIdSchema = z.union([z.string(), z.number().int()]);
45
- const JSONRPCRequestSchema = z.object({
46
- jsonrpc: z.literal(JSONRPC_VERSION),
47
- id: RequestIdSchema
48
- }).merge(RequestSchema).strict();
49
- const isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
50
- const JSONRPCNotificationSchema = z.object({
51
- jsonrpc: z.literal(JSONRPC_VERSION)
52
- }).merge(NotificationSchema).strict();
53
- const JSONRPCResponseSchema = z.object({
54
- jsonrpc: z.literal(JSONRPC_VERSION),
55
- id: RequestIdSchema,
56
- result: ResultSchema
57
- }).strict();
58
- const isJSONRPCResponse = (value) => JSONRPCResponseSchema.safeParse(value).success;
59
- var ErrorCode;
60
- (function(ErrorCode2) {
61
- ErrorCode2[ErrorCode2["ConnectionClosed"] = -32e3] = "ConnectionClosed";
62
- ErrorCode2[ErrorCode2["RequestTimeout"] = -32001] = "RequestTimeout";
63
- ErrorCode2[ErrorCode2["ParseError"] = -32700] = "ParseError";
64
- ErrorCode2[ErrorCode2["InvalidRequest"] = -32600] = "InvalidRequest";
65
- ErrorCode2[ErrorCode2["MethodNotFound"] = -32601] = "MethodNotFound";
66
- ErrorCode2[ErrorCode2["InvalidParams"] = -32602] = "InvalidParams";
67
- ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
68
- })(ErrorCode || (ErrorCode = {}));
69
- const JSONRPCErrorSchema = z.object({
70
- jsonrpc: z.literal(JSONRPC_VERSION),
71
- id: RequestIdSchema,
72
- error: z.object({
73
- /**
74
- * The error type that occurred.
75
- */
76
- code: z.number().int(),
77
- /**
78
- * A short description of the error. The message SHOULD be limited to a concise single sentence.
79
- */
80
- message: z.string(),
81
- /**
82
- * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
83
- */
84
- data: z.optional(z.unknown())
85
- })
86
- }).strict();
87
- const isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
88
- const JSONRPCMessageSchema = z.union([
89
- JSONRPCRequestSchema,
90
- JSONRPCNotificationSchema,
91
- JSONRPCResponseSchema,
92
- JSONRPCErrorSchema
93
- ]);
94
- const EmptyResultSchema = ResultSchema.strict();
95
- const CancelledNotificationSchema = NotificationSchema.extend({
96
- method: z.literal("notifications/cancelled"),
97
- params: BaseNotificationParamsSchema.extend({
98
- /**
99
- * The ID of the request to cancel.
100
- *
101
- * This MUST correspond to the ID of a request previously issued in the same direction.
102
- */
103
- requestId: RequestIdSchema,
104
- /**
105
- * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
106
- */
107
- reason: z.string().optional()
108
- })
109
- });
110
- const BaseMetadataSchema = z.object({
111
- /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
112
- name: z.string(),
113
- /**
114
- * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
115
- * even by those unfamiliar with domain-specific terminology.
116
- *
117
- * If not provided, the name should be used for display (except for Tool,
118
- * where `annotations.title` should be given precedence over using `name`,
119
- * if present).
120
- */
121
- title: z.optional(z.string())
122
- }).passthrough();
123
- const ImplementationSchema = BaseMetadataSchema.extend({
124
- version: z.string()
125
- });
126
- const ClientCapabilitiesSchema = z.object({
127
- /**
128
- * Experimental, non-standard capabilities that the client supports.
129
- */
130
- experimental: z.optional(z.object({}).passthrough()),
131
- /**
132
- * Present if the client supports sampling from an LLM.
133
- */
134
- sampling: z.optional(z.object({}).passthrough()),
135
- /**
136
- * Present if the client supports eliciting user input.
137
- */
138
- elicitation: z.optional(z.object({}).passthrough()),
139
- /**
140
- * Present if the client supports listing roots.
141
- */
142
- roots: z.optional(z.object({
143
- /**
144
- * Whether the client supports issuing notifications for changes to the roots list.
145
- */
146
- listChanged: z.optional(z.boolean())
147
- }).passthrough())
148
- }).passthrough();
149
- const InitializeRequestSchema = RequestSchema.extend({
150
- method: z.literal("initialize"),
151
- params: BaseRequestParamsSchema.extend({
152
- /**
153
- * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
154
- */
155
- protocolVersion: z.string(),
156
- capabilities: ClientCapabilitiesSchema,
157
- clientInfo: ImplementationSchema
158
- })
159
- });
160
- const isInitializeRequest = (value) => InitializeRequestSchema.safeParse(value).success;
161
- const ServerCapabilitiesSchema = z.object({
162
- /**
163
- * Experimental, non-standard capabilities that the server supports.
164
- */
165
- experimental: z.optional(z.object({}).passthrough()),
166
- /**
167
- * Present if the server supports sending log messages to the client.
168
- */
169
- logging: z.optional(z.object({}).passthrough()),
170
- /**
171
- * Present if the server supports sending completions to the client.
172
- */
173
- completions: z.optional(z.object({}).passthrough()),
174
- /**
175
- * Present if the server offers any prompt templates.
176
- */
177
- prompts: z.optional(z.object({
178
- /**
179
- * Whether this server supports issuing notifications for changes to the prompt list.
180
- */
181
- listChanged: z.optional(z.boolean())
182
- }).passthrough()),
183
- /**
184
- * Present if the server offers any resources to read.
185
- */
186
- resources: z.optional(z.object({
187
- /**
188
- * Whether this server supports clients subscribing to resource updates.
189
- */
190
- subscribe: z.optional(z.boolean()),
191
- /**
192
- * Whether this server supports issuing notifications for changes to the resource list.
193
- */
194
- listChanged: z.optional(z.boolean())
195
- }).passthrough()),
196
- /**
197
- * Present if the server offers any tools to call.
198
- */
199
- tools: z.optional(z.object({
200
- /**
201
- * Whether this server supports issuing notifications for changes to the tool list.
202
- */
203
- listChanged: z.optional(z.boolean())
204
- }).passthrough())
205
- }).passthrough();
206
- const InitializeResultSchema = ResultSchema.extend({
207
- /**
208
- * 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.
209
- */
210
- protocolVersion: z.string(),
211
- capabilities: ServerCapabilitiesSchema,
212
- serverInfo: ImplementationSchema,
213
- /**
214
- * Instructions describing how to use the server and its features.
215
- *
216
- * 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.
217
- */
218
- instructions: z.optional(z.string())
219
- });
220
- const InitializedNotificationSchema = NotificationSchema.extend({
221
- method: z.literal("notifications/initialized")
222
- });
223
- const PingRequestSchema = RequestSchema.extend({
224
- method: z.literal("ping")
225
- });
226
- const ProgressSchema = z.object({
227
- /**
228
- * The progress thus far. This should increase every time progress is made, even if the total is unknown.
229
- */
230
- progress: z.number(),
231
- /**
232
- * Total number of items to process (or total progress required), if known.
233
- */
234
- total: z.optional(z.number()),
235
- /**
236
- * An optional message describing the current progress.
237
- */
238
- message: z.optional(z.string())
239
- }).passthrough();
240
- const ProgressNotificationSchema = NotificationSchema.extend({
241
- method: z.literal("notifications/progress"),
242
- params: BaseNotificationParamsSchema.merge(ProgressSchema).extend({
243
- /**
244
- * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
245
- */
246
- progressToken: ProgressTokenSchema
247
- })
248
- });
249
- const PaginatedRequestSchema = RequestSchema.extend({
250
- params: BaseRequestParamsSchema.extend({
251
- /**
252
- * An opaque token representing the current pagination position.
253
- * If provided, the server should return results starting after this cursor.
254
- */
255
- cursor: z.optional(CursorSchema)
256
- }).optional()
257
- });
258
- const PaginatedResultSchema = ResultSchema.extend({
259
- /**
260
- * An opaque token representing the pagination position after the last returned result.
261
- * If present, there may be more results available.
262
- */
263
- nextCursor: z.optional(CursorSchema)
264
- });
265
- const ResourceContentsSchema = z.object({
266
- /**
267
- * The URI of this resource.
268
- */
269
- uri: z.string(),
270
- /**
271
- * The MIME type of this resource, if known.
272
- */
273
- mimeType: z.optional(z.string()),
274
- /**
275
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
276
- * for notes on _meta usage.
277
- */
278
- _meta: z.optional(z.object({}).passthrough())
279
- }).passthrough();
280
- const TextResourceContentsSchema = ResourceContentsSchema.extend({
281
- /**
282
- * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
283
- */
284
- text: z.string()
285
- });
286
- const BlobResourceContentsSchema = ResourceContentsSchema.extend({
287
- /**
288
- * A base64-encoded string representing the binary data of the item.
289
- */
290
- blob: z.string().base64()
291
- });
292
- const ResourceSchema = BaseMetadataSchema.extend({
293
- /**
294
- * The URI of this resource.
295
- */
296
- uri: z.string(),
297
- /**
298
- * A description of what this resource represents.
299
- *
300
- * 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.
301
- */
302
- description: z.optional(z.string()),
303
- /**
304
- * The MIME type of this resource, if known.
305
- */
306
- mimeType: z.optional(z.string()),
307
- /**
308
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
309
- * for notes on _meta usage.
310
- */
311
- _meta: z.optional(z.object({}).passthrough())
312
- });
313
- const ResourceTemplateSchema = BaseMetadataSchema.extend({
314
- /**
315
- * A URI template (according to RFC 6570) that can be used to construct resource URIs.
316
- */
317
- uriTemplate: z.string(),
318
- /**
319
- * A description of what this template is for.
320
- *
321
- * 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.
322
- */
323
- description: z.optional(z.string()),
324
- /**
325
- * 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.
326
- */
327
- mimeType: z.optional(z.string()),
328
- /**
329
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
330
- * for notes on _meta usage.
331
- */
332
- _meta: z.optional(z.object({}).passthrough())
333
- });
334
- const ListResourcesRequestSchema = PaginatedRequestSchema.extend({
335
- method: z.literal("resources/list")
336
- });
337
- const ListResourcesResultSchema = PaginatedResultSchema.extend({
338
- resources: z.array(ResourceSchema)
339
- });
340
- const ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({
341
- method: z.literal("resources/templates/list")
342
- });
343
- const ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({
344
- resourceTemplates: z.array(ResourceTemplateSchema)
345
- });
346
- const ReadResourceRequestSchema = RequestSchema.extend({
347
- method: z.literal("resources/read"),
348
- params: BaseRequestParamsSchema.extend({
349
- /**
350
- * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
351
- */
352
- uri: z.string()
353
- })
354
- });
355
- const ReadResourceResultSchema = ResultSchema.extend({
356
- contents: z.array(z.union([TextResourceContentsSchema, BlobResourceContentsSchema]))
357
- });
358
- const ResourceListChangedNotificationSchema = NotificationSchema.extend({
359
- method: z.literal("notifications/resources/list_changed")
360
- });
361
- const SubscribeRequestSchema = RequestSchema.extend({
362
- method: z.literal("resources/subscribe"),
363
- params: BaseRequestParamsSchema.extend({
364
- /**
365
- * The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.
366
- */
367
- uri: z.string()
368
- })
369
- });
370
- const UnsubscribeRequestSchema = RequestSchema.extend({
371
- method: z.literal("resources/unsubscribe"),
372
- params: BaseRequestParamsSchema.extend({
373
- /**
374
- * The URI of the resource to unsubscribe from.
375
- */
376
- uri: z.string()
377
- })
378
- });
379
- const ResourceUpdatedNotificationSchema = NotificationSchema.extend({
380
- method: z.literal("notifications/resources/updated"),
381
- params: BaseNotificationParamsSchema.extend({
382
- /**
383
- * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
384
- */
385
- uri: z.string()
386
- })
387
- });
388
- const PromptArgumentSchema = z.object({
389
- /**
390
- * The name of the argument.
391
- */
392
- name: z.string(),
393
- /**
394
- * A human-readable description of the argument.
395
- */
396
- description: z.optional(z.string()),
397
- /**
398
- * Whether this argument must be provided.
399
- */
400
- required: z.optional(z.boolean())
401
- }).passthrough();
402
- const PromptSchema = BaseMetadataSchema.extend({
403
- /**
404
- * An optional description of what this prompt provides
405
- */
406
- description: z.optional(z.string()),
407
- /**
408
- * A list of arguments to use for templating the prompt.
409
- */
410
- arguments: z.optional(z.array(PromptArgumentSchema)),
411
- /**
412
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
413
- * for notes on _meta usage.
414
- */
415
- _meta: z.optional(z.object({}).passthrough())
416
- });
417
- const ListPromptsRequestSchema = PaginatedRequestSchema.extend({
418
- method: z.literal("prompts/list")
419
- });
420
- const ListPromptsResultSchema = PaginatedResultSchema.extend({
421
- prompts: z.array(PromptSchema)
422
- });
423
- const GetPromptRequestSchema = RequestSchema.extend({
424
- method: z.literal("prompts/get"),
425
- params: BaseRequestParamsSchema.extend({
426
- /**
427
- * The name of the prompt or prompt template.
428
- */
429
- name: z.string(),
430
- /**
431
- * Arguments to use for templating the prompt.
432
- */
433
- arguments: z.optional(z.record(z.string()))
434
- })
435
- });
436
- const TextContentSchema = z.object({
437
- type: z.literal("text"),
438
- /**
439
- * The text content of the message.
440
- */
441
- text: z.string(),
442
- /**
443
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
444
- * for notes on _meta usage.
445
- */
446
- _meta: z.optional(z.object({}).passthrough())
447
- }).passthrough();
448
- const ImageContentSchema = z.object({
449
- type: z.literal("image"),
450
- /**
451
- * The base64-encoded image data.
452
- */
453
- data: z.string().base64(),
454
- /**
455
- * The MIME type of the image. Different providers may support different image types.
456
- */
457
- mimeType: z.string(),
458
- /**
459
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
460
- * for notes on _meta usage.
461
- */
462
- _meta: z.optional(z.object({}).passthrough())
463
- }).passthrough();
464
- const AudioContentSchema = z.object({
465
- type: z.literal("audio"),
466
- /**
467
- * The base64-encoded audio data.
468
- */
469
- data: z.string().base64(),
470
- /**
471
- * The MIME type of the audio. Different providers may support different audio types.
472
- */
473
- mimeType: z.string(),
474
- /**
475
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
476
- * for notes on _meta usage.
477
- */
478
- _meta: z.optional(z.object({}).passthrough())
479
- }).passthrough();
480
- const EmbeddedResourceSchema = z.object({
481
- type: z.literal("resource"),
482
- resource: z.union([TextResourceContentsSchema, BlobResourceContentsSchema]),
483
- /**
484
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
485
- * for notes on _meta usage.
486
- */
487
- _meta: z.optional(z.object({}).passthrough())
488
- }).passthrough();
489
- const ResourceLinkSchema = ResourceSchema.extend({
490
- type: z.literal("resource_link")
491
- });
492
- const ContentBlockSchema = z.union([
493
- TextContentSchema,
494
- ImageContentSchema,
495
- AudioContentSchema,
496
- ResourceLinkSchema,
497
- EmbeddedResourceSchema
498
- ]);
499
- const PromptMessageSchema = z.object({
500
- role: z.enum(["user", "assistant"]),
501
- content: ContentBlockSchema
502
- }).passthrough();
503
- const GetPromptResultSchema = ResultSchema.extend({
504
- /**
505
- * An optional description for the prompt.
506
- */
507
- description: z.optional(z.string()),
508
- messages: z.array(PromptMessageSchema)
509
- });
510
- const PromptListChangedNotificationSchema = NotificationSchema.extend({
511
- method: z.literal("notifications/prompts/list_changed")
512
- });
513
- const ToolAnnotationsSchema = z.object({
514
- /**
515
- * A human-readable title for the tool.
516
- */
517
- title: z.optional(z.string()),
518
- /**
519
- * If true, the tool does not modify its environment.
520
- *
521
- * Default: false
522
- */
523
- readOnlyHint: z.optional(z.boolean()),
524
- /**
525
- * If true, the tool may perform destructive updates to its environment.
526
- * If false, the tool performs only additive updates.
527
- *
528
- * (This property is meaningful only when `readOnlyHint == false`)
529
- *
530
- * Default: true
531
- */
532
- destructiveHint: z.optional(z.boolean()),
533
- /**
534
- * If true, calling the tool repeatedly with the same arguments
535
- * will have no additional effect on the its environment.
536
- *
537
- * (This property is meaningful only when `readOnlyHint == false`)
538
- *
539
- * Default: false
540
- */
541
- idempotentHint: z.optional(z.boolean()),
542
- /**
543
- * If true, this tool may interact with an "open world" of external
544
- * entities. If false, the tool's domain of interaction is closed.
545
- * For example, the world of a web search tool is open, whereas that
546
- * of a memory tool is not.
547
- *
548
- * Default: true
549
- */
550
- openWorldHint: z.optional(z.boolean())
551
- }).passthrough();
552
- const ToolSchema = BaseMetadataSchema.extend({
553
- /**
554
- * A human-readable description of the tool.
555
- */
556
- description: z.optional(z.string()),
557
- /**
558
- * A JSON Schema object defining the expected parameters for the tool.
559
- */
560
- inputSchema: z.object({
561
- type: z.literal("object"),
562
- properties: z.optional(z.object({}).passthrough()),
563
- required: z.optional(z.array(z.string()))
564
- }).passthrough(),
565
- /**
566
- * An optional JSON Schema object defining the structure of the tool's output returned in
567
- * the structuredContent field of a CallToolResult.
568
- */
569
- outputSchema: z.optional(z.object({
570
- type: z.literal("object"),
571
- properties: z.optional(z.object({}).passthrough()),
572
- required: z.optional(z.array(z.string()))
573
- }).passthrough()),
574
- /**
575
- * Optional additional tool information.
576
- */
577
- annotations: z.optional(ToolAnnotationsSchema),
578
- /**
579
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
580
- * for notes on _meta usage.
581
- */
582
- _meta: z.optional(z.object({}).passthrough())
583
- });
584
- const ListToolsRequestSchema = PaginatedRequestSchema.extend({
585
- method: z.literal("tools/list")
586
- });
587
- const ListToolsResultSchema = PaginatedResultSchema.extend({
588
- tools: z.array(ToolSchema)
589
- });
590
- const CallToolResultSchema = ResultSchema.extend({
591
- /**
592
- * A list of content objects that represent the result of the tool call.
593
- *
594
- * If the Tool does not define an outputSchema, this field MUST be present in the result.
595
- * For backwards compatibility, this field is always present, but it may be empty.
596
- */
597
- content: z.array(ContentBlockSchema).default([]),
598
- /**
599
- * An object containing structured tool output.
600
- *
601
- * If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
602
- */
603
- structuredContent: z.object({}).passthrough().optional(),
604
- /**
605
- * Whether the tool call ended in an error.
606
- *
607
- * If not set, this is assumed to be false (the call was successful).
608
- *
609
- * Any errors that originate from the tool SHOULD be reported inside the result
610
- * object, with `isError` set to true, _not_ as an MCP protocol-level error
611
- * response. Otherwise, the LLM would not be able to see that an error occurred
612
- * and self-correct.
613
- *
614
- * However, any errors in _finding_ the tool, an error indicating that the
615
- * server does not support tool calls, or any other exceptional conditions,
616
- * should be reported as an MCP error response.
617
- */
618
- isError: z.optional(z.boolean())
619
- });
620
- CallToolResultSchema.or(ResultSchema.extend({
621
- toolResult: z.unknown()
622
- }));
623
- const CallToolRequestSchema = RequestSchema.extend({
624
- method: z.literal("tools/call"),
625
- params: BaseRequestParamsSchema.extend({
626
- name: z.string(),
627
- arguments: z.optional(z.record(z.unknown()))
628
- })
629
- });
630
- const ToolListChangedNotificationSchema = NotificationSchema.extend({
631
- method: z.literal("notifications/tools/list_changed")
632
- });
633
- const LoggingLevelSchema = z.enum([
634
- "debug",
635
- "info",
636
- "notice",
637
- "warning",
638
- "error",
639
- "critical",
640
- "alert",
641
- "emergency"
642
- ]);
643
- const SetLevelRequestSchema = RequestSchema.extend({
644
- method: z.literal("logging/setLevel"),
645
- params: BaseRequestParamsSchema.extend({
646
- /**
647
- * 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.
648
- */
649
- level: LoggingLevelSchema
650
- })
651
- });
652
- const LoggingMessageNotificationSchema = NotificationSchema.extend({
653
- method: z.literal("notifications/message"),
654
- params: BaseNotificationParamsSchema.extend({
655
- /**
656
- * The severity of this log message.
657
- */
658
- level: LoggingLevelSchema,
659
- /**
660
- * An optional name of the logger issuing this message.
661
- */
662
- logger: z.optional(z.string()),
663
- /**
664
- * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
665
- */
666
- data: z.unknown()
667
- })
668
- });
669
- const ModelHintSchema = z.object({
670
- /**
671
- * A hint for a model name.
672
- */
673
- name: z.string().optional()
674
- }).passthrough();
675
- const ModelPreferencesSchema = z.object({
676
- /**
677
- * Optional hints to use for model selection.
678
- */
679
- hints: z.optional(z.array(ModelHintSchema)),
680
- /**
681
- * How much to prioritize cost when selecting a model.
682
- */
683
- costPriority: z.optional(z.number().min(0).max(1)),
684
- /**
685
- * How much to prioritize sampling speed (latency) when selecting a model.
686
- */
687
- speedPriority: z.optional(z.number().min(0).max(1)),
688
- /**
689
- * How much to prioritize intelligence and capabilities when selecting a model.
690
- */
691
- intelligencePriority: z.optional(z.number().min(0).max(1))
692
- }).passthrough();
693
- const SamplingMessageSchema = z.object({
694
- role: z.enum(["user", "assistant"]),
695
- content: z.union([TextContentSchema, ImageContentSchema, AudioContentSchema])
696
- }).passthrough();
697
- const CreateMessageRequestSchema = RequestSchema.extend({
698
- method: z.literal("sampling/createMessage"),
699
- params: BaseRequestParamsSchema.extend({
700
- messages: z.array(SamplingMessageSchema),
701
- /**
702
- * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
703
- */
704
- systemPrompt: z.optional(z.string()),
705
- /**
706
- * 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.
707
- */
708
- includeContext: z.optional(z.enum(["none", "thisServer", "allServers"])),
709
- temperature: z.optional(z.number()),
710
- /**
711
- * The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.
712
- */
713
- maxTokens: z.number().int(),
714
- stopSequences: z.optional(z.array(z.string())),
715
- /**
716
- * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
717
- */
718
- metadata: z.optional(z.object({}).passthrough()),
719
- /**
720
- * The server's preferences for which model to select.
721
- */
722
- modelPreferences: z.optional(ModelPreferencesSchema)
723
- })
724
- });
725
- const CreateMessageResultSchema = ResultSchema.extend({
726
- /**
727
- * The name of the model that generated the message.
728
- */
729
- model: z.string(),
730
- /**
731
- * The reason why sampling stopped.
732
- */
733
- stopReason: z.optional(z.enum(["endTurn", "stopSequence", "maxTokens"]).or(z.string())),
734
- role: z.enum(["user", "assistant"]),
735
- content: z.discriminatedUnion("type", [
736
- TextContentSchema,
737
- ImageContentSchema,
738
- AudioContentSchema
739
- ])
740
- });
741
- const BooleanSchemaSchema = z.object({
742
- type: z.literal("boolean"),
743
- title: z.optional(z.string()),
744
- description: z.optional(z.string()),
745
- default: z.optional(z.boolean())
746
- }).passthrough();
747
- const StringSchemaSchema = z.object({
748
- type: z.literal("string"),
749
- title: z.optional(z.string()),
750
- description: z.optional(z.string()),
751
- minLength: z.optional(z.number()),
752
- maxLength: z.optional(z.number()),
753
- format: z.optional(z.enum(["email", "uri", "date", "date-time"]))
754
- }).passthrough();
755
- const NumberSchemaSchema = z.object({
756
- type: z.enum(["number", "integer"]),
757
- title: z.optional(z.string()),
758
- description: z.optional(z.string()),
759
- minimum: z.optional(z.number()),
760
- maximum: z.optional(z.number())
761
- }).passthrough();
762
- const EnumSchemaSchema = z.object({
763
- type: z.literal("string"),
764
- title: z.optional(z.string()),
765
- description: z.optional(z.string()),
766
- enum: z.array(z.string()),
767
- enumNames: z.optional(z.array(z.string()))
768
- }).passthrough();
769
- const PrimitiveSchemaDefinitionSchema = z.union([
770
- BooleanSchemaSchema,
771
- StringSchemaSchema,
772
- NumberSchemaSchema,
773
- EnumSchemaSchema
774
- ]);
775
- const ElicitRequestSchema = RequestSchema.extend({
776
- method: z.literal("elicitation/create"),
777
- params: BaseRequestParamsSchema.extend({
778
- /**
779
- * The message to present to the user.
780
- */
781
- message: z.string(),
782
- /**
783
- * The schema for the requested user input.
784
- */
785
- requestedSchema: z.object({
786
- type: z.literal("object"),
787
- properties: z.record(z.string(), PrimitiveSchemaDefinitionSchema),
788
- required: z.optional(z.array(z.string()))
789
- }).passthrough()
790
- })
791
- });
792
- const ElicitResultSchema = ResultSchema.extend({
793
- /**
794
- * The user's response action.
795
- */
796
- action: z.enum(["accept", "reject", "cancel"]),
797
- /**
798
- * The collected user input content (only present if action is "accept").
799
- */
800
- content: z.optional(z.record(z.string(), z.unknown()))
801
- });
802
- const ResourceTemplateReferenceSchema = z.object({
803
- type: z.literal("ref/resource"),
804
- /**
805
- * The URI or URI template of the resource.
806
- */
807
- uri: z.string()
808
- }).passthrough();
809
- const PromptReferenceSchema = z.object({
810
- type: z.literal("ref/prompt"),
811
- /**
812
- * The name of the prompt or prompt template
813
- */
814
- name: z.string()
815
- }).passthrough();
816
- const CompleteRequestSchema = RequestSchema.extend({
817
- method: z.literal("completion/complete"),
818
- params: BaseRequestParamsSchema.extend({
819
- ref: z.union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
820
- /**
821
- * The argument's information
822
- */
823
- argument: z.object({
824
- /**
825
- * The name of the argument
826
- */
827
- name: z.string(),
828
- /**
829
- * The value of the argument to use for completion matching.
830
- */
831
- value: z.string()
832
- }).passthrough(),
833
- context: z.optional(z.object({
834
- /**
835
- * Previously-resolved variables in a URI template or prompt.
836
- */
837
- arguments: z.optional(z.record(z.string(), z.string()))
838
- }))
839
- })
840
- });
841
- const CompleteResultSchema = ResultSchema.extend({
842
- completion: z.object({
843
- /**
844
- * An array of completion values. Must not exceed 100 items.
845
- */
846
- values: z.array(z.string()).max(100),
847
- /**
848
- * The total number of completion options available. This can exceed the number of values actually sent in the response.
849
- */
850
- total: z.optional(z.number().int()),
851
- /**
852
- * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
853
- */
854
- hasMore: z.optional(z.boolean())
855
- }).passthrough()
856
- });
857
- const RootSchema = z.object({
858
- /**
859
- * The URI identifying the root. This *must* start with file:// for now.
860
- */
861
- uri: z.string().startsWith("file://"),
862
- /**
863
- * An optional name for the root.
864
- */
865
- name: z.optional(z.string()),
866
- /**
867
- * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
868
- * for notes on _meta usage.
869
- */
870
- _meta: z.optional(z.object({}).passthrough())
871
- }).passthrough();
872
- const ListRootsRequestSchema = RequestSchema.extend({
873
- method: z.literal("roots/list")
874
- });
875
- const ListRootsResultSchema = ResultSchema.extend({
876
- roots: z.array(RootSchema)
877
- });
878
- const RootsListChangedNotificationSchema = NotificationSchema.extend({
879
- method: z.literal("notifications/roots/list_changed")
880
- });
881
- z.union([
882
- PingRequestSchema,
883
- InitializeRequestSchema,
884
- CompleteRequestSchema,
885
- SetLevelRequestSchema,
886
- GetPromptRequestSchema,
887
- ListPromptsRequestSchema,
888
- ListResourcesRequestSchema,
889
- ListResourceTemplatesRequestSchema,
890
- ReadResourceRequestSchema,
891
- SubscribeRequestSchema,
892
- UnsubscribeRequestSchema,
893
- CallToolRequestSchema,
894
- ListToolsRequestSchema
895
- ]);
896
- z.union([
897
- CancelledNotificationSchema,
898
- ProgressNotificationSchema,
899
- InitializedNotificationSchema,
900
- RootsListChangedNotificationSchema
901
- ]);
902
- z.union([
903
- EmptyResultSchema,
904
- CreateMessageResultSchema,
905
- ElicitResultSchema,
906
- ListRootsResultSchema
907
- ]);
908
- z.union([
909
- PingRequestSchema,
910
- CreateMessageRequestSchema,
911
- ElicitRequestSchema,
912
- ListRootsRequestSchema
913
- ]);
914
- z.union([
915
- CancelledNotificationSchema,
916
- ProgressNotificationSchema,
917
- LoggingMessageNotificationSchema,
918
- ResourceUpdatedNotificationSchema,
919
- ResourceListChangedNotificationSchema,
920
- ToolListChangedNotificationSchema,
921
- PromptListChangedNotificationSchema
922
- ]);
923
- z.union([
924
- EmptyResultSchema,
925
- InitializeResultSchema,
926
- CompleteResultSchema,
927
- GetPromptResultSchema,
928
- ListPromptsResultSchema,
929
- ListResourcesResultSchema,
930
- ListResourceTemplatesResultSchema,
931
- ReadResourceResultSchema,
932
- CallToolResultSchema,
933
- ListToolsResultSchema
934
- ]);
935
- export {
936
- DEFAULT_NEGOTIATED_PROTOCOL_VERSION as D,
937
- JSONRPCMessageSchema as J,
938
- SUPPORTED_PROTOCOL_VERSIONS as S,
939
- isJSONRPCRequest as a,
940
- isJSONRPCResponse as b,
941
- isJSONRPCError as c,
942
- isInitializeRequest as i
943
- };
944
- //# sourceMappingURL=types-DpK81FWv.js.map