@@ -8,17 +8,8 @@ use rmcp::{
8
8
} ,
9
9
schemars, tool,
10
10
} ;
11
- use tracing_subscriber:: { self , EnvFilter } ;
12
11
13
12
pub async fn start ( ) -> Result < ( ) > {
14
- tracing_subscriber:: fmt ( )
15
- . with_env_filter ( EnvFilter :: from_default_env ( ) . add_directive ( tracing:: Level :: DEBUG . into ( ) ) )
16
- . with_writer ( std:: io:: stderr)
17
- . with_ansi ( false )
18
- . init ( ) ;
19
-
20
- tracing:: info!( "Starting MCP server" ) ;
21
-
22
13
let client_info = Arc :: new ( Mutex :: new ( None ) ) ;
23
14
let transport = ( tokio:: io:: stdin ( ) , tokio:: io:: stdout ( ) ) ;
24
15
let service = Mcp :: default ( ) . serve ( transport) . await ?;
@@ -35,12 +26,12 @@ pub struct Mcp {}
35
26
36
27
#[ tool( tool_box) ]
37
28
impl Mcp {
38
- #[ tool( description = "Permission check - approve if the input contains allow, otherwise deny. " ) ]
29
+ #[ tool( description = "Permission check for tool calls " ) ]
39
30
pub fn approval_prompt (
40
31
& self ,
41
- #[ tool( aggr) ] request : PermissionRequest ,
32
+ #[ tool( aggr) ] request : McpPermissionRequest ,
42
33
) -> Result < CallToolResult , McpError > {
43
- let result = Ok ( PermissionResponse {
34
+ let result = Ok ( McpPermissionResponse {
44
35
behavior : Behavior :: Allow ,
45
36
updated_input : Some ( request. input ) ,
46
37
message : None ,
@@ -49,9 +40,8 @@ impl Mcp {
49
40
}
50
41
}
51
42
52
- #[ derive( Debug , serde:: Serialize , serde:: Deserialize , schemars:: JsonSchema ) ]
53
- #[ serde( rename_all = "camelCase" ) ]
54
- pub struct PermissionRequest {
43
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , schemars:: JsonSchema ) ]
44
+ pub struct McpPermissionRequest {
55
45
#[ schemars( description = "The name of the tool requesting permission" ) ]
56
46
tool_name : String ,
57
47
#[ schemars( description = "The input for the tool" ) ]
@@ -60,17 +50,17 @@ pub struct PermissionRequest {
60
50
tool_use_id : String ,
61
51
}
62
52
63
- #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize , strum :: Display ) ]
53
+ #[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
64
54
pub enum Behavior {
65
- #[ strum ( serialize = "allow" ) ]
55
+ #[ serde ( rename = "allow" ) ]
66
56
Allow ,
67
- #[ strum ( serialize = "deny" ) ]
57
+ #[ serde ( rename = "deny" ) ]
68
58
Deny ,
69
59
}
70
60
71
61
#[ derive( Debug , Clone , serde:: Serialize , serde:: Deserialize ) ]
72
62
#[ serde( rename_all = "camelCase" ) ]
73
- pub struct PermissionResponse {
63
+ pub struct McpPermissionResponse {
74
64
behavior : Behavior ,
75
65
updated_input : Option < serde_json:: Value > ,
76
66
message : Option < String > ,
0 commit comments