@@ -34,3 +34,55 @@ pub fn sse_event(sse_raw: &str) -> String {
3434pub fn sse_data ( sse_raw : & str ) -> String {
3535 sse_raw. replace ( "data: " , "" )
3636}
37+
38+ pub mod sample_tools {
39+ use rust_mcp_sdk:: macros:: { mcp_tool, JsonSchema } ;
40+ use rust_mcp_sdk:: schema:: { schema_utils:: CallToolError , CallToolResult } ;
41+
42+ //****************//
43+ // SayHelloTool //
44+ //****************//
45+ #[ mcp_tool(
46+ name = "say_hello" ,
47+ description = "Accepts a person's name and says a personalized \" Hello\" to that person" ,
48+ idempotent_hint = false ,
49+ destructive_hint = false ,
50+ open_world_hint = false ,
51+ read_only_hint = false
52+ ) ]
53+ #[ derive( Debug , :: serde:: Deserialize , :: serde:: Serialize , JsonSchema ) ]
54+ pub struct SayHelloTool {
55+ /// The name of the person to greet with a "Hello".
56+ name : String ,
57+ }
58+
59+ impl SayHelloTool {
60+ pub fn call_tool ( & self ) -> Result < CallToolResult , CallToolError > {
61+ let hello_message = format ! ( "Hello, {}!" , self . name) ;
62+ Ok ( CallToolResult :: text_content ( hello_message, None ) )
63+ }
64+ }
65+
66+ //******************//
67+ // SayGoodbyeTool //
68+ //******************//
69+ #[ mcp_tool(
70+ name = "say_goodbye" ,
71+ description = "Accepts a person's name and says a personalized \" Goodbye\" to that person." ,
72+ idempotent_hint = false ,
73+ destructive_hint = false ,
74+ open_world_hint = false ,
75+ read_only_hint = false
76+ ) ]
77+ #[ derive( Debug , :: serde:: Deserialize , :: serde:: Serialize , JsonSchema ) ]
78+ pub struct SayGoodbyeTool {
79+ /// The name of the person to say goodbye to.
80+ name : String ,
81+ }
82+ impl SayGoodbyeTool {
83+ pub fn call_tool ( & self ) -> Result < CallToolResult , CallToolError > {
84+ let hello_message = format ! ( "Goodbye, {}!" , self . name) ;
85+ Ok ( CallToolResult :: text_content ( hello_message, None ) )
86+ }
87+ }
88+ }
0 commit comments