11use async_trait:: async_trait;
22use rust_mcp_schema:: {
3- CancelledNotification , CreateMessageRequest , CreateMessageResult , JsonrpcErrorError ,
4- ListRootsRequest , ListRootsResult , LoggingMessageNotification , PingRequest ,
5- ProgressNotification , PromptListChangedNotification , ResourceListChangedNotification ,
6- ResourceUpdatedNotification , Result , ToolListChangedNotification ,
3+ CancelledNotification , CreateMessageRequest , CreateMessageResult , ListRootsRequest ,
4+ ListRootsResult , LoggingMessageNotification , PingRequest , ProgressNotification ,
5+ PromptListChangedNotification , ResourceListChangedNotification , ResourceUpdatedNotification ,
6+ Result , RpcError , ToolListChangedNotification ,
77} ;
88use serde_json:: Value ;
99
@@ -22,17 +22,17 @@ pub trait ClientHandler: Send + Sync + 'static {
2222 & self ,
2323 request : PingRequest ,
2424 runtime : & dyn MCPClient ,
25- ) -> std:: result:: Result < Result , JsonrpcErrorError > {
25+ ) -> std:: result:: Result < Result , RpcError > {
2626 Ok ( Result :: default ( ) )
2727 }
2828
2929 async fn handle_create_message_request (
3030 & self ,
3131 request : CreateMessageRequest ,
3232 runtime : & dyn MCPClient ,
33- ) -> std:: result:: Result < CreateMessageResult , JsonrpcErrorError > {
33+ ) -> std:: result:: Result < CreateMessageResult , RpcError > {
3434 runtime. assert_client_request_capabilities ( request. method ( ) ) ?;
35- Err ( JsonrpcErrorError :: method_not_found ( ) . with_message ( format ! (
35+ Err ( RpcError :: method_not_found ( ) . with_message ( format ! (
3636 "No handler is implemented for '{}'." ,
3737 request. method( ) ,
3838 ) ) )
@@ -42,9 +42,9 @@ pub trait ClientHandler: Send + Sync + 'static {
4242 & self ,
4343 request : ListRootsRequest ,
4444 runtime : & dyn MCPClient ,
45- ) -> std:: result:: Result < ListRootsResult , JsonrpcErrorError > {
45+ ) -> std:: result:: Result < ListRootsResult , RpcError > {
4646 runtime. assert_client_request_capabilities ( request. method ( ) ) ?;
47- Err ( JsonrpcErrorError :: method_not_found ( ) . with_message ( format ! (
47+ Err ( RpcError :: method_not_found ( ) . with_message ( format ! (
4848 "No handler is implemented for '{}'." ,
4949 request. method( ) ,
5050 ) ) )
@@ -54,8 +54,8 @@ pub trait ClientHandler: Send + Sync + 'static {
5454 & self ,
5555 request : Value ,
5656 runtime : & dyn MCPClient ,
57- ) -> std:: result:: Result < ListRootsResult , JsonrpcErrorError > {
58- Err ( JsonrpcErrorError :: method_not_found ( )
57+ ) -> std:: result:: Result < ListRootsResult , RpcError > {
58+ Err ( RpcError :: method_not_found ( )
5959 . with_message ( "No handler is implemented for custom requests." . to_string ( ) ) )
6060 }
6161
@@ -67,63 +67,63 @@ pub trait ClientHandler: Send + Sync + 'static {
6767 & self ,
6868 notification : CancelledNotification ,
6969 runtime : & dyn MCPClient ,
70- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
70+ ) -> std:: result:: Result < ( ) , RpcError > {
7171 Ok ( ( ) )
7272 }
7373
7474 async fn handle_progress_notification (
7575 & self ,
7676 notification : ProgressNotification ,
7777 runtime : & dyn MCPClient ,
78- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
78+ ) -> std:: result:: Result < ( ) , RpcError > {
7979 Ok ( ( ) )
8080 }
8181
8282 async fn handle_resource_list_changed_notification (
8383 & self ,
8484 notification : ResourceListChangedNotification ,
8585 runtime : & dyn MCPClient ,
86- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
86+ ) -> std:: result:: Result < ( ) , RpcError > {
8787 Ok ( ( ) )
8888 }
8989
9090 async fn handle_resource_updated_notification (
9191 & self ,
9292 notification : ResourceUpdatedNotification ,
9393 runtime : & dyn MCPClient ,
94- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
94+ ) -> std:: result:: Result < ( ) , RpcError > {
9595 Ok ( ( ) )
9696 }
9797
9898 async fn handle_prompt_list_changed_notification (
9999 & self ,
100100 notification : PromptListChangedNotification ,
101101 runtime : & dyn MCPClient ,
102- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
102+ ) -> std:: result:: Result < ( ) , RpcError > {
103103 Ok ( ( ) )
104104 }
105105
106106 async fn handle_tool_list_changed_notification (
107107 & self ,
108108 notification : ToolListChangedNotification ,
109109 runtime : & dyn MCPClient ,
110- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
110+ ) -> std:: result:: Result < ( ) , RpcError > {
111111 Ok ( ( ) )
112112 }
113113
114114 async fn handle_logging_message_notification (
115115 & self ,
116116 notification : LoggingMessageNotification ,
117117 runtime : & dyn MCPClient ,
118- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
118+ ) -> std:: result:: Result < ( ) , RpcError > {
119119 Ok ( ( ) )
120120 }
121121
122122 async fn handle_custom_notification (
123123 & self ,
124124 notification : Value ,
125125 runtime : & dyn MCPClient ,
126- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
126+ ) -> std:: result:: Result < ( ) , RpcError > {
127127 Ok ( ( ) )
128128 }
129129
@@ -132,17 +132,17 @@ pub trait ClientHandler: Send + Sync + 'static {
132132 //********************//
133133 async fn handle_error (
134134 & self ,
135- error : JsonrpcErrorError ,
135+ error : RpcError ,
136136 runtime : & dyn MCPClient ,
137- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
137+ ) -> std:: result:: Result < ( ) , RpcError > {
138138 Ok ( ( ) )
139139 }
140140
141141 async fn handle_process_error (
142142 & self ,
143143 error_message : String ,
144144 runtime : & dyn MCPClient ,
145- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
145+ ) -> std:: result:: Result < ( ) , RpcError > {
146146 if !runtime. is_shut_down ( ) . await {
147147 eprintln ! ( "Process error: {}" , error_message) ;
148148 }
0 commit comments