@effect/ai 0.18.12 → 0.18.13

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.
@@ -0,0 +1,1903 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Rpc from "@effect/rpc/Rpc"
5
+ import * as RpcGroup from "@effect/rpc/RpcGroup"
6
+ import * as Schema from "effect/Schema"
7
+
8
+ // =============================================================================
9
+ // Common
10
+ // =============================================================================
11
+
12
+ /**
13
+ * A uniquely identifying ID for a request in JSON-RPC.
14
+ *
15
+ * @since 1.0.0
16
+ * @category Common
17
+ */
18
+ export const RequestId: Schema.Union<[
19
+ typeof Schema.String,
20
+ typeof Schema.Number
21
+ ]> = Schema.Union(Schema.String, Schema.Number)
22
+
23
+ /**
24
+ * A uniquely identifying ID for a request in JSON-RPC.
25
+ *
26
+ * @since 1.0.0
27
+ * @category Common
28
+ */
29
+ export type RequestId = typeof RequestId.Type
30
+
31
+ /**
32
+ * A progress token, used to associate progress notifications with the original
33
+ * request.
34
+ *
35
+ * @since 1.0.0
36
+ * @category Common
37
+ */
38
+ export const ProgressToken: Schema.Union<[
39
+ typeof Schema.String,
40
+ typeof Schema.Number
41
+ ]> = Schema.Union(Schema.String, Schema.Number)
42
+
43
+ /**
44
+ * A progress token, used to associate progress notifications with the original
45
+ * request.
46
+ *
47
+ * @since 1.0.0
48
+ * @category Common
49
+ */
50
+ export type ProgressToken = typeof ProgressToken.Type
51
+
52
+ /**
53
+ * @since 1.0.0
54
+ * @category Common
55
+ */
56
+ export class RequestMeta extends Schema.Class<RequestMeta>(
57
+ "@effect/ai/McpSchema/RequestMeta"
58
+ )({
59
+ _meta: Schema.optional(Schema.Struct({
60
+ /**
61
+ * If specified, the caller is requesting out-of-band progress notifications
62
+ * for this request (as represented by notifications/progress). The value of
63
+ * this parameter is an opaque token that will be attached to any subsequent
64
+ * notifications. The receiver is not obligated to provide these
65
+ * notifications.
66
+ */
67
+ progressToken: Schema.optional(ProgressToken)
68
+ }))
69
+ }) {}
70
+
71
+ /**
72
+ * @since 1.0.0
73
+ * @category Common
74
+ */
75
+ export class ResultMeta extends Schema.Class<ResultMeta>(
76
+ "@effect/ai/McpSchema/ResultMeta"
77
+ )({
78
+ /**
79
+ * This result property is reserved by the protocol to allow clients and
80
+ * servers to attach additional metadata to their responses.
81
+ */
82
+ _meta: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown }))
83
+ }) {}
84
+
85
+ /**
86
+ * @since 1.0.0
87
+ * @category Common
88
+ */
89
+ export class NotificationMeta extends Schema.Class<NotificationMeta>(
90
+ "@effect/ai/McpSchema/NotificationMeta"
91
+ )({
92
+ /**
93
+ * This parameter name is reserved by MCP to allow clients and servers to
94
+ * attach additional metadata to their notifications.
95
+ */
96
+ _meta: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Unknown }))
97
+ }) {}
98
+
99
+ /**
100
+ * An opaque token used to represent a cursor for pagination.
101
+ *
102
+ * @since 1.0.0
103
+ * @category Common
104
+ */
105
+ export const Cursor: typeof Schema.String = Schema.String
106
+
107
+ /**
108
+ * @since 1.0.0
109
+ * @category Common
110
+ */
111
+ export type Cursor = typeof Cursor.Type
112
+
113
+ /**
114
+ * @since 1.0.0
115
+ * @category Common
116
+ */
117
+ export class PaginatedRequestMeta extends Schema.Class<PaginatedRequestMeta>(
118
+ "@effect/ai/McpSchema/PaginatedRequestMeta"
119
+ )({
120
+ ...RequestMeta.fields,
121
+ /**
122
+ * An opaque token representing the current pagination position.
123
+ * If provided, the server should return results starting after this cursor.
124
+ */
125
+ cursor: Schema.optional(Cursor)
126
+ }) {}
127
+
128
+ /**
129
+ * @since 1.0.0
130
+ * @category Common
131
+ */
132
+ export class PaginatedResultMeta extends Schema.Class<PaginatedResultMeta>(
133
+ "@effect/ai/McpSchema/PaginatedResultMeta"
134
+ )({
135
+ ...ResultMeta.fields,
136
+ /**
137
+ * An opaque token representing the pagination position after the last returned result.
138
+ * If present, there may be more results available.
139
+ */
140
+ nextCursor: Schema.optional(Cursor)
141
+ }) {}
142
+
143
+ /**
144
+ * The sender or recipient of messages and data in a conversation.
145
+ * @since 1.0.0
146
+ * @category Common
147
+ */
148
+ export const Role: Schema.Literal<["user", "assistant"]> = Schema.Literal("user", "assistant")
149
+
150
+ /**
151
+ * @since 1.0.0
152
+ * @category Common
153
+ */
154
+ export type Role = typeof Role.Type
155
+
156
+ /**
157
+ * Optional annotations for the client. The client can use annotations to
158
+ * inform how objects are used or displayed
159
+ *
160
+ * @since 1.0.0
161
+ * @category Common
162
+ */
163
+ export class Annotations extends Schema.Class<Annotations>(
164
+ "@effect/ai/McpSchema/Annotations"
165
+ )({
166
+ /**
167
+ * Describes who the intended customer of this object or data is.
168
+ *
169
+ * It can include multiple entries to indicate content useful for multiple
170
+ * audiences (e.g., `["user", "assistant"]`).
171
+ */
172
+ audience: Schema.optional(Schema.Array(Role)),
173
+ /**
174
+ * Describes how important this data is for operating the server.
175
+ *
176
+ * A value of 1 means "most important," and indicates that the data is
177
+ * effectively required, while 0 means "least important," and indicates that
178
+ * the data is entirely optional.
179
+ */
180
+ priority: Schema.optional(Schema.Number.pipe(Schema.between(0, 1)))
181
+ }) {}
182
+
183
+ /**
184
+ * Describes the name and version of an MCP implementation.
185
+ *
186
+ * @since 1.0.0
187
+ * @category Common
188
+ */
189
+ export class Implementation extends Schema.Class<Implementation>(
190
+ "@effect/ai/McpSchema/Implementation"
191
+ )({
192
+ name: Schema.String,
193
+ version: Schema.String
194
+ }) {}
195
+
196
+ /**
197
+ * Capabilities a client may support. Known capabilities are defined here, in
198
+ * this schema, but this is not a closed set: any client can define its own,
199
+ * additional capabilities.
200
+ *
201
+ * @since 1.0.0
202
+ * @category Common
203
+ */
204
+ export class ClientCapabilities extends Schema.Class<ClientCapabilities>(
205
+ "@effect/ai/McpSchema/ClientCapabilities"
206
+ )({
207
+ /**
208
+ * Experimental, non-standard capabilities that the client supports.
209
+ */
210
+ experimental: Schema.optional(Schema.Record({
211
+ key: Schema.String,
212
+ value: Schema.Struct({})
213
+ })),
214
+ /**
215
+ * Present if the client supports listing roots.
216
+ */
217
+ roots: Schema.optional(Schema.Struct({
218
+ /**
219
+ * Whether the client supports notifications for changes to the roots list.
220
+ */
221
+ listChanged: Schema.optional(Schema.Boolean)
222
+ })),
223
+ /**
224
+ * Present if the client supports sampling from an LLM.
225
+ */
226
+ sampling: Schema.optional(Schema.Struct({}))
227
+ }) {}
228
+
229
+ /**
230
+ * Capabilities that a server may support. Known capabilities are defined
231
+ * here, in this schema, but this is not a closed set: any server can define
232
+ * its own, additional capabilities.
233
+ *
234
+ * @since 1.0.0
235
+ * @category Common
236
+ */
237
+ export class ServerCapabilities extends Schema.Class<ServerCapabilities>(
238
+ "@effect/ai/McpSchema/ServerCapabilities"
239
+ )({
240
+ /**
241
+ * Experimental, non-standard capabilities that the server supports.
242
+ */
243
+ experimental: Schema.optional(Schema.Record({
244
+ key: Schema.String,
245
+ value: Schema.Struct({})
246
+ })),
247
+ /**
248
+ * Present if the server supports sending log messages to the client.
249
+ */
250
+ logging: Schema.optional(Schema.Struct({})),
251
+ /**
252
+ * Present if the server supports argument autocompletion suggestions.
253
+ */
254
+ completions: Schema.optional(Schema.Struct({})),
255
+ /**
256
+ * Present if the server offers any prompt templates.
257
+ */
258
+ prompts: Schema.optional(Schema.Struct({
259
+ /**
260
+ * Whether this server supports notifications for changes to the prompt list.
261
+ */
262
+ listChanged: Schema.optional(Schema.Boolean)
263
+ })),
264
+ /**
265
+ * Present if the server offers any resources to read.
266
+ */
267
+ resources: Schema.optional(Schema.Struct({
268
+ /**
269
+ * Whether this server supports subscribing to resource updates.
270
+ */
271
+ subscribe: Schema.optional(Schema.Boolean),
272
+ /**
273
+ * Whether this server supports notifications for changes to the resource list.
274
+ */
275
+ listChanged: Schema.optional(Schema.Boolean)
276
+ })),
277
+ /**
278
+ * Present if the server offers any tools to call.
279
+ */
280
+ tools: Schema.optional(Schema.Struct({
281
+ /**
282
+ * Whether this server supports notifications for changes to the tool list.
283
+ */
284
+ listChanged: Schema.optional(Schema.Boolean)
285
+ }))
286
+ }) {}
287
+
288
+ // =============================================================================
289
+ // Errors
290
+ // =============================================================================
291
+
292
+ /**
293
+ * @since 1.0.0
294
+ * @category Errors
295
+ */
296
+ export class McpError extends Schema.Class<McpError>(
297
+ "@effect/ai/McpSchema/McpError"
298
+ )({
299
+ /**
300
+ * The error type that occurred.
301
+ */
302
+ code: Schema.Number,
303
+ /**
304
+ * A short description of the error. The message SHOULD be limited to a
305
+ * concise single sentence.
306
+ */
307
+ message: Schema.String,
308
+ /**
309
+ * Additional information about the error. The value of this member is
310
+ * defined by the sender (e.g. detailed error information, nested errors etc.).
311
+ */
312
+ data: Schema.optional(Schema.Unknown)
313
+ }) {}
314
+
315
+ /**
316
+ * @since 1.0.0
317
+ * @category Errors
318
+ */
319
+ export const INVALID_REQUEST_ERROR_CODE = -32600 as const
320
+ /**
321
+ * @since 1.0.0
322
+ * @category Errors
323
+ */
324
+ export const METHOD_NOT_FOUND_ERROR_CODE = -32601 as const
325
+ /**
326
+ * @since 1.0.0
327
+ * @category Errors
328
+ */
329
+ export const INVALID_PARAMS_ERROR_CODE = -32602 as const
330
+ /**
331
+ * @since 1.0.0
332
+ * @category Errors
333
+ */
334
+ export const INTERNAL_ERROR_CODE = -32603 as const
335
+ /**
336
+ * @since 1.0.0
337
+ * @category Errors
338
+ */
339
+ export const PARSE_ERROR_CODE = -32700 as const
340
+
341
+ /**
342
+ * @since 1.0.0
343
+ * @category Errors
344
+ */
345
+ export class ParseError extends Schema.TaggedError<ParseError>()("ParseError", {
346
+ ...McpError.fields,
347
+ code: Schema.tag(PARSE_ERROR_CODE)
348
+ }) {}
349
+
350
+ /**
351
+ * @since 1.0.0
352
+ * @category Errors
353
+ */
354
+ export class InvalidRequest extends Schema.TaggedError<InvalidRequest>()("InvalidRequest", {
355
+ ...McpError.fields,
356
+ code: Schema.tag(INVALID_REQUEST_ERROR_CODE)
357
+ }) {}
358
+
359
+ /**
360
+ * @since 1.0.0
361
+ * @category Errors
362
+ */
363
+ export class MethodNotFound extends Schema.TaggedError<MethodNotFound>()("MethodNotFound", {
364
+ ...McpError.fields,
365
+ code: Schema.tag(METHOD_NOT_FOUND_ERROR_CODE)
366
+ }) {}
367
+
368
+ /**
369
+ * @since 1.0.0
370
+ * @category Errors
371
+ */
372
+ export class InvalidParams extends Schema.TaggedError<InvalidParams>()("InvalidParams", {
373
+ ...McpError.fields,
374
+ code: Schema.tag(INVALID_PARAMS_ERROR_CODE)
375
+ }) {}
376
+
377
+ /**
378
+ * @since 1.0.0
379
+ * @category Errors
380
+ */
381
+ export class InternalError extends Schema.TaggedError<InternalError>()("InternalError", {
382
+ ...McpError.fields,
383
+ code: Schema.tag(INTERNAL_ERROR_CODE)
384
+ }) {
385
+ static readonly notImplemented = new InternalError({ message: "Not implemented" })
386
+ }
387
+
388
+ // =============================================================================
389
+ // Ping
390
+ // =============================================================================
391
+
392
+ /**
393
+ * A ping, issued by either the server or the client, to check that the other
394
+ * party is still alive. The receiver must promptly respond, or else may be
395
+ * disconnected.
396
+ *
397
+ * @since 1.0.0
398
+ * @category Ping
399
+ */
400
+ export class Ping extends Rpc.make("ping", {
401
+ success: Schema.Struct({}),
402
+ error: McpError,
403
+ payload: RequestMeta
404
+ }) {}
405
+
406
+ // =============================================================================
407
+ // Initialization
408
+ // =============================================================================
409
+
410
+ /**
411
+ * After receiving an initialize request from the client, the server sends this
412
+ * response.
413
+ *
414
+ * @since 1.0.0
415
+ * @category Initialization
416
+ */
417
+ export class InitializeResult extends Schema.Class<InitializeResult>(
418
+ "@effect/ai/McpSchema/InitializeResult"
419
+ )({
420
+ ...ResultMeta.fields,
421
+ /**
422
+ * The version of the Model Context Protocol that the server wants to use.
423
+ * This may not match the version that the client requested. If the client
424
+ * cannot support this version, it MUST disconnect.
425
+ */
426
+ protocolVersion: Schema.String,
427
+ capabilities: ServerCapabilities,
428
+ serverInfo: Implementation,
429
+ /**
430
+ * Instructions describing how to use the server and its features.
431
+ *
432
+ * This can be used by clients to improve the LLM's understanding of available
433
+ * tools, resources, etc. It can be thought of like a "hint" to the model.
434
+ * For example, this information MAY be added to the system prompt.
435
+ */
436
+ instructions: Schema.optional(Schema.String)
437
+ }) {}
438
+
439
+ /**
440
+ * This request is sent from the client to the server when it first connects,
441
+ * asking it to begin initialization.
442
+ *
443
+ * @since 1.0.0
444
+ * @category Initialization
445
+ */
446
+ export class Initialize extends Rpc.make("initialize", {
447
+ success: InitializeResult,
448
+ error: McpError,
449
+ payload: {
450
+ ...RequestMeta.fields,
451
+ /**
452
+ * The latest version of the Model Context Protocol that the client
453
+ * supports. The client MAY decide to support older versions as well.
454
+ */
455
+ protocolVersion: Schema.String,
456
+ /**
457
+ * Capabilities a client may support. Known capabilities are defined here,
458
+ * in this schema, but this is not a closed set: any client can define its
459
+ * own, additional capabilities.
460
+ */
461
+ capabilities: ClientCapabilities,
462
+ /**
463
+ * Describes the name and version of an MCP implementation.
464
+ */
465
+ clientInfo: Implementation
466
+ }
467
+ }) {}
468
+
469
+ /**
470
+ * This notification is sent from the client to the server after initialization
471
+ * has finished.
472
+ *
473
+ * @since 1.0.0
474
+ * @category Initialization
475
+ */
476
+ export class InitializedNotification extends Rpc.make("notifications/initialized", {
477
+ payload: NotificationMeta
478
+ }) {}
479
+
480
+ // =============================================================================
481
+ // Cancellation
482
+ // =============================================================================
483
+
484
+ /**
485
+ * @since 1.0.0
486
+ * @category Cancellation
487
+ */
488
+ export class CancelledNotification extends Rpc.make("notifications/cancelled", {
489
+ payload: {
490
+ ...NotificationMeta.fields,
491
+ /**
492
+ * The ID of the request to cancel.
493
+ *
494
+ * This MUST correspond to the ID of a request previously issued in the
495
+ * same direction.
496
+ */
497
+ requestId: RequestId,
498
+ /**
499
+ * An optional string describing the reason for the cancellation. This MAY
500
+ * be logged or presented to the user.
501
+ */
502
+ reason: Schema.optional(Schema.String)
503
+ }
504
+ }) {}
505
+
506
+ // =============================================================================
507
+ // Progress
508
+ // =============================================================================
509
+
510
+ /**
511
+ * An out-of-band notification used to inform the receiver of a progress update
512
+ * for a long-running request.
513
+ *
514
+ * @since 1.0.0
515
+ * @category Progress
516
+ */
517
+ export class ProgressNotification extends Rpc.make("notifications/progress", {
518
+ payload: {
519
+ ...NotificationMeta.fields,
520
+ /**
521
+ * The progress token which was given in the initial request, used to
522
+ * associate this notification with the request that is proceeding.
523
+ */
524
+ progressToken: ProgressToken,
525
+ /**
526
+ * The progress thus far. This should increase every time progress is made,
527
+ * even if the total is unknown.
528
+ */
529
+ progress: Schema.optional(Schema.Number),
530
+ /**
531
+ * Total number of items to process (or total progress required), if known.
532
+ */
533
+ total: Schema.optional(Schema.Number),
534
+ /**
535
+ * An optional message describing the current progress.
536
+ */
537
+ message: Schema.optional(Schema.String)
538
+ }
539
+ }) {}
540
+
541
+ // =============================================================================
542
+ // Resources
543
+ // =============================================================================
544
+
545
+ /**
546
+ * A known resource that the server is capable of reading.
547
+ *
548
+ * @since 1.0.0
549
+ * @category Resources
550
+ */
551
+ export class Resource extends Schema.Class<Resource>(
552
+ "@effect/ai/McpSchema/Resource"
553
+ )({
554
+ /**
555
+ * The URI of this resource.
556
+ */
557
+ uri: Schema.String,
558
+ /**
559
+ * A human-readable name for this resource.
560
+ *
561
+ * This can be used by clients to populate UI elements.
562
+ */
563
+ name: Schema.String,
564
+ /**
565
+ * A description of what this resource represents.
566
+ *
567
+ * This can be used by clients to improve the LLM's understanding of available
568
+ * resources. It can be thought of like a "hint" to the model.
569
+ */
570
+ description: Schema.optional(Schema.String),
571
+ /**
572
+ * The MIME type of this resource, if known.
573
+ */
574
+ mimeType: Schema.optional(Schema.String),
575
+ /**
576
+ * Optional annotations for the client.
577
+ */
578
+ annotations: Schema.optional(Annotations),
579
+ /**
580
+ * The size of the raw resource content, in bytes (i.e., before base64
581
+ * encoding or any tokenization), if known.
582
+ *
583
+ * This can be used by Hosts to display file sizes and estimate context
584
+ * window usage.
585
+ */
586
+ size: Schema.optional(Schema.Number)
587
+ }) {}
588
+
589
+ /**
590
+ * A template description for resources available on the server.
591
+ *
592
+ * @since 1.0.0
593
+ * @category Resources
594
+ */
595
+ export class ResourceTemplate extends Schema.Class<ResourceTemplate>(
596
+ "@effect/ai/McpSchema/ResourceTemplate"
597
+ )({
598
+ /**
599
+ * A URI template (according to RFC 6570) that can be used to construct
600
+ * resource URIs.
601
+ */
602
+ uriTemplate: Schema.String,
603
+ /**
604
+ * A human-readable name for the type of resource this template refers to.
605
+ *
606
+ * This can be used by clients to populate UI elements.
607
+ */
608
+ name: Schema.String,
609
+ /**
610
+ * A description of what this template is for.
611
+ *
612
+ * This can be used by clients to improve the LLM's understanding of available
613
+ * resources. It can be thought of like a "hint" to the model.
614
+ */
615
+ description: Schema.optional(Schema.String),
616
+
617
+ /**
618
+ * The MIME type for all resources that match this template. This should only
619
+ * be included if all resources matching this template have the same type.
620
+ */
621
+ mimeType: Schema.optional(Schema.String),
622
+
623
+ /**
624
+ * Optional annotations for the client.
625
+ */
626
+ annotations: Schema.optional(Annotations)
627
+ }) {}
628
+
629
+ /**
630
+ * The contents of a specific resource or sub-resource.
631
+ *
632
+ * @since 1.0.0
633
+ * @category Resources
634
+ */
635
+ export class ResourceContents extends Schema.Class<ResourceContents>(
636
+ "@effect/ai/McpSchema/ResourceContents"
637
+ )({
638
+ /**
639
+ * The URI of this resource.
640
+ */
641
+ uri: Schema.String,
642
+ /**
643
+ * The MIME type of this resource, if known.
644
+ */
645
+ mimeType: Schema.optional(Schema.String)
646
+ }) {}
647
+
648
+ /**
649
+ * The contents of a text resource, which can be represented as a string.
650
+ *
651
+ * @since 1.0.0
652
+ * @category Resources
653
+ */
654
+ export class TextResourceContents extends ResourceContents.extend<TextResourceContents>(
655
+ "@effect/ai/McpSchema/TextResourceContents"
656
+ )({
657
+ /**
658
+ * The text of the item. This must only be set if the item can actually be
659
+ * represented as text (not binary data).
660
+ */
661
+ text: Schema.String
662
+ }) {}
663
+
664
+ /**
665
+ * The contents of a binary resource, which can be represented as an Uint8Array
666
+ *
667
+ * @since 1.0.0
668
+ * @category Resources
669
+ */
670
+ export class BlobResourceContents extends ResourceContents.extend<BlobResourceContents>(
671
+ "@effect/ai/McpSchema/BlobResourceContents"
672
+ )({
673
+ /**
674
+ * The binary data of the item decoded from a base64-encoded string.
675
+ */
676
+ blob: Schema.Uint8ArrayFromBase64
677
+ }) {}
678
+
679
+ /**
680
+ * The server's response to a resources/list request from the client.
681
+ *
682
+ * @since 1.0.0
683
+ * @category Resources
684
+ */
685
+ export class ListResourcesResult extends Schema.Class<ListResourcesResult>(
686
+ "@effect/ai/McpSchema/ListResourcesResult"
687
+ )({
688
+ ...PaginatedResultMeta.fields,
689
+ resources: Schema.Array(Resource)
690
+ }) {}
691
+
692
+ /**
693
+ * Sent from the client to request a list of resources the server has.
694
+ *
695
+ * @since 1.0.0
696
+ * @category Resources
697
+ */
698
+ export class ListResources extends Rpc.make("resources/list", {
699
+ success: ListResourcesResult,
700
+ error: McpError,
701
+ payload: PaginatedRequestMeta
702
+ }) {}
703
+
704
+ /**
705
+ * The server's response to a resources/templates/list request from the client.
706
+ *
707
+ * @since 1.0.0
708
+ * @category Resources
709
+ */
710
+ export class ListResourceTemplatesResult extends Schema.Class<ListResourceTemplatesResult>(
711
+ "@effect/ai/McpSchema/ListResourceTemplatesResult"
712
+ )({
713
+ ...PaginatedResultMeta.fields,
714
+ resourceTemplates: Schema.Array(ResourceTemplate)
715
+ }) {}
716
+
717
+ /**
718
+ * Sent from the client to request a list of resource templates the server has.
719
+ *
720
+ * @since 1.0.0
721
+ * @category Resources
722
+ */
723
+ export class ListResourceTemplates extends Rpc.make("resources/templates/list", {
724
+ success: ListResourceTemplatesResult,
725
+ error: McpError,
726
+ payload: PaginatedRequestMeta
727
+ }) {}
728
+
729
+ /**
730
+ * The server's response to a resources/read request from the client.
731
+ *
732
+ * @since 1.0.0
733
+ * @category Resources
734
+ */
735
+ export class ReadResourceResult extends Schema.Class<ReadResourceResult>(
736
+ "@effect/ai/McpSchema/ReadResourceResult"
737
+ )({
738
+ ...ResultMeta.fields,
739
+ contents: Schema.Array(Schema.Union(
740
+ TextResourceContents,
741
+ BlobResourceContents
742
+ ))
743
+ }) {}
744
+
745
+ /**
746
+ * Sent from the client to the server, to read a specific resource URI.
747
+ *
748
+ * @since 1.0.0
749
+ * @category Resources
750
+ */
751
+ export class ReadResource extends Rpc.make("resources/read", {
752
+ success: ReadResourceResult,
753
+ error: McpError,
754
+ payload: {
755
+ ...RequestMeta.fields,
756
+ /**
757
+ * The URI of the resource to read. The URI can use any protocol; it is up
758
+ * to the server how to interpret it.
759
+ */
760
+ uri: Schema.String
761
+ }
762
+ }) {}
763
+
764
+ /**
765
+ * An optional notification from the server to the client, informing it that the
766
+ * list of resources it can read from has changed. This may be issued by servers
767
+ * without any previous subscription from the client.
768
+ *
769
+ * @since 1.0.0
770
+ * @category Resources
771
+ */
772
+ export class ResourceListChangedNotification extends Rpc.make("notifications/resources/list_changed", {
773
+ payload: NotificationMeta
774
+ }) {}
775
+
776
+ /**
777
+ * Sent from the client to request resources/updated notifications from the
778
+ * server whenever a particular resource changes.
779
+ *
780
+ * @since 1.0.0
781
+ * @category Resources
782
+ */
783
+ export class Subscribe extends Rpc.make("resources/subscribe", {
784
+ error: McpError,
785
+ payload: {
786
+ ...RequestMeta.fields,
787
+ /**
788
+ * The URI of the resource to subscribe to. The URI can use any protocol;
789
+ * it is up to the server how to interpret it.
790
+ */
791
+ uri: Schema.String
792
+ }
793
+ }) {}
794
+
795
+ /**
796
+ * Sent from the client to request cancellation of resources/updated
797
+ * notifications from the server. This should follow a previous
798
+ * resources/subscribe request.
799
+ *
800
+ * @since 1.0.0
801
+ * @category Resources
802
+ */
803
+ export class Unsubscribe extends Rpc.make("resources/unsubscribe", {
804
+ error: McpError,
805
+ payload: {
806
+ ...RequestMeta.fields,
807
+ /**
808
+ * The URI of the resource to subscribe to. The URI can use any protocol;
809
+ * it is up to the server how to interpret it.
810
+ */
811
+ uri: Schema.String
812
+ }
813
+ }) {}
814
+
815
+ /**
816
+ * @since 1.0.0
817
+ * @category Resources
818
+ */
819
+ export class ResourceUpdatedNotification extends Rpc.make("notifications/resources/updated", {
820
+ payload: {
821
+ ...NotificationMeta.fields,
822
+ /**
823
+ * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
824
+ */
825
+ uri: Schema.String
826
+ }
827
+ }) {}
828
+
829
+ // =============================================================================
830
+ // Prompts
831
+ // =============================================================================
832
+
833
+ /**
834
+ * Describes an argument that a prompt can accept.
835
+ *
836
+ * @since 1.0.0
837
+ * @category Prompts
838
+ */
839
+ export class PromptArgument extends Schema.Class<PromptArgument>(
840
+ "@effect/ai/McpSchema/PromptArgument"
841
+ )({
842
+ /**
843
+ * The name of the argument.
844
+ */
845
+ name: Schema.String,
846
+ /**
847
+ * A human-readable description of the argument.
848
+ */
849
+ description: Schema.optional(Schema.String),
850
+ /**
851
+ * Whether this argument must be provided.
852
+ */
853
+ required: Schema.optional(Schema.Boolean)
854
+ }) {}
855
+
856
+ /**
857
+ * A prompt or prompt template that the server offers.
858
+ *
859
+ * @since 1.0.0
860
+ * @category Prompts
861
+ */
862
+ export class Prompt extends Schema.Class<Prompt>(
863
+ "@effect/ai/McpSchema/Prompt"
864
+ )({
865
+ /**
866
+ * The name of the prompt or prompt template.
867
+ */
868
+ name: Schema.String,
869
+ /**
870
+ * An optional description of what this prompt provides
871
+ */
872
+ description: Schema.optional(Schema.String),
873
+ /**
874
+ * A list of arguments to use for templating the prompt.
875
+ */
876
+ arguments: Schema.optional(Schema.Array(PromptArgument))
877
+ }) {}
878
+
879
+ /**
880
+ * Text provided to or from an LLM.
881
+ *
882
+ * @since 1.0.0
883
+ * @category Prompts
884
+ */
885
+ export class TextContent extends Schema.Class<TextContent>(
886
+ "@effect/ai/McpSchema/TextContent"
887
+ )({
888
+ type: Schema.tag("text"),
889
+ /**
890
+ * The text content of the message.
891
+ */
892
+ text: Schema.String,
893
+ /**
894
+ * Optional annotations for the client.
895
+ */
896
+ annotations: Schema.optional(Annotations)
897
+ }) {}
898
+
899
+ /**
900
+ * An image provided to or from an LLM.
901
+ *
902
+ * @since 1.0.0
903
+ * @category Prompts
904
+ */
905
+ export class ImageContent extends Schema.Class<ImageContent>(
906
+ "@effect/ai/McpSchema/ImageContent"
907
+ )({
908
+ type: Schema.tag("image"),
909
+ /**
910
+ * The image data.
911
+ */
912
+ data: Schema.Uint8ArrayFromBase64,
913
+ /**
914
+ * The MIME type of the image. Different providers may support different
915
+ * image types.
916
+ */
917
+ mimeType: Schema.String,
918
+ /**
919
+ * Optional annotations for the client.
920
+ */
921
+ annotations: Schema.optional(Annotations)
922
+ }) {}
923
+
924
+ /**
925
+ * Audio provided to or from an LLM.
926
+ *
927
+ * @since 1.0.0
928
+ * @category Prompts
929
+ */
930
+ export class AudioContent extends Schema.Class<AudioContent>(
931
+ "@effect/ai/McpSchema/AudioContent"
932
+ )({
933
+ type: Schema.tag("audio"),
934
+ /**
935
+ * The audio data.
936
+ */
937
+ data: Schema.Uint8ArrayFromBase64,
938
+ /**
939
+ * The MIME type of the audio. Different providers may support different
940
+ * audio types.
941
+ */
942
+ mimeType: Schema.String,
943
+ /**
944
+ * Optional annotations for the client.
945
+ */
946
+ annotations: Schema.optional(Annotations)
947
+ }) {}
948
+
949
+ /**
950
+ * The contents of a resource, embedded into a prompt or tool call result.
951
+ *
952
+ * It is up to the client how best to render embedded resources for the benefit
953
+ * of the LLM and/or the user.
954
+ *
955
+ * @since 1.0.0
956
+ * @category Prompts
957
+ */
958
+ export class EmbeddedResource extends Schema.Class<EmbeddedResource>(
959
+ "@effect/ai/McpSchema/EmbeddedResource"
960
+ )({
961
+ type: Schema.tag("resource"),
962
+ resource: Schema.Union(TextResourceContents, BlobResourceContents),
963
+ /**
964
+ * Optional annotations for the client.
965
+ */
966
+ annotations: Schema.optional(Annotations)
967
+ }) {}
968
+
969
+ /**
970
+ * Describes a message returned as part of a prompt.
971
+ *
972
+ * This is similar to `SamplingMessage`, but also supports the embedding of
973
+ * resources from the MCP server.
974
+ *
975
+ * @since 1.0.0
976
+ * @category Prompts
977
+ */
978
+ export class PromptMessage extends Schema.Class<PromptMessage>(
979
+ "@effect/ai/McpSchema/PromptMessage"
980
+ )({
981
+ role: Role,
982
+ content: Schema.Union(
983
+ TextContent,
984
+ ImageContent,
985
+ AudioContent,
986
+ EmbeddedResource
987
+ )
988
+ }) {}
989
+
990
+ /**
991
+ * The server's response to a prompts/list request from the client.
992
+ *
993
+ * @since 1.0.0
994
+ * @category Prompts
995
+ */
996
+ export class ListPromptsResult extends Schema.Class<ListPromptsResult>(
997
+ "@effect/ai/McpSchema/ListPromptsResult"
998
+ )({
999
+ ...PaginatedResultMeta.fields,
1000
+ prompts: Schema.Array(Prompt)
1001
+ }) {}
1002
+
1003
+ /**
1004
+ * Sent from the client to request a list of prompts and prompt templates the
1005
+ * server has.
1006
+ *
1007
+ * @since 1.0.0
1008
+ * @category Prompts
1009
+ */
1010
+ export class ListPrompts extends Rpc.make("prompts/list", {
1011
+ success: ListPromptsResult,
1012
+ error: McpError,
1013
+ payload: PaginatedRequestMeta
1014
+ }) {}
1015
+
1016
+ /**
1017
+ * The server's response to a prompts/get request from the client.
1018
+ *
1019
+ * @since 1.0.0
1020
+ * @category Prompts
1021
+ */
1022
+ export class GetPromptResult extends Schema.Class<GetPromptResult>(
1023
+ "@effect/ai/McpSchema/GetPromptResult"
1024
+ )({
1025
+ ...ResultMeta.fields,
1026
+ messages: Schema.Array(PromptMessage),
1027
+ /**
1028
+ * An optional description for the prompt.
1029
+ */
1030
+ description: Schema.optional(Schema.String)
1031
+ }) {}
1032
+
1033
+ /**
1034
+ * Used by the client to get a prompt provided by the server.
1035
+ *
1036
+ * @since 1.0.0
1037
+ * @category Prompts
1038
+ */
1039
+ export class GetPrompt extends Rpc.make("prompts/get", {
1040
+ success: GetPromptResult,
1041
+ error: McpError,
1042
+ payload: {
1043
+ ...RequestMeta.fields,
1044
+ /**
1045
+ * The name of the prompt or prompt template.
1046
+ */
1047
+ name: Schema.String,
1048
+ /**
1049
+ * Arguments to use for templating the prompt.
1050
+ */
1051
+ arguments: Schema.optional(Schema.Record({
1052
+ key: Schema.String,
1053
+ value: Schema.String
1054
+ }))
1055
+ }
1056
+ }) {}
1057
+
1058
+ /**
1059
+ * An optional notification from the server to the client, informing it that
1060
+ * the list of prompts it offers has changed. This may be issued by servers
1061
+ * without any previous subscription from the client.
1062
+ *
1063
+ * @since 1.0.0
1064
+ * @category Prompts
1065
+ */
1066
+ export class PromptListChangedNotification extends Rpc.make("notifications/prompts/list_changed", {
1067
+ payload: NotificationMeta
1068
+ }) {}
1069
+
1070
+ // =============================================================================
1071
+ // Tools
1072
+ // =============================================================================
1073
+
1074
+ /**
1075
+ * Additional properties describing a Tool to clients.
1076
+ *
1077
+ * NOTE: all properties in ToolAnnotations are **hints**. They are not
1078
+ * guaranteed to provide a faithful description of tool behavior (including
1079
+ * descriptive properties like `title`).
1080
+ *
1081
+ * Clients should never make tool use decisions based on ToolAnnotations
1082
+ * received from untrusted servers.
1083
+ *
1084
+ * @since 1.0.0
1085
+ * @category Tools
1086
+ */
1087
+ export class ToolAnnotations extends Schema.Class<ToolAnnotations>(
1088
+ "@effect/ai/McpSchema/ToolAnnotations"
1089
+ )({
1090
+ /**
1091
+ * A human-readable title for the tool.
1092
+ */
1093
+ title: Schema.optional(Schema.String),
1094
+ /**
1095
+ * If true, the tool does not modify its environment.
1096
+ *
1097
+ * Default: `false`
1098
+ */
1099
+ readOnlyHint: Schema.optionalWith(Schema.Boolean, { default: () => false }),
1100
+ /**
1101
+ * If true, the tool may perform destructive updates to its environment.
1102
+ * If false, the tool performs only additive updates.
1103
+ *
1104
+ * (This property is meaningful only when `readOnlyHint == false`)
1105
+ *
1106
+ * Default: `true`
1107
+ */
1108
+ destructiveHint: Schema.optionalWith(Schema.Boolean, { default: () => true }),
1109
+ /**
1110
+ * If true, calling the tool repeatedly with the same arguments
1111
+ * will have no additional effect on the its environment.
1112
+ *
1113
+ * (This property is meaningful only when `readOnlyHint == false`)
1114
+ *
1115
+ * Default: `false`
1116
+ */
1117
+ idempotentHint: Schema.optionalWith(Schema.Boolean, { default: () => false }),
1118
+ /**
1119
+ * If true, this tool may interact with an "open world" of external
1120
+ * entities. If false, the tool's domain of interaction is closed.
1121
+ * For example, the world of a web search tool is open, whereas that
1122
+ * of a memory tool is not.
1123
+ *
1124
+ * Default: `true`
1125
+ */
1126
+ openWorldHint: Schema.optionalWith(Schema.Boolean, { default: () => true })
1127
+ }) {}
1128
+
1129
+ /**
1130
+ * Definition for a tool the client can call.
1131
+ *
1132
+ * @since 1.0.0
1133
+ * @category Tools
1134
+ */
1135
+ export class Tool extends Schema.Class<Tool>(
1136
+ "@effect/ai/McpSchema/Tool"
1137
+ )({
1138
+ /**
1139
+ * The name of the tool.
1140
+ */
1141
+ name: Schema.String,
1142
+ /**
1143
+ * A human-readable description of the tool.
1144
+ *
1145
+ * This can be used by clients to improve the LLM's understanding of available tools. It can be thought of like a "hint" to the model.
1146
+ */
1147
+ description: Schema.optional(Schema.String),
1148
+ /**
1149
+ * A JSON Schema object defining the expected parameters for the tool.
1150
+ */
1151
+ inputSchema: Schema.Unknown,
1152
+ /**
1153
+ * Optional additional tool information.
1154
+ */
1155
+ annotations: Schema.optional(ToolAnnotations)
1156
+ }) {}
1157
+
1158
+ /**
1159
+ * The server's response to a tools/list request from the client.
1160
+ *
1161
+ * @since 1.0.0
1162
+ * @category Tools
1163
+ */
1164
+ export class ListToolsResult extends Schema.Class<ListToolsResult>(
1165
+ "@effect/ai/McpSchema/ListToolsResult"
1166
+ )({
1167
+ ...PaginatedResultMeta.fields,
1168
+ tools: Schema.Array(Tool)
1169
+ }) {}
1170
+
1171
+ /**
1172
+ * Sent from the client to request a list of tools the server has.
1173
+ *
1174
+ * @since 1.0.0
1175
+ * @category Tools
1176
+ */
1177
+ export class ListTools extends Rpc.make("tools/list", {
1178
+ success: ListToolsResult,
1179
+ error: McpError,
1180
+ payload: PaginatedRequestMeta
1181
+ }) {}
1182
+
1183
+ /**
1184
+ * The server's response to a tool call.
1185
+ *
1186
+ * Any errors that originate from the tool SHOULD be reported inside the result
1187
+ * object, with `isError` set to true, _not_ as an MCP protocol-level error
1188
+ * response. Otherwise, the LLM would not be able to see that an error occurred
1189
+ * and self-correct.
1190
+ *
1191
+ * However, any errors in _finding_ the tool, an error indicating that the
1192
+ * server does not support tool calls, or any other exceptional conditions,
1193
+ * should be reported as an MCP error response.
1194
+ *
1195
+ * @since 1.0.0
1196
+ * @category Tools
1197
+ */
1198
+ export class CallToolResult extends Schema.Class<CallToolResult>(
1199
+ "@effect/ai/McpSchema/CallToolResult"
1200
+ )({
1201
+ ...ResultMeta.fields,
1202
+ content: Schema.Array(Schema.Union(
1203
+ TextContent,
1204
+ ImageContent,
1205
+ AudioContent,
1206
+ EmbeddedResource
1207
+ )),
1208
+ /**
1209
+ * Whether the tool call ended in an error.
1210
+ *
1211
+ * If not set, this is assumed to be false (the call was successful).
1212
+ */
1213
+ isError: Schema.optional(Schema.Boolean)
1214
+ }) {}
1215
+
1216
+ /**
1217
+ * Used by the client to invoke a tool provided by the server.
1218
+ *
1219
+ * @since 1.0.0
1220
+ * @category Tools
1221
+ */
1222
+ export class CallTool extends Rpc.make("tools/call", {
1223
+ success: CallToolResult,
1224
+ error: McpError,
1225
+ payload: {
1226
+ ...RequestMeta.fields,
1227
+ name: Schema.String,
1228
+ arguments: Schema.Record({
1229
+ key: Schema.String,
1230
+ value: Schema.Unknown
1231
+ })
1232
+ }
1233
+ }) {}
1234
+
1235
+ /**
1236
+ * An optional notification from the server to the client, informing it that
1237
+ * the list of tools it offers has changed. This may be issued by servers
1238
+ * without any previous subscription from the client.
1239
+ *
1240
+ * @since 1.0.0
1241
+ * @category Tools
1242
+ */
1243
+ export class ToolListChangedNotification extends Rpc.make("notifications/tools/list_changed", {
1244
+ payload: NotificationMeta
1245
+ }) {}
1246
+
1247
+ // =============================================================================
1248
+ // Logging
1249
+ // =============================================================================
1250
+
1251
+ /**
1252
+ * The severity of a log message.
1253
+ *
1254
+ * These map to syslog message severities, as specified in RFC-5424:
1255
+ * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
1256
+ *
1257
+ * @since 1.0.0
1258
+ * @category Logging
1259
+ */
1260
+ export const LoggingLevel: Schema.Literal<[
1261
+ "debug",
1262
+ "info",
1263
+ "notice",
1264
+ "warning",
1265
+ "error",
1266
+ "critical",
1267
+ "alert",
1268
+ "emergency"
1269
+ ]> = Schema.Literal(
1270
+ "debug",
1271
+ "info",
1272
+ "notice",
1273
+ "warning",
1274
+ "error",
1275
+ "critical",
1276
+ "alert",
1277
+ "emergency"
1278
+ )
1279
+
1280
+ /**
1281
+ * The severity of a log message.
1282
+ *
1283
+ * These map to syslog message severities, as specified in RFC-5424:
1284
+ * https://datatracker.ietf.org/doc/html/rfc5424#section-6.2.1
1285
+ *
1286
+ * @since 1.0.0
1287
+ * @category Logging
1288
+ */
1289
+ export type LoggingLevel = typeof LoggingLevel.Type
1290
+
1291
+ /**
1292
+ * A request from the client to the server, to enable or adjust logging.
1293
+ *
1294
+ * @since 1.0.0
1295
+ * @category Logging
1296
+ */
1297
+ export class SetLevel extends Rpc.make("logging/setLevel", {
1298
+ payload: {
1299
+ ...RequestMeta.fields,
1300
+ /**
1301
+ * The level of logging that the client wants to receive from the server.
1302
+ * The server should send all logs at this level and higher (i.e., more
1303
+ * severe) to the client as notifications/message.
1304
+ */
1305
+ level: LoggingLevel
1306
+ },
1307
+ error: McpError
1308
+ }) {}
1309
+
1310
+ /**
1311
+ * @since 1.0.0
1312
+ * @category Logging
1313
+ */
1314
+ export class LoggingMessageNotification extends Rpc.make("notifications/message", {
1315
+ payload: Schema.Struct({
1316
+ ...NotificationMeta.fields,
1317
+ /**
1318
+ * The severity of this log message.
1319
+ */
1320
+ level: LoggingLevel,
1321
+ /**
1322
+ * An optional name of the logger issuing this message.
1323
+ */
1324
+ logger: Schema.optional(Schema.String),
1325
+ /**
1326
+ * The data to be logged, such as a string message or an object. Any JSON
1327
+ * serializable type is allowed here.
1328
+ */
1329
+ data: Schema.Unknown
1330
+ })
1331
+ }) {}
1332
+
1333
+ // =============================================================================
1334
+ // Sampling
1335
+ // =============================================================================
1336
+
1337
+ /**
1338
+ * Describes a message issued to or received from an LLM API.
1339
+ *
1340
+ * @since 1.0.0
1341
+ * @category Sampling
1342
+ */
1343
+ export class SamplingMessage extends Schema.Class<SamplingMessage>(
1344
+ "@effect/ai/McpSchema/SamplingMessage"
1345
+ )({
1346
+ role: Role,
1347
+ content: Schema.Union(TextContent, ImageContent, AudioContent)
1348
+ }) {}
1349
+
1350
+ /**
1351
+ * Hints to use for model selection.
1352
+ *
1353
+ * Keys not declared here are currently left unspecified by the spec and are up
1354
+ * to the client to interpret.
1355
+ *
1356
+ * @since 1.0.0
1357
+ * @category Sampling
1358
+ */
1359
+ export class ModelHint extends Schema.Class<ModelHint>(
1360
+ "@effect/ai/McpSchema/ModelHint"
1361
+ )({
1362
+ /**
1363
+ * A hint for a model name.
1364
+ *
1365
+ * The client SHOULD treat this as a substring of a model name; for example:
1366
+ * - `claude-3-5-sonnet` should match `claude-3-5-sonnet-20241022`
1367
+ * - `sonnet` should match `claude-3-5-sonnet-20241022`, `claude-3-sonnet-20240229`, etc.
1368
+ * - `claude` should match any Claude model
1369
+ *
1370
+ * The client MAY also map the string to a different provider's model name or
1371
+ * a different model family, as long as it fills a similar niche; for example:
1372
+ * - `gemini-1.5-flash` could match `claude-3-haiku-20240307`
1373
+ */
1374
+ name: Schema.optional(Schema.String)
1375
+ }) {}
1376
+
1377
+ /**
1378
+ * The server's preferences for model selection, requested of the client during sampling.
1379
+ *
1380
+ * Because LLMs can vary along multiple dimensions, choosing the "best" model is
1381
+ * rarely straightforward. Different models excel in different areas—some are
1382
+ * faster but less capable, others are more capable but more expensive, and so
1383
+ * on. This interface allows servers to express their priorities across multiple
1384
+ * dimensions to help clients make an appropriate selection for their use case.
1385
+ *
1386
+ * These preferences are always advisory. The client MAY ignore them. It is also
1387
+ * up to the client to decide how to interpret these preferences and how to
1388
+ * balance them against other considerations.
1389
+ *
1390
+ * @since 1.0.0
1391
+ * @category Sampling
1392
+ */
1393
+ export class ModelPreferences extends Schema.Class<ModelPreferences>(
1394
+ "@effect/ai/McpSchema/ModelPreferences"
1395
+ )({
1396
+ /**
1397
+ * Optional hints to use for model selection.
1398
+ *
1399
+ * If multiple hints are specified, the client MUST evaluate them in order
1400
+ * (such that the first match is taken).
1401
+ *
1402
+ * The client SHOULD prioritize these hints over the numeric priorities, but
1403
+ * MAY still use the priorities to select from ambiguous matches.
1404
+ */
1405
+ hints: Schema.optional(Schema.Array(ModelHint)),
1406
+ /**
1407
+ * How much to prioritize cost when selecting a model. A value of 0 means cost
1408
+ * is not important, while a value of 1 means cost is the most important
1409
+ * factor.
1410
+ */
1411
+ costPriority: Schema.optional(Schema.Number.pipe(Schema.between(0, 1))),
1412
+ /**
1413
+ * How much to prioritize sampling speed (latency) when selecting a model. A
1414
+ * value of 0 means speed is not important, while a value of 1 means speed is
1415
+ * the most important factor.
1416
+ */
1417
+ speedPriority: Schema.optional(Schema.Number.pipe(Schema.between(0, 1))),
1418
+ /**
1419
+ * How much to prioritize intelligence and capabilities when selecting a
1420
+ * model. A value of 0 means intelligence is not important, while a value of 1
1421
+ * means intelligence is the most important factor.
1422
+ */
1423
+ intelligencePriority: Schema.optional(Schema.Number.pipe(Schema.between(0, 1)))
1424
+ }) {}
1425
+
1426
+ /**
1427
+ * The client's response to a sampling/create_message request from the server.
1428
+ * The client should inform the user before returning the sampled message, to
1429
+ * allow them to inspect the response (human in the loop) and decide whether to
1430
+ * allow the server to see it.
1431
+ *
1432
+ * @since 1.0.0
1433
+ * @category Sampling
1434
+ */
1435
+ export class CreateMessageResult extends Schema.Class<CreateMessageResult>(
1436
+ "@effect/ai/McpSchema/CreateMessageResult"
1437
+ )({
1438
+ /**
1439
+ * The name of the model that generated the message.
1440
+ */
1441
+ model: Schema.String,
1442
+ /**
1443
+ * The reason why sampling stopped, if known.
1444
+ */
1445
+ stopReason: Schema.optional(Schema.String)
1446
+ }) {}
1447
+
1448
+ /**
1449
+ * A request from the server to sample an LLM via the client. The client has
1450
+ * full discretion over which model to select. The client should also inform the
1451
+ * user before beginning sampling, to allow them to inspect the request (human
1452
+ * in the loop) and decide whether to approve it.
1453
+ *
1454
+ * @since 1.0.0
1455
+ * @category Sampling
1456
+ */
1457
+ export class CreateMessage extends Rpc.make("sampling/createMessage", {
1458
+ success: CreateMessageResult,
1459
+ error: McpError,
1460
+ payload: {
1461
+ messages: Schema.Array(SamplingMessage),
1462
+ /**
1463
+ * The server's preferences for which model to select. The client MAY ignore
1464
+ * these preferences.
1465
+ */
1466
+ modelPreferences: Schema.optional(ModelPreferences),
1467
+ /**
1468
+ * An optional system prompt the server wants to use for sampling. The
1469
+ * client MAY modify or omit this prompt.
1470
+ */
1471
+ systemPrompt: Schema.optional(Schema.String),
1472
+ /**
1473
+ * A request to include context from one or more MCP servers (including the
1474
+ * caller), to be attached to the prompt. The client MAY ignore this request.
1475
+ */
1476
+ includeContext: Schema.optional(Schema.Literal("none", "thisServer", "allServers")),
1477
+ temperature: Schema.optional(Schema.Number),
1478
+ /**
1479
+ * The maximum number of tokens to sample, as requested by the server. The
1480
+ * client MAY choose to sample fewer tokens than requested.
1481
+ */
1482
+ maxTokens: Schema.Number,
1483
+ stopSequences: Schema.optional(Schema.Array(Schema.String)),
1484
+ /**
1485
+ * Optional metadata to pass through to the LLM provider. The format of
1486
+ * this metadata is provider-specific.
1487
+ */
1488
+ metadata: Schema.Unknown
1489
+ }
1490
+ }) {}
1491
+
1492
+ // =============================================================================
1493
+ // Autocomplete
1494
+ // =============================================================================
1495
+
1496
+ /**
1497
+ * A reference to a resource or resource template definition.
1498
+ *
1499
+ * @since 1.0.0
1500
+ * @category Autocomplete
1501
+ */
1502
+ export class ResourceReference extends Schema.Class<ResourceReference>(
1503
+ "@effect/ai/McpSchema/ResourceReference"
1504
+ )({
1505
+ type: Schema.tag("ref/resource"),
1506
+ /**
1507
+ * The URI or URI template of the resource.
1508
+ */
1509
+ uri: Schema.String
1510
+ }) {}
1511
+
1512
+ /**
1513
+ * Identifies a prompt.
1514
+ *
1515
+ * @since 1.0.0
1516
+ * @category Autocomplete
1517
+ */
1518
+ export class PromptReference extends Schema.Class<PromptReference>(
1519
+ "@effect/ai/McpSchema/PromptReference"
1520
+ )({
1521
+ type: Schema.tag("ref/prompt"),
1522
+ /**
1523
+ * The name of the prompt or prompt template
1524
+ */
1525
+ name: Schema.String
1526
+ }) {}
1527
+
1528
+ /**
1529
+ * The server's response to a completion/complete request
1530
+ *
1531
+ * @since 1.0.0
1532
+ * @category Autocomplete
1533
+ */
1534
+ export class CompleteResult extends Schema.Class<CompleteResult>(
1535
+ "@effect/ai/McpSchema/CompleteResult"
1536
+ )({
1537
+ completion: Schema.Struct({
1538
+ /**
1539
+ * An array of completion values. Must not exceed 100 items.
1540
+ */
1541
+ values: Schema.Array(Schema.String),
1542
+ /**
1543
+ * The total number of completion options available. This can exceed the
1544
+ * number of values actually sent in the response.
1545
+ */
1546
+ total: Schema.optional(Schema.Number),
1547
+ /**
1548
+ * Indicates whether there are additional completion options beyond those
1549
+ * provided in the current response, even if the exact total is unknown.
1550
+ */
1551
+ hasMore: Schema.optional(Schema.Boolean)
1552
+ })
1553
+ }) {
1554
+ /**
1555
+ * @since 1.0.0
1556
+ */
1557
+ static readonly empty = new CompleteResult({
1558
+ completion: {
1559
+ values: [],
1560
+ total: 0,
1561
+ hasMore: false
1562
+ }
1563
+ })
1564
+ }
1565
+
1566
+ /**
1567
+ * A request from the client to the server, to ask for completion options.
1568
+ *
1569
+ * @since 1.0.0
1570
+ * @category Autocomplete
1571
+ */
1572
+ export class Complete extends Rpc.make("completion/complete", {
1573
+ success: CompleteResult,
1574
+ error: McpError,
1575
+ payload: {
1576
+ ref: Schema.Union(PromptReference, ResourceReference),
1577
+ /**
1578
+ * The argument's information
1579
+ */
1580
+ argument: Schema.Struct({
1581
+ /**
1582
+ * The name of the argument
1583
+ */
1584
+ name: Schema.String,
1585
+ /**
1586
+ * The value of the argument to use for completion matching.
1587
+ */
1588
+ value: Schema.String
1589
+ })
1590
+ }
1591
+ }) {}
1592
+
1593
+ // =============================================================================
1594
+ // Roots
1595
+ // =============================================================================
1596
+
1597
+ /**
1598
+ * Represents a root directory or file that the server can operate on.
1599
+ *
1600
+ * @since 1.0.0
1601
+ * @category Roots
1602
+ */
1603
+ export class Root extends Schema.Class<Root>(
1604
+ "@effect/ai/McpSchema/Root"
1605
+ )({
1606
+ /**
1607
+ * The URI identifying the root. This *must* start with file:// for now.
1608
+ * This restriction may be relaxed in future versions of the protocol to allow
1609
+ * other URI schemes.
1610
+ */
1611
+ uri: Schema.String,
1612
+ /**
1613
+ * An optional name for the root. This can be used to provide a human-readable
1614
+ * identifier for the root, which may be useful for display purposes or for
1615
+ * referencing the root in other parts of the application.
1616
+ */
1617
+ name: Schema.optional(Schema.String)
1618
+ }) {}
1619
+
1620
+ /**
1621
+ * The client's response to a roots/list request from the server. This result
1622
+ * contains an array of Root objects, each representing a root directory or file
1623
+ * that the server can operate on.
1624
+ *
1625
+ * @since 1.0.0
1626
+ * @category Roots
1627
+ */
1628
+ export class ListRootsResult extends Schema.Class<ListRootsResult>(
1629
+ "@effect/ai/McpSchema/ListRootsResult"
1630
+ )({
1631
+ roots: Schema.Array(Root)
1632
+ }) {}
1633
+
1634
+ /**
1635
+ * Sent from the server to request a list of root URIs from the client. Roots
1636
+ * allow servers to ask for specific directories or files to operate on. A
1637
+ * common example for roots is providing a set of repositories or directories a
1638
+ * server should operate
1639
+ * on.
1640
+ *
1641
+ * This request is typically used when the server needs to understand the file
1642
+ * system structure or access specific locations that the client has permission
1643
+ * to read from.
1644
+ *
1645
+ * @since 1.0.0
1646
+ * @category Roots
1647
+ */
1648
+ export class ListRoots extends Rpc.make("roots/list", {
1649
+ success: ListRootsResult,
1650
+ error: McpError,
1651
+ payload: RequestMeta
1652
+ }) {}
1653
+
1654
+ /**
1655
+ * A notification from the client to the server, informing it that the list of
1656
+ * roots has changed. This notification should be sent whenever the client adds,
1657
+ * removes, or modifies any root. The server should then request an updated list
1658
+ * of roots using the ListRootsRequest.
1659
+ *
1660
+ * @since 1.0.0
1661
+ * @category Roots
1662
+ */
1663
+ export class RootsListChangedNotification extends Rpc.make("notifications/roots/list_changed", {
1664
+ payload: NotificationMeta
1665
+ }) {}
1666
+
1667
+ // =============================================================================
1668
+ // Protocol
1669
+ // =============================================================================
1670
+
1671
+ /**
1672
+ * @since 1.0.0
1673
+ * @category Protocol
1674
+ */
1675
+ export type RequestEncoded<Group extends RpcGroup.Any> = RpcGroup.Rpcs<
1676
+ Group
1677
+ > extends infer Rpc ? Rpc extends Rpc.Rpc<
1678
+ infer _Tag,
1679
+ infer _Payload,
1680
+ infer _Success,
1681
+ infer _Error,
1682
+ infer _Middleware
1683
+ > ? {
1684
+ readonly _tag: "Request"
1685
+ readonly id: string | number
1686
+ readonly method: _Tag
1687
+ readonly payload: _Payload["Encoded"]
1688
+ }
1689
+ : never
1690
+ : never
1691
+
1692
+ /**
1693
+ * @since 1.0.0
1694
+ * @category Protocol
1695
+ */
1696
+ export type NotificationEncoded<Group extends RpcGroup.Any> = RpcGroup.Rpcs<
1697
+ Group
1698
+ > extends infer Rpc ? Rpc extends Rpc.Rpc<
1699
+ infer _Tag,
1700
+ infer _Payload,
1701
+ infer _Success,
1702
+ infer _Error,
1703
+ infer _Middleware
1704
+ > ? {
1705
+ readonly _tag: "Notification"
1706
+ readonly method: _Tag
1707
+ readonly payload: _Payload["Encoded"]
1708
+ }
1709
+ : never
1710
+ : never
1711
+
1712
+ /**
1713
+ * @since 1.0.0
1714
+ * @category Protocol
1715
+ */
1716
+ export type SuccessEncoded<Group extends RpcGroup.Any> = RpcGroup.Rpcs<
1717
+ Group
1718
+ > extends infer Rpc ? Rpc extends Rpc.Rpc<
1719
+ infer _Tag,
1720
+ infer _Payload,
1721
+ infer _Success,
1722
+ infer _Error,
1723
+ infer _Middleware
1724
+ > ? {
1725
+ readonly _tag: "Success"
1726
+ readonly id: string | number
1727
+ readonly result: _Success["Encoded"]
1728
+ }
1729
+ : never
1730
+ : never
1731
+
1732
+ /**
1733
+ * @since 1.0.0
1734
+ * @category Protocol
1735
+ */
1736
+ export type FailureEncoded<Group extends RpcGroup.Any> = RpcGroup.Rpcs<
1737
+ Group
1738
+ > extends infer Rpc ? Rpc extends Rpc.Rpc<
1739
+ infer _Tag,
1740
+ infer _Payload,
1741
+ infer _Success,
1742
+ infer _Error,
1743
+ infer _Middleware
1744
+ > ? {
1745
+ readonly _tag: "Failure"
1746
+ readonly id: string | number
1747
+ readonly error: _Error["Encoded"]
1748
+ }
1749
+ : never
1750
+ : never
1751
+
1752
+ /**
1753
+ * @since 1.0.0
1754
+ * @category Protocol
1755
+ */
1756
+ export class ClientRequestRpcs extends RpcGroup.make(
1757
+ Ping,
1758
+ Initialize,
1759
+ Complete,
1760
+ SetLevel,
1761
+ GetPrompt,
1762
+ ListPrompts,
1763
+ ListResources,
1764
+ ListResourceTemplates,
1765
+ ReadResource,
1766
+ Subscribe,
1767
+ Unsubscribe,
1768
+ CallTool,
1769
+ ListTools
1770
+ ) {}
1771
+
1772
+ /**
1773
+ * @since 1.0.0
1774
+ * @category Protocol
1775
+ */
1776
+ export type ClientRequestEncoded = RequestEncoded<typeof ClientRequestRpcs>
1777
+
1778
+ /**
1779
+ * @since 1.0.0
1780
+ * @category Protocol
1781
+ */
1782
+ export class ClientNotificationRpcs extends RpcGroup.make(
1783
+ CancelledNotification,
1784
+ ProgressNotification,
1785
+ InitializedNotification,
1786
+ RootsListChangedNotification
1787
+ ) {}
1788
+
1789
+ /**
1790
+ * @since 1.0.0
1791
+ * @category Protocol
1792
+ */
1793
+ export type ClientNotificationEncoded = NotificationEncoded<typeof ClientNotificationRpcs>
1794
+
1795
+ /**
1796
+ * @since 1.0.0
1797
+ * @category Protocol
1798
+ */
1799
+ export class ClientRpcs extends ClientRequestRpcs.merge(ClientNotificationRpcs) {}
1800
+
1801
+ /**
1802
+ * @since 1.0.0
1803
+ * @category Protocol
1804
+ */
1805
+ export type ClientSuccessEncoded = SuccessEncoded<typeof ServerRequestRpcs>
1806
+
1807
+ /**
1808
+ * @since 1.0.0
1809
+ * @category Protocol
1810
+ */
1811
+ export type ClientFailureEncoded = FailureEncoded<typeof ServerRequestRpcs>
1812
+
1813
+ /**
1814
+ * @since 1.0.0
1815
+ * @category Protocol
1816
+ */
1817
+ export class ServerRequestRpcs extends RpcGroup.make(
1818
+ Ping,
1819
+ CreateMessage,
1820
+ ListRoots
1821
+ ) {}
1822
+
1823
+ /**
1824
+ * @since 1.0.0
1825
+ * @category Protocol
1826
+ */
1827
+ export type ServerRequestEncoded = RequestEncoded<typeof ServerRequestRpcs>
1828
+
1829
+ /**
1830
+ * @since 1.0.0
1831
+ * @category Protocol
1832
+ */
1833
+ export class ServerNotificationRpcs extends RpcGroup.make(
1834
+ CancelledNotification,
1835
+ ProgressNotification,
1836
+ LoggingMessageNotification,
1837
+ ResourceUpdatedNotification,
1838
+ ResourceListChangedNotification,
1839
+ ToolListChangedNotification,
1840
+ PromptListChangedNotification
1841
+ ) {}
1842
+
1843
+ /**
1844
+ * @since 1.0.0
1845
+ * @category Protocol
1846
+ */
1847
+ export type ServerNotificationEncoded = NotificationEncoded<typeof ServerNotificationRpcs>
1848
+
1849
+ /**
1850
+ * @since 1.0.0
1851
+ * @category Protocol
1852
+ */
1853
+ export type ServerSuccessEncoded = SuccessEncoded<typeof ClientRequestRpcs>
1854
+
1855
+ /**
1856
+ * @since 1.0.0
1857
+ * @category Protocol
1858
+ */
1859
+ export type ServerFailureEncoded = FailureEncoded<typeof ClientRequestRpcs>
1860
+
1861
+ /**
1862
+ * @since 1.0.0
1863
+ * @category Protocol
1864
+ */
1865
+ export type ServerResultEncoded = ServerSuccessEncoded | ServerFailureEncoded
1866
+
1867
+ /**
1868
+ * @since 1.0.0
1869
+ * @category Protocol
1870
+ */
1871
+ export type FromClientEncoded = ClientRequestEncoded | ClientNotificationEncoded
1872
+ /**
1873
+ * @since 1.0.0
1874
+ * @category Protocol
1875
+ */
1876
+ export type FromServerEncoded = ServerResultEncoded | ServerNotificationEncoded
1877
+
1878
+ /**
1879
+ * @since 1.0.0
1880
+ * @category Parameters
1881
+ */
1882
+ export const ParamAnnotation: unique symbol = Symbol.for("@effect/ai/McpSchema/ParamNameId")
1883
+
1884
+ /**
1885
+ * @since 1.0.0
1886
+ * @category Parameters
1887
+ */
1888
+ export interface Param<Id extends string, S extends Schema.Schema.Any>
1889
+ extends Schema.Schema<S["Type"], S["Encoded"], S["Context"]>
1890
+ {
1891
+ readonly [ParamAnnotation]: Id
1892
+ }
1893
+
1894
+ /**
1895
+ * Helper to create a param for a resource URI template.
1896
+ *
1897
+ * @since 1.0.0
1898
+ * @category Parameters
1899
+ */
1900
+ export const param = <const Id extends string, S extends Schema.Schema.Any>(id: Id, schema: S): Param<Id, S> =>
1901
+ schema.annotations({
1902
+ [ParamAnnotation]: id
1903
+ }) as any