Module: ActionMCP::Client::Tools

Included in:
Base
Defined in:
lib/action_mcp/client/tools.rb

Instance Method Summary collapse

Instance Method Details

#call_tool(name, arguments) ⇒ String

Call a specific tool on the server

Parameters:

  • name (String)

    Name of the tool to call

  • arguments (Hash)

    Arguments to pass to the tool

Returns:

  • (String)

    Request ID for tracking the request



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/action_mcp/client/tools.rb', line 31

def call_tool(name, arguments)
  request_id = SecureRandom.uuid_v7

  # Send request
  send_jsonrpc_request("tools/call",
                       params: {
                         name: name,
                         arguments: arguments
                       },
                       id: request_id)

  # Return request ID for tracking the request
  request_id
end

#list_tools(params = {}) ⇒ String

List all available tools from the server

Parameters:

  • params (Hash) (defaults to: {})

    Optional parameters for pagination

Options Hash (params):

  • :cursor (String)

    Pagination cursor for fetching next page

  • :limit (Integer)

    Maximum number of items to return

Returns:

  • (String)

    Request ID for tracking the request



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/action_mcp/client/tools.rb', line 11

def list_tools(params = {})
  request_id = SecureRandom.uuid_v7

  # Send request with pagination parameters if provided
  request_params = {}
  request_params[:cursor] = params[:cursor] if params[:cursor]
  request_params[:limit] = params[:limit] if params[:limit]

  send_jsonrpc_request("tools/list",
                       params: request_params.empty? ? nil : request_params,
                       id: request_id)

  # Return request ID for timeout tracking
  request_id
end