@@ -151,10 +151,12 @@ func (m *Meta) UnmarshalJSON(data []byte) error {
151
151
}
152
152
153
153
type Request struct {
154
- Method string `json:"method"`
155
- Params struct {
156
- Meta * Meta `json:"_meta,omitempty"`
157
- } `json:"params,omitempty"`
154
+ Method string `json:"method"`
155
+ Params RequestParams `json:"params,omitempty"`
156
+ }
157
+
158
+ type RequestParams struct {
159
+ Meta * Meta `json:"_meta,omitempty"`
158
160
}
159
161
160
162
type Params map [string ]any
@@ -375,17 +377,19 @@ type EmptyResult Result
375
377
// A client MUST NOT attempt to cancel its `initialize` request.
376
378
type CancelledNotification struct {
377
379
Notification
378
- Params struct {
379
- // The ID of the request to cancel.
380
- //
381
- // This MUST correspond to the ID of a request previously issued
382
- // in the same direction.
383
- RequestId RequestId `json:"requestId"`
380
+ Params CancelledNotificationParams `json:"params"`
381
+ }
382
+
383
+ type CancelledNotificationParams struct {
384
+ // The ID of the request to cancel.
385
+ //
386
+ // This MUST correspond to the ID of a request previously issued
387
+ // in the same direction.
388
+ RequestId RequestId `json:"requestId"`
384
389
385
- // An optional string describing the reason for the cancellation. This MAY
386
- // be logged or presented to the user.
387
- Reason string `json:"reason,omitempty"`
388
- } `json:"params"`
390
+ // An optional string describing the reason for the cancellation. This MAY
391
+ // be logged or presented to the user.
392
+ Reason string `json:"reason,omitempty"`
389
393
}
390
394
391
395
/* Initialization */
@@ -394,13 +398,15 @@ type CancelledNotification struct {
394
398
// connects, asking it to begin initialization.
395
399
type InitializeRequest struct {
396
400
Request
397
- Params struct {
398
- // The latest version of the Model Context Protocol that the client supports.
399
- // The client MAY decide to support older versions as well.
400
- ProtocolVersion string `json:"protocolVersion"`
401
- Capabilities ClientCapabilities `json:"capabilities"`
402
- ClientInfo Implementation `json:"clientInfo"`
403
- } `json:"params"`
401
+ Params InitializeParams `json:"params"`
402
+ }
403
+
404
+ type InitializeParams struct {
405
+ // The latest version of the Model Context Protocol that the client supports.
406
+ // The client MAY decide to support older versions as well.
407
+ ProtocolVersion string `json:"protocolVersion"`
408
+ Capabilities ClientCapabilities `json:"capabilities"`
409
+ ClientInfo Implementation `json:"clientInfo"`
404
410
}
405
411
406
412
// InitializeResult is sent after receiving an initialize request from the
@@ -491,30 +497,34 @@ type PingRequest struct {
491
497
// receiver of a progress update for a long-running request.
492
498
type ProgressNotification struct {
493
499
Notification
494
- Params struct {
495
- // The progress token which was given in the initial request, used to
496
- // associate this notification with the request that is proceeding.
497
- ProgressToken ProgressToken `json:"progressToken"`
498
- // The progress thus far. This should increase every time progress is made,
499
- // even if the total is unknown.
500
- Progress float64 `json:"progress"`
501
- // Total number of items to process (or total progress required), if known.
502
- Total float64 `json:"total,omitempty"`
503
- // Message related to progress. This should provide relevant human-readable
504
- // progress information.
505
- Message string `json:"message,omitempty"`
506
- } `json:"params"`
500
+ Params ProgressNotificationParams `json:"params"`
501
+ }
502
+
503
+ type ProgressNotificationParams struct {
504
+ // The progress token which was given in the initial request, used to
505
+ // associate this notification with the request that is proceeding.
506
+ ProgressToken ProgressToken `json:"progressToken"`
507
+ // The progress thus far. This should increase every time progress is made,
508
+ // even if the total is unknown.
509
+ Progress float64 `json:"progress"`
510
+ // Total number of items to process (or total progress required), if known.
511
+ Total float64 `json:"total,omitempty"`
512
+ // Message related to progress. This should provide relevant human-readable
513
+ // progress information.
514
+ Message string `json:"message,omitempty"`
507
515
}
508
516
509
517
/* Pagination */
510
518
511
519
type PaginatedRequest struct {
512
520
Request
513
- Params struct {
514
- // An opaque token representing the current pagination position.
515
- // If provided, the server should return results starting after this cursor.
516
- Cursor Cursor `json:"cursor,omitempty"`
517
- } `json:"params,omitempty"`
521
+ Params PaginatedParams `json:"params,omitempty"`
522
+ }
523
+
524
+ type PaginatedParams struct {
525
+ // An opaque token representing the current pagination position.
526
+ // If provided, the server should return results starting after this cursor.
527
+ Cursor Cursor `json:"cursor,omitempty"`
518
528
}
519
529
520
530
type PaginatedResult struct {
@@ -557,13 +567,15 @@ type ListResourceTemplatesResult struct {
557
567
// specific resource URI.
558
568
type ReadResourceRequest struct {
559
569
Request
560
- Params struct {
561
- // The URI of the resource to read. The URI can use any protocol; it is up
562
- // to the server how to interpret it.
563
- URI string `json:"uri"`
564
- // Arguments to pass to the resource handler
565
- Arguments map [string ]any `json:"arguments,omitempty"`
566
- } `json:"params"`
570
+ Params ReadResourceParams `json:"params"`
571
+ }
572
+
573
+ type ReadResourceParams struct {
574
+ // The URI of the resource to read. The URI can use any protocol; it is up
575
+ // to the server how to interpret it.
576
+ URI string `json:"uri"`
577
+ // Arguments to pass to the resource handler
578
+ Arguments map [string ]any `json:"arguments,omitempty"`
567
579
}
568
580
569
581
// ReadResourceResult is the server's response to a resources/read request
@@ -585,34 +597,39 @@ type ResourceListChangedNotification struct {
585
597
// notifications from the server whenever a particular resource changes.
586
598
type SubscribeRequest struct {
587
599
Request
588
- Params struct {
589
- // The URI of the resource to subscribe to. The URI can use any protocol; it
590
- // is up to the server how to interpret it.
591
- URI string `json:"uri"`
592
- } `json:"params"`
600
+ Params SubscribeParams `json:"params"`
601
+ }
602
+
603
+ type SubscribeParams struct {
604
+ // The URI of the resource to subscribe to. The URI can use any protocol; it
605
+ // is up to the server how to interpret it.
606
+ URI string `json:"uri"`
593
607
}
594
608
595
609
// UnsubscribeRequest is sent from the client to request cancellation of
596
610
// resources/updated notifications from the server. This should follow a previous
597
611
// resources/subscribe request.
598
612
type UnsubscribeRequest struct {
599
613
Request
600
- Params struct {
601
- // The URI of the resource to unsubscribe from.
602
- URI string `json:"uri"`
603
- } `json:"params"`
614
+ Params UnsubscribeParams `json:"params"`
615
+ }
616
+
617
+ type UnsubscribeParams struct {
618
+ // The URI of the resource to unsubscribe from.
619
+ URI string `json:"uri"`
604
620
}
605
621
606
622
// ResourceUpdatedNotification is a notification from the server to the client,
607
623
// informing it that a resource has changed and may need to be read again. This
608
624
// should only be sent if the client previously sent a resources/subscribe request.
609
625
type ResourceUpdatedNotification struct {
610
626
Notification
611
- Params struct {
612
- // The URI of the resource that has been updated. This might be a sub-
613
- // resource of the one that the client actually subscribed to.
614
- URI string `json:"uri"`
615
- } `json:"params"`
627
+ Params ResourceUpdatedNotificationParams `json:"params"`
628
+ }
629
+ type ResourceUpdatedNotificationParams struct {
630
+ // The URI of the resource that has been updated. This might be a sub-
631
+ // resource of the one that the client actually subscribed to.
632
+ URI string `json:"uri"`
616
633
}
617
634
618
635
// Resource represents a known resource that the server is capable of reading.
@@ -699,28 +716,32 @@ func (BlobResourceContents) isResourceContents() {}
699
716
// adjust logging.
700
717
type SetLevelRequest struct {
701
718
Request
702
- Params struct {
703
- // The level of logging that the client wants to receive from the server.
704
- // The server should send all logs at this level and higher (i.e., more severe) to
705
- // the client as notifications/logging/message.
706
- Level LoggingLevel `json:"level"`
707
- } `json:"params"`
719
+ Params SetLevelParams `json:"params"`
720
+ }
721
+
722
+ type SetLevelParams struct {
723
+ // The level of logging that the client wants to receive from the server.
724
+ // The server should send all logs at this level and higher (i.e., more severe) to
725
+ // the client as notifications/logging/message.
726
+ Level LoggingLevel `json:"level"`
708
727
}
709
728
710
729
// LoggingMessageNotification is a notification of a log message passed from
711
730
// server to client. If no logging/setLevel request has been sent from the client,
712
731
// the server MAY decide which messages to send automatically.
713
732
type LoggingMessageNotification struct {
714
733
Notification
715
- Params struct {
716
- // The severity of this log message.
717
- Level LoggingLevel `json:"level"`
718
- // An optional name of the logger issuing this message.
719
- Logger string `json:"logger,omitempty"`
720
- // The data to be logged, such as a string message or an object. Any JSON
721
- // serializable type is allowed here.
722
- Data any `json:"data"`
723
- } `json:"params"`
734
+ Params LoggingMessageNotificationParams `json:"params"`
735
+ }
736
+
737
+ type LoggingMessageNotificationParams struct {
738
+ // The severity of this log message.
739
+ Level LoggingLevel `json:"level"`
740
+ // An optional name of the logger issuing this message.
741
+ Logger string `json:"logger,omitempty"`
742
+ // The data to be logged, such as a string message or an object. Any JSON
743
+ // serializable type is allowed here.
744
+ Data any `json:"data"`
724
745
}
725
746
726
747
// LoggingLevel represents the severity of a log message.
@@ -748,16 +769,18 @@ const (
748
769
// the request (human in the loop) and decide whether to approve it.
749
770
type CreateMessageRequest struct {
750
771
Request
751
- Params struct {
752
- Messages []SamplingMessage `json:"messages"`
753
- ModelPreferences * ModelPreferences `json:"modelPreferences,omitempty"`
754
- SystemPrompt string `json:"systemPrompt,omitempty"`
755
- IncludeContext string `json:"includeContext,omitempty"`
756
- Temperature float64 `json:"temperature,omitempty"`
757
- MaxTokens int `json:"maxTokens"`
758
- StopSequences []string `json:"stopSequences,omitempty"`
759
- Metadata any `json:"metadata,omitempty"`
760
- } `json:"params"`
772
+ CreateMessageParams `json:"params"`
773
+ }
774
+
775
+ type CreateMessageParams struct {
776
+ Messages []SamplingMessage `json:"messages"`
777
+ ModelPreferences * ModelPreferences `json:"modelPreferences,omitempty"`
778
+ SystemPrompt string `json:"systemPrompt,omitempty"`
779
+ IncludeContext string `json:"includeContext,omitempty"`
780
+ Temperature float64 `json:"temperature,omitempty"`
781
+ MaxTokens int `json:"maxTokens"`
782
+ StopSequences []string `json:"stopSequences,omitempty"`
783
+ Metadata any `json:"metadata,omitempty"`
761
784
}
762
785
763
786
// CreateMessageResult is the client's response to a sampling/create_message
@@ -915,15 +938,17 @@ type ModelHint struct {
915
938
// CompleteRequest is a request from the client to the server, to ask for completion options.
916
939
type CompleteRequest struct {
917
940
Request
918
- Params struct {
919
- Ref any `json:"ref"` // Can be PromptReference or ResourceReference
920
- Argument struct {
921
- // The name of the argument
922
- Name string `json:"name"`
923
- // The value of the argument to use for completion matching.
924
- Value string `json:"value"`
925
- } `json:"argument"`
926
- } `json:"params"`
941
+ Params CompleteParams `json:"params"`
942
+ }
943
+
944
+ type CompleteParams struct {
945
+ Ref any `json:"ref"` // Can be PromptReference or ResourceReference
946
+ Argument struct {
947
+ // The name of the argument
948
+ Name string `json:"name"`
949
+ // The value of the argument to use for completion matching.
950
+ Value string `json:"value"`
951
+ } `json:"argument"`
927
952
}
928
953
929
954
// CompleteResult is the server's response to a completion/complete request
0 commit comments