@@ -58,14 +58,32 @@ def tools
5858 # The exact requirements for `arguments` are determined by the transport layer in use.
5959 # Consult the documentation for your transport (e.g., MCP::Client::HTTP) for details.
6060 def call_tool ( tool :, arguments : nil )
61- response = transport . send_request ( request : {
61+ response = call_tool_raw ( tool : tool , arguments : arguments )
62+
63+ response . dig ( "result" , "content" )
64+ end
65+
66+ # Calls a tool via the transport layer and returns the full response from the server.
67+ #
68+ # @param tool [MCP::Client::Tool] The tool to be called.
69+ # @param arguments [Object, nil] The arguments to pass to the tool.
70+ # @return [Hash] The full JSON-RPC response from the transport.
71+ #
72+ # @example
73+ # tool = client.tools.first
74+ # response = client.call_tool_with_response(tool: tool, arguments: { foo: "bar" })
75+ # structured_content = response.dig("result", "structuredContent")
76+ #
77+ # @note
78+ # The exact requirements for `arguments` are determined by the transport layer in use.
79+ # Consult the documentation for your transport (e.g., MCP::Client::HTTP) for details.
80+ def call_tool_raw ( tool :, arguments : nil )
81+ transport . send_request ( request : {
6282 jsonrpc : JsonRpcHandler ::Version ::V2_0 ,
6383 id : request_id ,
6484 method : "tools/call" ,
6585 params : { name : tool . name , arguments : arguments } ,
6686 } )
67-
68- response . dig ( "result" , "content" )
6987 end
7088
7189 private
0 commit comments