-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathschema.go
3169 lines (2777 loc) · 112 KB
/
schema.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT.
package mcp
import "encoding/json"
import "fmt"
import "reflect"
// Base for objects that include optional annotations for the client. The client
// can use annotations to inform how objects are used or displayed
type Annotated struct {
// Annotations corresponds to the JSON schema field "annotations".
Annotations *AnnotatedAnnotations `json:"annotations,omitempty" yaml:"annotations,omitempty" mapstructure:"annotations,omitempty"`
}
type AnnotatedAnnotations struct {
// Describes who the intended customer of this object or data is.
//
// It can include multiple entries to indicate content useful for multiple
// audiences (e.g., `["user", "assistant"]`).
Audience []Role `json:"audience,omitempty" yaml:"audience,omitempty" mapstructure:"audience,omitempty"`
// Describes how important this data is for operating the server.
//
// A value of 1 means "most important," and indicates that the data is
// effectively required, while 0 means "least important," and indicates that
// the data is entirely optional.
Priority *float64 `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *AnnotatedAnnotations) UnmarshalJSON(b []byte) error {
type Plain AnnotatedAnnotations
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
if plain.Priority != nil && 1 < *plain.Priority {
return fmt.Errorf("field %s: must be <= %v", "priority", 1)
}
if plain.Priority != nil && 0 > *plain.Priority {
return fmt.Errorf("field %s: must be >= %v", "priority", 0)
}
*j = AnnotatedAnnotations(plain)
return nil
}
type BlobResourceContents struct {
// A base64-encoded string representing the binary data of the item.
Blob string `json:"blob" yaml:"blob" mapstructure:"blob"`
// The MIME type of this resource, if known.
MimeType *string `json:"mimeType,omitempty" yaml:"mimeType,omitempty" mapstructure:"mimeType,omitempty"`
// The URI of this resource.
Uri string `json:"uri" yaml:"uri" mapstructure:"uri"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *BlobResourceContents) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["blob"]; raw != nil && !ok {
return fmt.Errorf("field blob in BlobResourceContents: required")
}
if _, ok := raw["uri"]; raw != nil && !ok {
return fmt.Errorf("field uri in BlobResourceContents: required")
}
type Plain BlobResourceContents
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = BlobResourceContents(plain)
return nil
}
// Used by the client to invoke a tool provided by the server.
type CallToolRequest struct {
// Method corresponds to the JSON schema field "method".
Method string `json:"method" yaml:"method" mapstructure:"method"`
// Params corresponds to the JSON schema field "params".
Params CallToolRequestParams `json:"params" yaml:"params" mapstructure:"params"`
}
type CallToolRequestParams struct {
// Arguments corresponds to the JSON schema field "arguments".
Arguments CallToolRequestParamsArguments `json:"arguments,omitempty" yaml:"arguments,omitempty" mapstructure:"arguments,omitempty"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
}
type CallToolRequestParamsArguments map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CallToolRequestParams) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["name"]; raw != nil && !ok {
return fmt.Errorf("field name in CallToolRequestParams: required")
}
type Plain CallToolRequestParams
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CallToolRequestParams(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CallToolRequest) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["method"]; raw != nil && !ok {
return fmt.Errorf("field method in CallToolRequest: required")
}
if _, ok := raw["params"]; raw != nil && !ok {
return fmt.Errorf("field params in CallToolRequest: required")
}
type Plain CallToolRequest
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CallToolRequest(plain)
return nil
}
// The server's response to a tool call.
//
// Any errors that originate from the tool SHOULD be reported inside the result
// object, with `isError` set to true, _not_ as an MCP protocol-level error
// response. Otherwise, the LLM would not be able to see that an error occurred
// and self-correct.
//
// However, any errors in _finding_ the tool, an error indicating that the
// server does not support tool calls, or any other exceptional conditions,
// should be reported as an MCP error response.
type CallToolResult struct {
// This result property is reserved by the protocol to allow clients and servers
// to attach additional metadata to their responses.
Meta CallToolResultMeta `json:"_meta,omitempty" yaml:"_meta,omitempty" mapstructure:"_meta,omitempty"`
// Content corresponds to the JSON schema field "content".
Content []interface{} `json:"content" yaml:"content" mapstructure:"content"`
// Whether the tool call ended in an error.
//
// If not set, this is assumed to be false (the call was successful).
IsError *bool `json:"isError,omitempty" yaml:"isError,omitempty" mapstructure:"isError,omitempty"`
}
// This result property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
type CallToolResultMeta map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CallToolResult) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["content"]; raw != nil && !ok {
return fmt.Errorf("field content in CallToolResult: required")
}
type Plain CallToolResult
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CallToolResult(plain)
return nil
}
// This notification can be sent by either side to indicate that it is cancelling a
// previously-issued request.
//
// The request SHOULD still be in-flight, but due to communication latency, it is
// always possible that this notification MAY arrive after the request has already
// finished.
//
// This notification indicates that the result will be unused, so any associated
// processing SHOULD cease.
//
// A client MUST NOT attempt to cancel its `initialize` request.
type CancelledNotification struct {
// Method corresponds to the JSON schema field "method".
Method string `json:"method" yaml:"method" mapstructure:"method"`
// Params corresponds to the JSON schema field "params".
Params CancelledNotificationParams `json:"params" yaml:"params" mapstructure:"params"`
}
type CancelledNotificationParams struct {
// An optional string describing the reason for the cancellation. This MAY be
// logged or presented to the user.
Reason *string `json:"reason,omitempty" yaml:"reason,omitempty" mapstructure:"reason,omitempty"`
// The ID of the request to cancel.
//
// This MUST correspond to the ID of a request previously issued in the same
// direction.
RequestId RequestId `json:"requestId" yaml:"requestId" mapstructure:"requestId"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CancelledNotificationParams) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["requestId"]; raw != nil && !ok {
return fmt.Errorf("field requestId in CancelledNotificationParams: required")
}
type Plain CancelledNotificationParams
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CancelledNotificationParams(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CancelledNotification) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["method"]; raw != nil && !ok {
return fmt.Errorf("field method in CancelledNotification: required")
}
if _, ok := raw["params"]; raw != nil && !ok {
return fmt.Errorf("field params in CancelledNotification: required")
}
type Plain CancelledNotification
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CancelledNotification(plain)
return nil
}
// Capabilities a client may support. Known capabilities are defined here, in this
// schema, but this is not a closed set: any client can define its own, additional
// capabilities.
type ClientCapabilities struct {
// Experimental, non-standard capabilities that the client supports.
Experimental ClientCapabilitiesExperimental `json:"experimental,omitempty" yaml:"experimental,omitempty" mapstructure:"experimental,omitempty"`
// Present if the client supports listing roots.
Roots *ClientCapabilitiesRoots `json:"roots,omitempty" yaml:"roots,omitempty" mapstructure:"roots,omitempty"`
// Present if the client supports sampling from an LLM.
Sampling ClientCapabilitiesSampling `json:"sampling,omitempty" yaml:"sampling,omitempty" mapstructure:"sampling,omitempty"`
}
// Experimental, non-standard capabilities that the client supports.
type ClientCapabilitiesExperimental map[string]map[string]interface{}
// Present if the client supports listing roots.
type ClientCapabilitiesRoots struct {
// Whether the client supports notifications for changes to the roots list.
ListChanged *bool `json:"listChanged,omitempty" yaml:"listChanged,omitempty" mapstructure:"listChanged,omitempty"`
}
// Present if the client supports sampling from an LLM.
type ClientCapabilitiesSampling map[string]interface{}
type ClientNotification interface{}
type ClientRequest interface{}
type ClientResult interface{}
// A request from the client to the server, to ask for completion options.
type CompleteRequest struct {
// Method corresponds to the JSON schema field "method".
Method string `json:"method" yaml:"method" mapstructure:"method"`
// Params corresponds to the JSON schema field "params".
Params CompleteRequestParams `json:"params" yaml:"params" mapstructure:"params"`
}
type CompleteRequestParams struct {
// The argument's information
Argument CompleteRequestParamsArgument `json:"argument" yaml:"argument" mapstructure:"argument"`
// Ref corresponds to the JSON schema field "ref".
Ref interface{} `json:"ref" yaml:"ref" mapstructure:"ref"`
}
// The argument's information
type CompleteRequestParamsArgument struct {
// The name of the argument
Name string `json:"name" yaml:"name" mapstructure:"name"`
// The value of the argument to use for completion matching.
Value string `json:"value" yaml:"value" mapstructure:"value"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CompleteRequestParamsArgument) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["name"]; raw != nil && !ok {
return fmt.Errorf("field name in CompleteRequestParamsArgument: required")
}
if _, ok := raw["value"]; raw != nil && !ok {
return fmt.Errorf("field value in CompleteRequestParamsArgument: required")
}
type Plain CompleteRequestParamsArgument
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CompleteRequestParamsArgument(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CompleteRequestParams) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["argument"]; raw != nil && !ok {
return fmt.Errorf("field argument in CompleteRequestParams: required")
}
if _, ok := raw["ref"]; raw != nil && !ok {
return fmt.Errorf("field ref in CompleteRequestParams: required")
}
type Plain CompleteRequestParams
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CompleteRequestParams(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CompleteRequest) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["method"]; raw != nil && !ok {
return fmt.Errorf("field method in CompleteRequest: required")
}
if _, ok := raw["params"]; raw != nil && !ok {
return fmt.Errorf("field params in CompleteRequest: required")
}
type Plain CompleteRequest
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CompleteRequest(plain)
return nil
}
// The server's response to a completion/complete request
type CompleteResult struct {
// This result property is reserved by the protocol to allow clients and servers
// to attach additional metadata to their responses.
Meta CompleteResultMeta `json:"_meta,omitempty" yaml:"_meta,omitempty" mapstructure:"_meta,omitempty"`
// Completion corresponds to the JSON schema field "completion".
Completion CompleteResultCompletion `json:"completion" yaml:"completion" mapstructure:"completion"`
}
type CompleteResultCompletion struct {
// Indicates whether there are additional completion options beyond those provided
// in the current response, even if the exact total is unknown.
HasMore *bool `json:"hasMore,omitempty" yaml:"hasMore,omitempty" mapstructure:"hasMore,omitempty"`
// The total number of completion options available. This can exceed the number of
// values actually sent in the response.
Total *int `json:"total,omitempty" yaml:"total,omitempty" mapstructure:"total,omitempty"`
// An array of completion values. Must not exceed 100 items.
Values []string `json:"values" yaml:"values" mapstructure:"values"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CompleteResultCompletion) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["values"]; raw != nil && !ok {
return fmt.Errorf("field values in CompleteResultCompletion: required")
}
type Plain CompleteResultCompletion
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CompleteResultCompletion(plain)
return nil
}
// This result property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
type CompleteResultMeta map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CompleteResult) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["completion"]; raw != nil && !ok {
return fmt.Errorf("field completion in CompleteResult: required")
}
type Plain CompleteResult
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CompleteResult(plain)
return nil
}
// A request from the server to sample an LLM via the client. The client has full
// discretion over which model to select. The client should also inform the user
// before beginning sampling, to allow them to inspect the request (human in the
// loop) and decide whether to approve it.
type CreateMessageRequest struct {
// Method corresponds to the JSON schema field "method".
Method string `json:"method" yaml:"method" mapstructure:"method"`
// Params corresponds to the JSON schema field "params".
Params CreateMessageRequestParams `json:"params" yaml:"params" mapstructure:"params"`
}
type CreateMessageRequestParams struct {
// 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.
IncludeContext *CreateMessageRequestParamsIncludeContext `json:"includeContext,omitempty" yaml:"includeContext,omitempty" mapstructure:"includeContext,omitempty"`
// The maximum number of tokens to sample, as requested by the server. The client
// MAY choose to sample fewer tokens than requested.
MaxTokens int `json:"maxTokens" yaml:"maxTokens" mapstructure:"maxTokens"`
// Messages corresponds to the JSON schema field "messages".
Messages []SamplingMessage `json:"messages" yaml:"messages" mapstructure:"messages"`
// Optional metadata to pass through to the LLM provider. The format of this
// metadata is provider-specific.
Metadata CreateMessageRequestParamsMetadata `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata,omitempty"`
// The server's preferences for which model to select. The client MAY ignore these
// preferences.
ModelPreferences *ModelPreferences `json:"modelPreferences,omitempty" yaml:"modelPreferences,omitempty" mapstructure:"modelPreferences,omitempty"`
// StopSequences corresponds to the JSON schema field "stopSequences".
StopSequences []string `json:"stopSequences,omitempty" yaml:"stopSequences,omitempty" mapstructure:"stopSequences,omitempty"`
// An optional system prompt the server wants to use for sampling. The client MAY
// modify or omit this prompt.
SystemPrompt *string `json:"systemPrompt,omitempty" yaml:"systemPrompt,omitempty" mapstructure:"systemPrompt,omitempty"`
// Temperature corresponds to the JSON schema field "temperature".
Temperature *float64 `json:"temperature,omitempty" yaml:"temperature,omitempty" mapstructure:"temperature,omitempty"`
}
type CreateMessageRequestParamsIncludeContext string
const CreateMessageRequestParamsIncludeContextAllServers CreateMessageRequestParamsIncludeContext = "allServers"
const CreateMessageRequestParamsIncludeContextNone CreateMessageRequestParamsIncludeContext = "none"
const CreateMessageRequestParamsIncludeContextThisServer CreateMessageRequestParamsIncludeContext = "thisServer"
var enumValues_CreateMessageRequestParamsIncludeContext = []interface{}{
"allServers",
"none",
"thisServer",
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CreateMessageRequestParamsIncludeContext) UnmarshalJSON(b []byte) error {
var v string
if err := json.Unmarshal(b, &v); err != nil {
return err
}
var ok bool
for _, expected := range enumValues_CreateMessageRequestParamsIncludeContext {
if reflect.DeepEqual(v, expected) {
ok = true
break
}
}
if !ok {
return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_CreateMessageRequestParamsIncludeContext, v)
}
*j = CreateMessageRequestParamsIncludeContext(v)
return nil
}
// Optional metadata to pass through to the LLM provider. The format of this
// metadata is provider-specific.
type CreateMessageRequestParamsMetadata map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CreateMessageRequestParams) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["maxTokens"]; raw != nil && !ok {
return fmt.Errorf("field maxTokens in CreateMessageRequestParams: required")
}
if _, ok := raw["messages"]; raw != nil && !ok {
return fmt.Errorf("field messages in CreateMessageRequestParams: required")
}
type Plain CreateMessageRequestParams
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CreateMessageRequestParams(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CreateMessageRequest) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["method"]; raw != nil && !ok {
return fmt.Errorf("field method in CreateMessageRequest: required")
}
if _, ok := raw["params"]; raw != nil && !ok {
return fmt.Errorf("field params in CreateMessageRequest: required")
}
type Plain CreateMessageRequest
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CreateMessageRequest(plain)
return nil
}
// The client's response to a sampling/create_message request from the server. The
// client should inform the user before returning the sampled message, to allow
// them to inspect the response (human in the loop) and decide whether to allow the
// server to see it.
type CreateMessageResult struct {
// This result property is reserved by the protocol to allow clients and servers
// to attach additional metadata to their responses.
Meta CreateMessageResultMeta `json:"_meta,omitempty" yaml:"_meta,omitempty" mapstructure:"_meta,omitempty"`
// Content corresponds to the JSON schema field "content".
Content interface{} `json:"content" yaml:"content" mapstructure:"content"`
// The name of the model that generated the message.
Model string `json:"model" yaml:"model" mapstructure:"model"`
// Role corresponds to the JSON schema field "role".
Role Role `json:"role" yaml:"role" mapstructure:"role"`
// The reason why sampling stopped, if known.
StopReason *string `json:"stopReason,omitempty" yaml:"stopReason,omitempty" mapstructure:"stopReason,omitempty"`
}
// This result property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
type CreateMessageResultMeta map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *CreateMessageResult) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["content"]; raw != nil && !ok {
return fmt.Errorf("field content in CreateMessageResult: required")
}
if _, ok := raw["model"]; raw != nil && !ok {
return fmt.Errorf("field model in CreateMessageResult: required")
}
if _, ok := raw["role"]; raw != nil && !ok {
return fmt.Errorf("field role in CreateMessageResult: required")
}
type Plain CreateMessageResult
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = CreateMessageResult(plain)
return nil
}
// An opaque token used to represent a cursor for pagination.
type Cursor string
// The contents of a resource, embedded into a prompt or tool call result.
//
// It is up to the client how best to render embedded resources for the benefit
// of the LLM and/or the user.
type EmbeddedResource struct {
// Annotations corresponds to the JSON schema field "annotations".
Annotations *EmbeddedResourceAnnotations `json:"annotations,omitempty" yaml:"annotations,omitempty" mapstructure:"annotations,omitempty"`
// Resource corresponds to the JSON schema field "resource".
Resource interface{} `json:"resource" yaml:"resource" mapstructure:"resource"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type" yaml:"type" mapstructure:"type"`
}
type EmbeddedResourceAnnotations struct {
// Describes who the intended customer of this object or data is.
//
// It can include multiple entries to indicate content useful for multiple
// audiences (e.g., `["user", "assistant"]`).
Audience []Role `json:"audience,omitempty" yaml:"audience,omitempty" mapstructure:"audience,omitempty"`
// Describes how important this data is for operating the server.
//
// A value of 1 means "most important," and indicates that the data is
// effectively required, while 0 means "least important," and indicates that
// the data is entirely optional.
Priority *float64 `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *EmbeddedResourceAnnotations) UnmarshalJSON(b []byte) error {
type Plain EmbeddedResourceAnnotations
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
if plain.Priority != nil && 1 < *plain.Priority {
return fmt.Errorf("field %s: must be <= %v", "priority", 1)
}
if plain.Priority != nil && 0 > *plain.Priority {
return fmt.Errorf("field %s: must be >= %v", "priority", 0)
}
*j = EmbeddedResourceAnnotations(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *EmbeddedResource) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["resource"]; raw != nil && !ok {
return fmt.Errorf("field resource in EmbeddedResource: required")
}
if _, ok := raw["type"]; raw != nil && !ok {
return fmt.Errorf("field type in EmbeddedResource: required")
}
type Plain EmbeddedResource
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = EmbeddedResource(plain)
return nil
}
// Used by the client to get a prompt provided by the server.
type GetPromptRequest struct {
// Method corresponds to the JSON schema field "method".
Method string `json:"method" yaml:"method" mapstructure:"method"`
// Params corresponds to the JSON schema field "params".
Params GetPromptRequestParams `json:"params" yaml:"params" mapstructure:"params"`
}
type GetPromptRequestParams struct {
// Arguments to use for templating the prompt.
Arguments GetPromptRequestParamsArguments `json:"arguments,omitempty" yaml:"arguments,omitempty" mapstructure:"arguments,omitempty"`
// The name of the prompt or prompt template.
Name string `json:"name" yaml:"name" mapstructure:"name"`
}
// Arguments to use for templating the prompt.
type GetPromptRequestParamsArguments map[string]string
// UnmarshalJSON implements json.Unmarshaler.
func (j *GetPromptRequestParams) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["name"]; raw != nil && !ok {
return fmt.Errorf("field name in GetPromptRequestParams: required")
}
type Plain GetPromptRequestParams
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = GetPromptRequestParams(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *GetPromptRequest) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["method"]; raw != nil && !ok {
return fmt.Errorf("field method in GetPromptRequest: required")
}
if _, ok := raw["params"]; raw != nil && !ok {
return fmt.Errorf("field params in GetPromptRequest: required")
}
type Plain GetPromptRequest
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = GetPromptRequest(plain)
return nil
}
// The server's response to a prompts/get request from the client.
type GetPromptResult struct {
// This result property is reserved by the protocol to allow clients and servers
// to attach additional metadata to their responses.
Meta GetPromptResultMeta `json:"_meta,omitempty" yaml:"_meta,omitempty" mapstructure:"_meta,omitempty"`
// An optional description for the prompt.
Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"`
// Messages corresponds to the JSON schema field "messages".
Messages []PromptMessage `json:"messages" yaml:"messages" mapstructure:"messages"`
}
// This result property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
type GetPromptResultMeta map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *GetPromptResult) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["messages"]; raw != nil && !ok {
return fmt.Errorf("field messages in GetPromptResult: required")
}
type Plain GetPromptResult
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = GetPromptResult(plain)
return nil
}
// An image provided to or from an LLM.
type ImageContent struct {
// Annotations corresponds to the JSON schema field "annotations".
Annotations *ImageContentAnnotations `json:"annotations,omitempty" yaml:"annotations,omitempty" mapstructure:"annotations,omitempty"`
// The base64-encoded image data.
Data string `json:"data" yaml:"data" mapstructure:"data"`
// The MIME type of the image. Different providers may support different image
// types.
MimeType string `json:"mimeType" yaml:"mimeType" mapstructure:"mimeType"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type" yaml:"type" mapstructure:"type"`
}
type ImageContentAnnotations struct {
// Describes who the intended customer of this object or data is.
//
// It can include multiple entries to indicate content useful for multiple
// audiences (e.g., `["user", "assistant"]`).
Audience []Role `json:"audience,omitempty" yaml:"audience,omitempty" mapstructure:"audience,omitempty"`
// Describes how important this data is for operating the server.
//
// A value of 1 means "most important," and indicates that the data is
// effectively required, while 0 means "least important," and indicates that
// the data is entirely optional.
Priority *float64 `json:"priority,omitempty" yaml:"priority,omitempty" mapstructure:"priority,omitempty"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *ImageContentAnnotations) UnmarshalJSON(b []byte) error {
type Plain ImageContentAnnotations
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
if plain.Priority != nil && 1 < *plain.Priority {
return fmt.Errorf("field %s: must be <= %v", "priority", 1)
}
if plain.Priority != nil && 0 > *plain.Priority {
return fmt.Errorf("field %s: must be >= %v", "priority", 0)
}
*j = ImageContentAnnotations(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *ImageContent) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["data"]; raw != nil && !ok {
return fmt.Errorf("field data in ImageContent: required")
}
if _, ok := raw["mimeType"]; raw != nil && !ok {
return fmt.Errorf("field mimeType in ImageContent: required")
}
if _, ok := raw["type"]; raw != nil && !ok {
return fmt.Errorf("field type in ImageContent: required")
}
type Plain ImageContent
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = ImageContent(plain)
return nil
}
// Describes the name and version of an MCP implementation.
type Implementation struct {
// Name corresponds to the JSON schema field "name".
Name string `json:"name" yaml:"name" mapstructure:"name"`
// Version corresponds to the JSON schema field "version".
Version string `json:"version" yaml:"version" mapstructure:"version"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *Implementation) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["name"]; raw != nil && !ok {
return fmt.Errorf("field name in Implementation: required")
}
if _, ok := raw["version"]; raw != nil && !ok {
return fmt.Errorf("field version in Implementation: required")
}
type Plain Implementation
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = Implementation(plain)
return nil
}
// This request is sent from the client to the server when it first connects,
// asking it to begin initialization.
type InitializeRequest struct {
// Method corresponds to the JSON schema field "method".
Method string `json:"method" yaml:"method" mapstructure:"method"`
// Params corresponds to the JSON schema field "params".
Params InitializeRequestParams `json:"params" yaml:"params" mapstructure:"params"`
}
type InitializeRequestParams struct {
// Capabilities corresponds to the JSON schema field "capabilities".
Capabilities ClientCapabilities `json:"capabilities" yaml:"capabilities" mapstructure:"capabilities"`
// ClientInfo corresponds to the JSON schema field "clientInfo".
ClientInfo Implementation `json:"clientInfo" yaml:"clientInfo" mapstructure:"clientInfo"`
// The latest version of the Model Context Protocol that the client supports. The
// client MAY decide to support older versions as well.
ProtocolVersion string `json:"protocolVersion" yaml:"protocolVersion" mapstructure:"protocolVersion"`
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *InitializeRequestParams) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["capabilities"]; raw != nil && !ok {
return fmt.Errorf("field capabilities in InitializeRequestParams: required")
}
if _, ok := raw["clientInfo"]; raw != nil && !ok {
return fmt.Errorf("field clientInfo in InitializeRequestParams: required")
}
if _, ok := raw["protocolVersion"]; raw != nil && !ok {
return fmt.Errorf("field protocolVersion in InitializeRequestParams: required")
}
type Plain InitializeRequestParams
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = InitializeRequestParams(plain)
return nil
}
// UnmarshalJSON implements json.Unmarshaler.
func (j *InitializeRequest) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["method"]; raw != nil && !ok {
return fmt.Errorf("field method in InitializeRequest: required")
}
if _, ok := raw["params"]; raw != nil && !ok {
return fmt.Errorf("field params in InitializeRequest: required")
}
type Plain InitializeRequest
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = InitializeRequest(plain)
return nil
}
// After receiving an initialize request from the client, the server sends this
// response.
type InitializeResult struct {
// This result property is reserved by the protocol to allow clients and servers
// to attach additional metadata to their responses.
Meta InitializeResultMeta `json:"_meta,omitempty" yaml:"_meta,omitempty" mapstructure:"_meta,omitempty"`
// Capabilities corresponds to the JSON schema field "capabilities".
Capabilities ServerCapabilities `json:"capabilities" yaml:"capabilities" mapstructure:"capabilities"`
// Instructions describing how to use the server and its features.
//
// 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.
Instructions *string `json:"instructions,omitempty" yaml:"instructions,omitempty" mapstructure:"instructions,omitempty"`
// 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.
ProtocolVersion string `json:"protocolVersion" yaml:"protocolVersion" mapstructure:"protocolVersion"`
// ServerInfo corresponds to the JSON schema field "serverInfo".
ServerInfo Implementation `json:"serverInfo" yaml:"serverInfo" mapstructure:"serverInfo"`
}
// This result property is reserved by the protocol to allow clients and servers to
// attach additional metadata to their responses.
type InitializeResultMeta map[string]interface{}
// UnmarshalJSON implements json.Unmarshaler.
func (j *InitializeResult) UnmarshalJSON(b []byte) error {
var raw map[string]interface{}
if err := json.Unmarshal(b, &raw); err != nil {
return err
}
if _, ok := raw["capabilities"]; raw != nil && !ok {
return fmt.Errorf("field capabilities in InitializeResult: required")
}
if _, ok := raw["protocolVersion"]; raw != nil && !ok {
return fmt.Errorf("field protocolVersion in InitializeResult: required")
}
if _, ok := raw["serverInfo"]; raw != nil && !ok {
return fmt.Errorf("field serverInfo in InitializeResult: required")
}
type Plain InitializeResult
var plain Plain
if err := json.Unmarshal(b, &plain); err != nil {
return err
}
*j = InitializeResult(plain)
return nil
}
// This notification is sent from the client to the server after initialization has
// finished.
type InitializedNotification struct {
// Method corresponds to the JSON schema field "method".