11use std:: sync:: Arc ;
22
33use rmcp:: {
4- Error as McpError , RoleServer , ServerHandler , const_string, model:: * , schemars,
5- service:: RequestContext , tool,
4+ Error as McpError , RoleServer , ServerHandler , model:: * , schemars, service:: RequestContext , tool,
65} ;
76use serde_json:: json;
87use tokio:: sync:: Mutex ;
@@ -26,10 +25,6 @@ impl Counter {
2625 }
2726 }
2827
29- fn _create_resource_text ( & self , uri : & str , name : & str ) -> Resource {
30- RawResource :: new ( uri, name. to_string ( ) ) . no_annotation ( )
31- }
32-
3328 #[ tool( description = "Increment the counter by 1" ) ]
3429 async fn increment ( & self ) -> Result < CallToolResult , McpError > {
3530 let mut counter = self . counter . lock ( ) . await ;
@@ -81,7 +76,7 @@ impl Counter {
8176 ) ] ) )
8277 }
8378}
84- const_string ! ( Echo = "echo" ) ;
79+
8580#[ tool( tool_box) ]
8681impl ServerHandler for Counter {
8782 fn get_info ( & self ) -> ServerInfo {
@@ -102,10 +97,13 @@ impl ServerHandler for Counter {
10297 _request : Option < PaginatedRequestParam > ,
10398 _: RequestContext < RoleServer > ,
10499 ) -> Result < ListResourcesResult , McpError > {
100+ fn create_resource_text ( uri : & str , name : & str ) -> Resource {
101+ RawResource :: new ( uri, name. to_string ( ) ) . no_annotation ( )
102+ }
105103 Ok ( ListResourcesResult {
106104 resources : vec ! [
107- self . _create_resource_text ( "str:////Users/to/some/path/" , "cwd" ) ,
108- self . _create_resource_text ( "memo://insights" , "memo-name" ) ,
105+ create_resource_text ( "str:////Users/to/some/path/" , "cwd" ) ,
106+ create_resource_text ( "memo://insights" , "memo-name" ) ,
109107 ] ,
110108 next_cursor : None ,
111109 } )
0 commit comments