@@ -1096,6 +1096,62 @@ def call(message:, server_context: nil)
10961096 assert_equal "OK" , response [ :result ] [ :content ] [ 0 ] [ :content ]
10971097 end
10981098
1099+ test "tools/call allows additional properties by default" do
1100+ server = Server . new (
1101+ tools : [ TestTool ] ,
1102+ configuration : Configuration . new ( validate_tool_call_arguments : true ) ,
1103+ )
1104+
1105+ response = server . handle (
1106+ {
1107+ jsonrpc : "2.0" ,
1108+ id : 1 ,
1109+ method : "tools/call" ,
1110+ params : {
1111+ name : "test_tool" ,
1112+ arguments : {
1113+ message : "Hello, world!" ,
1114+ other_property : "I am allowed" ,
1115+ } ,
1116+ } ,
1117+ } ,
1118+ )
1119+
1120+ assert_equal "2.0" , response [ :jsonrpc ]
1121+ assert_equal 1 , response [ :id ]
1122+ assert response [ :result ] , "Expected result key in response"
1123+ assert_equal "text" , response [ :result ] [ :content ] [ 0 ] [ :type ]
1124+ assert_equal "OK" , response [ :result ] [ :content ] [ 0 ] [ :content ]
1125+ end
1126+
1127+ test "tools/call disallows additional properties when additionalProperties set to false" do
1128+ server = Server . new (
1129+ tools : [ TestToolWithAdditionalPropertiesSetToFalse ] ,
1130+ configuration : Configuration . new ( validate_tool_call_arguments : true ) ,
1131+ )
1132+
1133+ response = server . handle (
1134+ {
1135+ jsonrpc : "2.0" ,
1136+ id : 1 ,
1137+ method : "tools/call" ,
1138+ params : {
1139+ name : "test_tool_with_additional_properties_set_to_false" ,
1140+ arguments : {
1141+ message : "Hello, world!" ,
1142+ extra : 123 ,
1143+ } ,
1144+ } ,
1145+ } ,
1146+ )
1147+
1148+ assert_equal "2.0" , response [ :jsonrpc ]
1149+ assert_equal 1 , response [ :id ]
1150+ assert_nil response [ :error ] , "Expected no JSON-RPC error"
1151+ assert response [ :result ] [ :isError ]
1152+ assert_includes response [ :result ] [ :content ] [ 0 ] [ :text ] , "Invalid arguments"
1153+ end
1154+
10991155 test "tools/call with no args" do
11001156 server = Server . new ( tools : [ @tool_with_no_args ] )
11011157
@@ -1123,7 +1179,19 @@ class TestTool < Tool
11231179 input_schema ( { properties : { message : { type : "string" } } , required : [ "message" ] } )
11241180
11251181 class << self
1126- def call ( message :, server_context : nil )
1182+ def call ( server_context : nil , **kwargs )
1183+ Tool ::Response . new ( [ { type : "text" , content : "OK" } ] )
1184+ end
1185+ end
1186+ end
1187+
1188+ class TestToolWithAdditionalPropertiesSetToFalse < Tool
1189+ tool_name "test_tool_with_additional_properties_set_to_false"
1190+ description "a test tool with additionalProperties set to false for testing"
1191+ input_schema ( { properties : { message : { type : "string" } } , required : [ "message" ] , additionalProperties : false } )
1192+
1193+ class << self
1194+ def call ( server_context : nil , **kwargs )
11271195 Tool ::Response . new ( [ { type : "text" , content : "OK" } ] )
11281196 end
11291197 end
0 commit comments