@@ -378,14 +378,6 @@ impl TryFrom<RequestFromClient> for ClientRequest {
378
378
}
379
379
380
380
impl RequestFromClient {
381
- #[ deprecated( since = "0.1.4" , note = "Use `method()` instead." ) ]
382
- pub fn get_method ( & self ) -> & str {
383
- match self {
384
- RequestFromClient :: ClientRequest ( request) => request. method ( ) ,
385
- RequestFromClient :: CustomRequest ( request) => request[ "method" ] . as_str ( ) . unwrap ( ) ,
386
- }
387
- }
388
-
389
381
pub fn method ( & self ) -> & str {
390
382
match self {
391
383
RequestFromClient :: ClientRequest ( request) => request. method ( ) ,
@@ -501,14 +493,6 @@ impl NotificationFromClient {
501
493
)
502
494
}
503
495
504
- #[ deprecated( since = "0.1.4" , note = "Use `method()` instead." ) ]
505
- pub fn get_method ( & self ) -> & str {
506
- match self {
507
- NotificationFromClient :: ClientNotification ( notification) => notification. method ( ) ,
508
- NotificationFromClient :: CustomNotification ( notification) => notification[ "method" ] . as_str ( ) . unwrap ( ) ,
509
- }
510
- }
511
-
512
496
fn method ( & self ) -> & str {
513
497
match self {
514
498
NotificationFromClient :: ClientNotification ( notification) => notification. method ( ) ,
@@ -907,14 +891,6 @@ impl TryFrom<RequestFromServer> for ServerRequest {
907
891
}
908
892
909
893
impl RequestFromServer {
910
- #[ deprecated( since = "0.1.4" , note = "Use `method()` instead." ) ]
911
- pub fn get_method ( & self ) -> & str {
912
- match self {
913
- RequestFromServer :: ServerRequest ( request) => request. method ( ) ,
914
- RequestFromServer :: CustomRequest ( request) => request[ "method" ] . as_str ( ) . unwrap ( ) ,
915
- }
916
- }
917
-
918
894
pub fn method ( & self ) -> & str {
919
895
match self {
920
896
RequestFromServer :: ServerRequest ( request) => request. method ( ) ,
@@ -1021,14 +997,6 @@ impl TryFrom<NotificationFromServer> for ServerNotification {
1021
997
}
1022
998
1023
999
impl NotificationFromServer {
1024
- #[ deprecated( since = "0.1.4" , note = "Use `method()` instead." ) ]
1025
- pub fn get_method ( & self ) -> & str {
1026
- match self {
1027
- NotificationFromServer :: ServerNotification ( notification) => notification. method ( ) ,
1028
- NotificationFromServer :: CustomNotification ( notification) => notification[ "method" ] . as_str ( ) . unwrap ( ) ,
1029
- }
1030
- }
1031
-
1032
1000
pub fn method ( & self ) -> & str {
1033
1001
match self {
1034
1002
NotificationFromServer :: ServerNotification ( notification) => notification. method ( ) ,
@@ -1434,6 +1402,17 @@ impl CallToolError {
1434
1402
}
1435
1403
}
1436
1404
1405
+ /// Converts a `CallToolError` into a `JsonrpcErrorError`.
1406
+ ///
1407
+ /// The conversion creates an internal error variant of `JsonrpcErrorError`
1408
+ /// and attaches the string representation of the original `CallToolError` as a message.
1409
+ ///
1410
+ impl From < CallToolError > for JsonrpcErrorError {
1411
+ fn from ( value : CallToolError ) -> Self {
1412
+ Self :: internal_error ( ) . with_message ( value. to_string ( ) )
1413
+ }
1414
+ }
1415
+
1437
1416
// Implement `Display` for `CallToolError` to provide a user-friendly error message.
1438
1417
impl core:: fmt:: Display for CallToolError {
1439
1418
fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
@@ -1456,56 +1435,6 @@ impl From<CallToolError> for CallToolResult {
1456
1435
}
1457
1436
}
1458
1437
1459
- //***************************//
1460
- //** CallToolResult Impl **//
1461
- //***************************//
1462
- impl CallToolResult {
1463
- /// Create a `CallToolResult` with an error, containing an error message in the content
1464
- pub fn with_error ( error : CallToolError ) -> Self {
1465
- Self {
1466
- content : vec ! [ CallToolResultContentItem :: TextContent ( TextContent :: new(
1467
- None ,
1468
- error. to_string( ) , // Convert the error to a string and wrap it in TextContent
1469
- ) ) ] ,
1470
- is_error : Some ( true ) , // Indicate that the result is an error
1471
- meta : None ,
1472
- }
1473
- }
1474
-
1475
- /// Create a `CallToolResult` containing text content and optional annotations
1476
- pub fn text_content ( text_content : String , text_annotations : Option < TextContentAnnotations > ) -> Self {
1477
- Self {
1478
- content : vec ! [ TextContent :: new( text_annotations, text_content) . into( ) ] ,
1479
- is_error : None ,
1480
- meta : None ,
1481
- }
1482
- }
1483
-
1484
- /// Create a `CallToolResult` containing image content, with data, MIME type, and optional annotations
1485
- pub fn image_content ( data : String , mime_type : String , annotations : Option < ImageContentAnnotations > ) -> Self {
1486
- Self {
1487
- content : vec ! [ ImageContent :: new( annotations, data, mime_type) . into( ) ] ,
1488
- is_error : None ,
1489
- meta : None ,
1490
- }
1491
- }
1492
-
1493
- /// Create a `CallToolResult` containing an embedded resource, with optional annotations
1494
- pub fn embedded_resource ( resource : EmbeddedResourceResource , annotations : Option < EmbeddedResourceAnnotations > ) -> Self {
1495
- Self {
1496
- content : vec ! [ EmbeddedResource :: new( annotations, resource) . into( ) ] ,
1497
- is_error : None ,
1498
- meta : None ,
1499
- }
1500
- }
1501
-
1502
- // Add metadata to the `CallToolResult`, allowing additional context or information to be included
1503
- pub fn with_meta ( mut self , meta : Option < serde_json:: Map < String , Value > > ) -> Self {
1504
- self . meta = meta;
1505
- self
1506
- }
1507
- }
1508
-
1509
1438
impl CallToolRequest {
1510
1439
/// Retrieves the name of the tool from the request parameters.
1511
1440
///
@@ -3758,17 +3687,24 @@ impl TryFrom<NotificationFromServer> for LoggingMessageNotification {
3758
3687
}
3759
3688
}
3760
3689
impl CallToolResultContentItem {
3761
- /// Create a `CallToolResultContentItem` with text content and optional annotations
3762
- pub fn text_content ( text_content : String , annotations : Option < TextContentAnnotations > ) -> Self {
3763
- TextContent :: new ( annotations, text_content) . into ( )
3764
- }
3765
- /// Create a `CallToolResultContentItem` with image content, with data, MIME type, and optional annotations
3766
- pub fn image_content ( data : String , mime_type : String , annotations : Option < ImageContentAnnotations > ) -> Self {
3767
- ImageContent :: new ( annotations, data, mime_type) . into ( )
3690
+ ///Create a CallToolResultContentItem::TextContent
3691
+ pub fn text_content ( text : :: std:: string:: String , annotations : :: std:: option:: Option < TextContentAnnotations > ) -> Self {
3692
+ TextContent :: new ( text, annotations) . into ( )
3693
+ }
3694
+ ///Create a CallToolResultContentItem::ImageContent
3695
+ pub fn image_content (
3696
+ data : :: std:: string:: String ,
3697
+ mime_type : :: std:: string:: String ,
3698
+ annotations : :: std:: option:: Option < ImageContentAnnotations > ,
3699
+ ) -> Self {
3700
+ ImageContent :: new ( data, mime_type, annotations) . into ( )
3768
3701
}
3769
- /// Create a `CallToolResultContentItem` with an embedded resource, with optional annotations
3770
- pub fn embedded_resource ( resource : EmbeddedResourceResource , annotations : Option < EmbeddedResourceAnnotations > ) -> Self {
3771
- EmbeddedResource :: new ( annotations, resource) . into ( )
3702
+ ///Create a CallToolResultContentItem::EmbeddedResource
3703
+ pub fn embedded_resource (
3704
+ resource : EmbeddedResourceResource ,
3705
+ annotations : :: std:: option:: Option < EmbeddedResourceAnnotations > ,
3706
+ ) -> Self {
3707
+ EmbeddedResource :: new ( resource, annotations) . into ( )
3772
3708
}
3773
3709
/// Returns the content type as a string based on the variant of `CallToolResultContentItem`.
3774
3710
pub fn content_type ( & self ) -> & str {
@@ -3812,6 +3748,52 @@ impl CallToolResultContentItem {
3812
3748
}
3813
3749
}
3814
3750
}
3751
+ impl CallToolResult {
3752
+ pub fn text_content ( text : :: std:: string:: String , annotations : :: std:: option:: Option < TextContentAnnotations > ) -> Self {
3753
+ Self {
3754
+ content : vec ! [ TextContent :: new( text, annotations) . into( ) ] ,
3755
+ is_error : None ,
3756
+ meta : None ,
3757
+ }
3758
+ }
3759
+ pub fn image_content (
3760
+ data : :: std:: string:: String ,
3761
+ mime_type : :: std:: string:: String ,
3762
+ annotations : :: std:: option:: Option < ImageContentAnnotations > ,
3763
+ ) -> Self {
3764
+ Self {
3765
+ content : vec ! [ ImageContent :: new( data, mime_type, annotations) . into( ) ] ,
3766
+ is_error : None ,
3767
+ meta : None ,
3768
+ }
3769
+ }
3770
+ pub fn embedded_resource (
3771
+ resource : EmbeddedResourceResource ,
3772
+ annotations : :: std:: option:: Option < EmbeddedResourceAnnotations > ,
3773
+ ) -> Self {
3774
+ Self {
3775
+ content : vec ! [ EmbeddedResource :: new( resource, annotations) . into( ) ] ,
3776
+ is_error : None ,
3777
+ meta : None ,
3778
+ }
3779
+ }
3780
+ /// Create a `CallToolResult` with an error, containing an error message in the content
3781
+ pub fn with_error ( error : CallToolError ) -> Self {
3782
+ Self {
3783
+ content : vec ! [ CallToolResultContentItem :: TextContent ( TextContent :: new(
3784
+ error. to_string( ) ,
3785
+ None ,
3786
+ ) ) ] ,
3787
+ is_error : Some ( true ) ,
3788
+ meta : None ,
3789
+ }
3790
+ }
3791
+ /// Adds metadata to the `CallToolResult`, allowing additional context or information to be included
3792
+ pub fn with_meta ( mut self , meta : Option < serde_json:: Map < String , Value > > ) -> Self {
3793
+ self . meta = meta;
3794
+ self
3795
+ }
3796
+ }
3815
3797
/// END AUTO GENERATED
3816
3798
#[ cfg( test) ]
3817
3799
mod tests {
0 commit comments