25
25
26
26
ProgressToken = str | int
27
27
Cursor = str
28
+ Role = Literal ["user" , "assistant" ]
29
+ RequestId = str | int
28
30
29
31
30
32
class RequestParams (BaseModel ):
@@ -101,9 +103,6 @@ class PaginatedResult(Result):
101
103
"""
102
104
103
105
104
- RequestId = str | int
105
-
106
-
107
106
class JSONRPCRequest (Request ):
108
107
"""A request that expects a response."""
109
108
@@ -344,6 +343,12 @@ class ListResourcesRequest(PaginatedRequest):
344
343
params : RequestParams | None = None
345
344
346
345
346
+ class Annotations (BaseModel ):
347
+ audience : list [Role ] | None = None
348
+ priority : float | None = None
349
+ model_config = ConfigDict (extra = "allow" )
350
+
351
+
347
352
class Resource (BaseModel ):
348
353
"""A known resource that the server is capable of reading."""
349
354
@@ -355,6 +360,14 @@ class Resource(BaseModel):
355
360
"""A description of what this resource represents."""
356
361
mimeType : str | None = None
357
362
"""The MIME type of this resource, if known."""
363
+ size : int | None = None
364
+ """
365
+ The size of the raw resource content, in bytes (i.e., before base64 encoding
366
+ or any tokenization), if known.
367
+
368
+ This can be used by Hosts to display file sizes and estimate context window usage.
369
+ """
370
+ annotations : Annotations | None = None
358
371
model_config = ConfigDict (extra = "allow" )
359
372
360
373
@@ -375,6 +388,7 @@ class ResourceTemplate(BaseModel):
375
388
The MIME type for all resources that match this template. This should only be
376
389
included if all resources matching this template have the same type.
377
390
"""
391
+ annotations : Annotations | None = None
378
392
model_config = ConfigDict (extra = "allow" )
379
393
380
394
@@ -578,6 +592,7 @@ class TextContent(BaseModel):
578
592
type : Literal ["text" ]
579
593
text : str
580
594
"""The text content of the message."""
595
+ annotations : Annotations | None = None
581
596
model_config = ConfigDict (extra = "allow" )
582
597
583
598
@@ -592,12 +607,10 @@ class ImageContent(BaseModel):
592
607
The MIME type of the image. Different providers may support different
593
608
image types.
594
609
"""
610
+ annotations : Annotations | None = None
595
611
model_config = ConfigDict (extra = "allow" )
596
612
597
613
598
- Role = Literal ["user" , "assistant" ]
599
-
600
-
601
614
class SamplingMessage (BaseModel ):
602
615
"""Describes a message issued to or received from an LLM API."""
603
616
@@ -616,6 +629,7 @@ class EmbeddedResource(BaseModel):
616
629
617
630
type : Literal ["resource" ]
618
631
resource : TextResourceContents | BlobResourceContents
632
+ annotations : Annotations | None = None
619
633
model_config = ConfigDict (extra = "allow" )
620
634
621
635
@@ -977,6 +991,26 @@ class RootsListChangedNotification(Notification):
977
991
params : NotificationParams | None = None
978
992
979
993
994
+ class CancelledNotificationParams (NotificationParams ):
995
+ """Parameters for cancellation notifications."""
996
+
997
+ requestId : RequestId
998
+ """The ID of the request to cancel."""
999
+ reason : str | None = None
1000
+ """An optional string describing the reason for the cancellation."""
1001
+ model_config = ConfigDict (extra = "allow" )
1002
+
1003
+
1004
+ class CancelledNotification (Notification ):
1005
+ """
1006
+ This notification can be sent by either side to indicate that it is cancelling a
1007
+ previously-issued request.
1008
+ """
1009
+
1010
+ method : Literal ["notifications/cancelled" ]
1011
+ params : CancelledNotificationParams
1012
+
1013
+
980
1014
class ClientRequest (
981
1015
RootModel [
982
1016
PingRequest
@@ -999,7 +1033,10 @@ class ClientRequest(
999
1033
1000
1034
class ClientNotification (
1001
1035
RootModel [
1002
- ProgressNotification | InitializedNotification | RootsListChangedNotification
1036
+ CancelledNotification
1037
+ | ProgressNotification
1038
+ | InitializedNotification
1039
+ | RootsListChangedNotification
1003
1040
]
1004
1041
):
1005
1042
pass
@@ -1015,7 +1052,8 @@ class ServerRequest(RootModel[PingRequest | CreateMessageRequest | ListRootsRequ
1015
1052
1016
1053
class ServerNotification (
1017
1054
RootModel [
1018
- ProgressNotification
1055
+ CancelledNotification
1056
+ | ProgressNotification
1019
1057
| LoggingMessageNotification
1020
1058
| ResourceUpdatedNotification
1021
1059
| ResourceListChangedNotification
0 commit comments