1
1
use async_trait:: async_trait;
2
2
use 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 ,
7
7
} ;
8
8
use serde_json:: Value ;
9
9
@@ -22,17 +22,17 @@ pub trait ClientHandler: Send + Sync + 'static {
22
22
& self ,
23
23
request : PingRequest ,
24
24
runtime : & dyn MCPClient ,
25
- ) -> std:: result:: Result < Result , JsonrpcErrorError > {
25
+ ) -> std:: result:: Result < Result , RpcError > {
26
26
Ok ( Result :: default ( ) )
27
27
}
28
28
29
29
async fn handle_create_message_request (
30
30
& self ,
31
31
request : CreateMessageRequest ,
32
32
runtime : & dyn MCPClient ,
33
- ) -> std:: result:: Result < CreateMessageResult , JsonrpcErrorError > {
33
+ ) -> std:: result:: Result < CreateMessageResult , RpcError > {
34
34
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 ! (
36
36
"No handler is implemented for '{}'." ,
37
37
request. method( ) ,
38
38
) ) )
@@ -42,9 +42,9 @@ pub trait ClientHandler: Send + Sync + 'static {
42
42
& self ,
43
43
request : ListRootsRequest ,
44
44
runtime : & dyn MCPClient ,
45
- ) -> std:: result:: Result < ListRootsResult , JsonrpcErrorError > {
45
+ ) -> std:: result:: Result < ListRootsResult , RpcError > {
46
46
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 ! (
48
48
"No handler is implemented for '{}'." ,
49
49
request. method( ) ,
50
50
) ) )
@@ -54,8 +54,8 @@ pub trait ClientHandler: Send + Sync + 'static {
54
54
& self ,
55
55
request : Value ,
56
56
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 ( )
59
59
. with_message ( "No handler is implemented for custom requests." . to_string ( ) ) )
60
60
}
61
61
@@ -67,63 +67,63 @@ pub trait ClientHandler: Send + Sync + 'static {
67
67
& self ,
68
68
notification : CancelledNotification ,
69
69
runtime : & dyn MCPClient ,
70
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
70
+ ) -> std:: result:: Result < ( ) , RpcError > {
71
71
Ok ( ( ) )
72
72
}
73
73
74
74
async fn handle_progress_notification (
75
75
& self ,
76
76
notification : ProgressNotification ,
77
77
runtime : & dyn MCPClient ,
78
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
78
+ ) -> std:: result:: Result < ( ) , RpcError > {
79
79
Ok ( ( ) )
80
80
}
81
81
82
82
async fn handle_resource_list_changed_notification (
83
83
& self ,
84
84
notification : ResourceListChangedNotification ,
85
85
runtime : & dyn MCPClient ,
86
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
86
+ ) -> std:: result:: Result < ( ) , RpcError > {
87
87
Ok ( ( ) )
88
88
}
89
89
90
90
async fn handle_resource_updated_notification (
91
91
& self ,
92
92
notification : ResourceUpdatedNotification ,
93
93
runtime : & dyn MCPClient ,
94
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
94
+ ) -> std:: result:: Result < ( ) , RpcError > {
95
95
Ok ( ( ) )
96
96
}
97
97
98
98
async fn handle_prompt_list_changed_notification (
99
99
& self ,
100
100
notification : PromptListChangedNotification ,
101
101
runtime : & dyn MCPClient ,
102
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
102
+ ) -> std:: result:: Result < ( ) , RpcError > {
103
103
Ok ( ( ) )
104
104
}
105
105
106
106
async fn handle_tool_list_changed_notification (
107
107
& self ,
108
108
notification : ToolListChangedNotification ,
109
109
runtime : & dyn MCPClient ,
110
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
110
+ ) -> std:: result:: Result < ( ) , RpcError > {
111
111
Ok ( ( ) )
112
112
}
113
113
114
114
async fn handle_logging_message_notification (
115
115
& self ,
116
116
notification : LoggingMessageNotification ,
117
117
runtime : & dyn MCPClient ,
118
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
118
+ ) -> std:: result:: Result < ( ) , RpcError > {
119
119
Ok ( ( ) )
120
120
}
121
121
122
122
async fn handle_custom_notification (
123
123
& self ,
124
124
notification : Value ,
125
125
runtime : & dyn MCPClient ,
126
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
126
+ ) -> std:: result:: Result < ( ) , RpcError > {
127
127
Ok ( ( ) )
128
128
}
129
129
@@ -132,17 +132,17 @@ pub trait ClientHandler: Send + Sync + 'static {
132
132
//********************//
133
133
async fn handle_error (
134
134
& self ,
135
- error : JsonrpcErrorError ,
135
+ error : RpcError ,
136
136
runtime : & dyn MCPClient ,
137
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
137
+ ) -> std:: result:: Result < ( ) , RpcError > {
138
138
Ok ( ( ) )
139
139
}
140
140
141
141
async fn handle_process_error (
142
142
& self ,
143
143
error_message : String ,
144
144
runtime : & dyn MCPClient ,
145
- ) -> std:: result:: Result < ( ) , JsonrpcErrorError > {
145
+ ) -> std:: result:: Result < ( ) , RpcError > {
146
146
if !runtime. is_shut_down ( ) . await {
147
147
eprintln ! ( "Process error: {}" , error_message) ;
148
148
}
0 commit comments