@@ -29,12 +29,27 @@ def test_tools_sends_request_to_transport_and_returns_tools_array
2929 assert_equal ( "tool2" , tools . last . name )
3030 end
3131
32+ def test_tools_returns_empty_array_when_no_tools
33+ transport = mock
34+ mock_response = { "result" => { "tools" => [ ] } }
35+
36+ # Only checking for the essential parts of the request
37+ transport . expects ( :send_request ) . with do |args |
38+ args in { request : { method : "tools/list" , jsonrpc : "2.0" } }
39+ end . returns ( mock_response ) . once
40+
41+ client = Client . new ( transport : transport )
42+ tools = client . tools
43+
44+ assert_empty ( tools )
45+ end
46+
3247 def test_call_tool_sends_request_to_transport_and_returns_content
3348 transport = mock
3449 tool = MCP ::Client ::Tool . new ( name : "tool1" , description : "tool1" , input_schema : { } )
3550 arguments = { foo : "bar" }
3651 mock_response = {
37- "result" => { "content" => "result" } ,
52+ "result" => { "content" => [ { "type" : "text" , "text" : "Hello, world!" } ] } ,
3853 }
3954
4055 # Only checking for the essential parts of the request
@@ -55,7 +70,7 @@ def test_call_tool_sends_request_to_transport_and_returns_content
5570 result = client . call_tool ( tool : tool , arguments : arguments )
5671 content = result . dig ( "result" , "content" )
5772
58- assert_equal ( "result" , content )
73+ assert_equal ( [ { type : "text" , text : "Hello, world!" } ] , content )
5974 end
6075
6176 def test_resources_sends_request_to_transport_and_returns_resources_array
0 commit comments