File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -44,28 +44,27 @@ def tools
4444      end  || [ ] 
4545    end 
4646
47-     # Calls a tool via the transport layer. 
47+     # Calls a tool via the transport layer and returns the full response from the server . 
4848    # 
4949    # @param tool [MCP::Client::Tool] The tool to be called. 
5050    # @param arguments [Object, nil] The arguments to pass to the tool. 
51-     # @return [Object ] The result of the tool call, as returned by  the transport. 
51+     # @return [Hash ] The full JSON-RPC response from  the transport. 
5252    # 
5353    # @example 
5454    #   tool = client.tools.first 
55-     #   result = client.call_tool(tool: tool, arguments: { foo: "bar" }) 
55+     #   response = client.call_tool(tool: tool, arguments: { foo: "bar" }) 
56+     #   structured_content = response.dig("result", "structuredContent") 
5657    # 
5758    # @note 
5859    #   The exact requirements for `arguments` are determined by the transport layer in use. 
5960    #   Consult the documentation for your transport (e.g., MCP::Client::HTTP) for details. 
6061    def  call_tool ( tool :,  arguments : nil ) 
61-       response   =   transport . send_request ( request : { 
62+       transport . send_request ( request : { 
6263        jsonrpc : JsonRpcHandler ::Version ::V2_0 , 
6364        id : request_id , 
6465        method : "tools/call" , 
6566        params : {  name : tool . name ,  arguments : arguments  } , 
6667      } ) 
67- 
68-       response . dig ( "result" ,  "content" ) 
6968    end 
7069
7170    private 
Original file line number Diff line number Diff line change @@ -53,8 +53,9 @@ def test_call_tool_sends_request_to_transport_and_returns_content
5353
5454      client  =  Client . new ( transport : transport ) 
5555      result  =  client . call_tool ( tool : tool ,  arguments : arguments ) 
56+       content  =  result . dig ( "result" ,  "content" ) 
5657
57-       assert_equal ( "result" ,  result ) 
58+       assert_equal ( "result" ,  content ) 
5859    end 
5960  end 
6061end 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments