@@ -378,14 +378,6 @@ impl TryFrom<RequestFromClient> for ClientRequest {
378378}
379379
380380impl 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-
389381 pub fn method ( & self ) -> & str {
390382 match self {
391383 RequestFromClient :: ClientRequest ( request) => request. method ( ) ,
@@ -501,14 +493,6 @@ impl NotificationFromClient {
501493 )
502494 }
503495
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-
512496 fn method ( & self ) -> & str {
513497 match self {
514498 NotificationFromClient :: ClientNotification ( notification) => notification. method ( ) ,
@@ -907,14 +891,6 @@ impl TryFrom<RequestFromServer> for ServerRequest {
907891}
908892
909893impl 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-
918894 pub fn method ( & self ) -> & str {
919895 match self {
920896 RequestFromServer :: ServerRequest ( request) => request. method ( ) ,
@@ -1021,14 +997,6 @@ impl TryFrom<NotificationFromServer> for ServerNotification {
1021997}
1022998
1023999impl 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-
10321000 pub fn method ( & self ) -> & str {
10331001 match self {
10341002 NotificationFromServer :: ServerNotification ( notification) => notification. method ( ) ,
@@ -1434,6 +1402,17 @@ impl CallToolError {
14341402 }
14351403}
14361404
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+
14371416// Implement `Display` for `CallToolError` to provide a user-friendly error message.
14381417impl core:: fmt:: Display for CallToolError {
14391418 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
@@ -1456,56 +1435,6 @@ impl From<CallToolError> for CallToolResult {
14561435 }
14571436}
14581437
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-
15091438impl CallToolRequest {
15101439 /// Retrieves the name of the tool from the request parameters.
15111440 ///
@@ -3758,17 +3687,24 @@ impl TryFrom<NotificationFromServer> for LoggingMessageNotification {
37583687 }
37593688}
37603689impl 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 ( )
37683701 }
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 ( )
37723708 }
37733709 /// Returns the content type as a string based on the variant of `CallToolResultContentItem`.
37743710 pub fn content_type ( & self ) -> & str {
@@ -3812,6 +3748,52 @@ impl CallToolResultContentItem {
38123748 }
38133749 }
38143750}
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+ }
38153797/// END AUTO GENERATED
38163798#[ cfg( test) ]
38173799mod tests {
0 commit comments