1+ # typed: true
12# frozen_string_literal: true
23
34require "test_helper"
@@ -17,7 +18,7 @@ class TestTool < Tool
1718 )
1819
1920 class << self
20- def call ( message , server_context : nil )
21+ def call ( message : , server_context : nil )
2122 Tool ::Response . new ( [ { type : "text" , content : "OK" } ] )
2223 end
2324 end
@@ -42,7 +43,7 @@ def call(message, server_context: nil)
4243
4344 test "#call invokes the tool block and returns the response" do
4445 tool = TestTool
45- response = tool . call ( "test" )
46+ response = tool . call ( message : "test" )
4647 assert_equal response . content , [ { type : "text" , content : "OK" } ]
4748 assert_equal response . is_error , false
4849 end
@@ -203,5 +204,27 @@ class UpdatableAnnotationsTool < Tool
203204 tool . annotations ( title : "Updated" )
204205 assert_equal tool . annotations_value . title , "Updated"
205206 end
207+
208+ test "#call with Sorbet typed tools invokes the tool block and returns the response" do
209+ class TypedTestTool < Tool
210+ tool_name "test_tool"
211+ description "a test tool for testing"
212+ input_schema ( { properties : { message : { type : "string" } } , required : [ "message" ] } )
213+
214+ class << self
215+ extend T ::Sig
216+
217+ sig { params ( message : String , server_context : T . nilable ( T . untyped ) ) . returns ( Tool ::Response ) }
218+ def call ( message :, server_context : nil )
219+ Tool ::Response . new ( [ { type : "text" , content : "OK" } ] )
220+ end
221+ end
222+ end
223+
224+ tool = TypedTestTool
225+ response = tool . call ( message : "test" )
226+ assert_equal response . content , [ { type : "text" , content : "OK" } ]
227+ assert_equal response . is_error , false
228+ end
206229 end
207230end
0 commit comments