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