@@ -31,110 +31,3 @@ fn test_rename() {
3131 let properties = schema. get ( "properties" ) . unwrap ( ) . as_object ( ) . unwrap ( ) ;
3232 assert_eq ! ( properties. len( ) , 2 ) ;
3333}
34-
35- #[ test]
36- #[ cfg( feature = "2025_06_18" ) ]
37- fn test_mcp_tool ( ) {
38- use serde_json:: { Map , Value } ;
39-
40- #[ rust_mcp_macros:: mcp_tool(
41- name = "example_tool" ,
42- title = "Example Tool" ,
43- description = "An example tool" ,
44- idempotent_hint = true ,
45- destructive_hint = true ,
46- open_world_hint = true ,
47- read_only_hint = true ,
48- meta = r#"{
49- "string_meta" : "meta value",
50- "numeric_meta" : 15
51- }"#
52- ) ]
53- #[ derive( rust_mcp_macros:: JsonSchema ) ]
54- #[ allow( unused) ]
55- struct ExampleTool {
56- field1 : String ,
57- field2 : i32 ,
58- }
59-
60- assert_eq ! ( ExampleTool :: tool_name( ) , "example_tool" ) ;
61- let tool: rust_mcp_schema:: Tool = ExampleTool :: tool ( ) ;
62- assert_eq ! ( tool. name, "example_tool" ) ;
63- assert_eq ! ( tool. description. unwrap( ) , "An example tool" ) ;
64- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . idempotent_hint. unwrap( ) , ) ;
65- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . destructive_hint. unwrap( ) , ) ;
66- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . open_world_hint. unwrap( ) , ) ;
67- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . read_only_hint. unwrap( ) , ) ;
68-
69- assert_eq ! ( tool. title. as_ref( ) . unwrap( ) , "Example Tool" ) ;
70-
71- let meta: & Map < String , Value > = tool. meta . as_ref ( ) . unwrap ( ) ;
72- // Assert that "string_meta" equals "meta value"
73- assert_eq ! (
74- meta. get( "string_meta" ) . unwrap( ) ,
75- & Value :: String ( "meta value" . to_string( ) )
76- ) ;
77-
78- // Assert that "numeric_meta" equals 15
79- assert_eq ! ( meta. get( "numeric_meta" ) . unwrap( ) , & Value :: Number ( 15 . into( ) ) ) ;
80-
81- let schema_properties = tool. input_schema . properties . unwrap ( ) ;
82- assert_eq ! ( schema_properties. len( ) , 2 ) ;
83- assert ! ( schema_properties. contains_key( "field1" ) ) ;
84- assert ! ( schema_properties. contains_key( "field2" ) ) ;
85- }
86-
87- #[ test]
88- #[ cfg( feature = "2025_03_26" ) ]
89- fn test_mcp_tool ( ) {
90- #[ rust_mcp_macros:: mcp_tool(
91- name = "example_tool" ,
92- description = "An example tool" ,
93- idempotent_hint = true ,
94- destructive_hint = true ,
95- open_world_hint = true ,
96- read_only_hint = true
97- ) ]
98- #[ derive( rust_mcp_macros:: JsonSchema ) ]
99- #[ allow( unused) ]
100- struct ExampleTool {
101- field1 : String ,
102- field2 : i32 ,
103- }
104-
105- assert_eq ! ( ExampleTool :: tool_name( ) , "example_tool" ) ;
106- let tool: rust_mcp_schema:: Tool = ExampleTool :: tool ( ) ;
107- assert_eq ! ( tool. name, "example_tool" ) ;
108- assert_eq ! ( tool. description. unwrap( ) , "An example tool" ) ;
109- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . idempotent_hint. unwrap( ) , ) ;
110- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . destructive_hint. unwrap( ) , ) ;
111- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . open_world_hint. unwrap( ) , ) ;
112- assert ! ( tool. annotations. as_ref( ) . unwrap( ) . read_only_hint. unwrap( ) , ) ;
113-
114- let schema_properties = tool. input_schema . properties . unwrap ( ) ;
115- assert_eq ! ( schema_properties. len( ) , 2 ) ;
116- assert ! ( schema_properties. contains_key( "field1" ) ) ;
117- assert ! ( schema_properties. contains_key( "field2" ) ) ;
118- }
119-
120- #[ test]
121- #[ cfg( feature = "2024_11_05" ) ]
122- fn test_mcp_tool ( ) {
123- #[ rust_mcp_macros:: mcp_tool( name = "example_tool" , description = "An example tool" ) ]
124- #[ derive( rust_mcp_macros:: JsonSchema ) ]
125- #[ allow( unused) ]
126- struct ExampleTool {
127- field1 : String ,
128- field2 : i32 ,
129- }
130-
131- assert_eq ! ( ExampleTool :: tool_name( ) , "example_tool" ) ;
132- let tool: rust_mcp_schema:: Tool = ExampleTool :: tool ( ) ;
133- assert_eq ! ( tool. name, "example_tool" ) ;
134- assert_eq ! ( tool. description. unwrap( ) , "An example tool" ) ;
135-
136- let schema_properties = tool. input_schema . properties . unwrap ( ) ;
137- assert_eq ! ( schema_properties. len( ) , 2 ) ;
138- assert ! ( schema_properties. contains_key( "field1" ) ) ;
139- assert ! ( schema_properties. contains_key( "field2" ) ) ;
140- }
0 commit comments