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