ruby_llm-docker 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,143 +2,124 @@
2
2
 
3
3
  module RubyLLM
4
4
  module Docker
5
- # RubyLLM tool for executing commands inside running Docker containers.
5
+ # MCP tool for executing commands inside Docker containers.
6
6
  #
7
- # This tool provides the ability to execute arbitrary commands inside running
8
- # Docker containers, with full control over execution environment including
9
- # working directory, user context, environment variables, and stdin input.
7
+ # This tool provides the ability to execute arbitrary commands inside
8
+ # running Docker containers. It supports interactive and non-interactive
9
+ # execution, environment variable injection, working directory specification,
10
+ # and user context switching within the container.
10
11
  #
11
- # == ⚠️ CRITICAL SECURITY WARNING ⚠️
12
+ # == Features
12
13
  #
13
- # This tool is EXTREMELY DANGEROUS as it allows arbitrary command execution
14
- # within Docker containers. This can be used to:
15
- # - Execute malicious code inside containers
16
- # - Access sensitive data within container filesystems
17
- # - Escalate privileges if container is poorly configured
18
- # - Perform lateral movement within containerized environments
19
- # - Exfiltrate data from applications
14
+ # - Execute arbitrary commands in running containers
15
+ # - Support for command arguments and shell parsing
16
+ # - Environment variable injection
17
+ # - Working directory specification
18
+ # - User context switching (run as specific user)
19
+ # - Standard input, output, and error handling
20
+ # - Configurable execution timeouts
20
21
  #
21
- # ONLY use this tool in trusted environments with proper security controls:
22
- # - Ensure containers run with minimal privileges
23
- # - Use read-only filesystems where possible
24
- # - Implement proper network segmentation
25
- # - Monitor and audit all command executions
26
- # - Never expose this tool to untrusted clients
22
+ # == Security Considerations
27
23
  #
28
- # == Features
24
+ # **CRITICAL WARNING**: This tool provides arbitrary command execution
25
+ # capabilities with significant security implications:
26
+ #
27
+ # - **Code Execution**: Can run any command available in the container
28
+ # - **File System Access**: Can read, write, and modify container files
29
+ # - **Network Access**: Can initiate network connections from container
30
+ # - **Process Manipulation**: Can start, stop, and signal processes
31
+ # - **Data Exposure**: Can access sensitive data within the container
32
+ # - **Privilege Escalation**: May exploit container or kernel vulnerabilities
33
+ # - **Resource Consumption**: Can consume container and host resources
34
+ #
35
+ # **Security Recommendations**:
36
+ # - Implement strict access controls and authentication
37
+ # - Use dedicated execution containers with minimal privileges
38
+ # - Monitor and log all command executions
39
+ # - Apply resource limits and timeouts
40
+ # - Validate and sanitize all command inputs
41
+ # - Consider using read-only file systems where possible
42
+ # - Implement network segmentation for container environments
29
43
  #
30
- # - Execute commands with custom working directory
31
- # - Run commands as specific users
32
- # - Set custom environment variables
33
- # - Provide stdin input to commands
34
- # - Configurable timeout protection
35
- # - Comprehensive error handling
36
- # - Separate stdout/stderr capture
44
+ # == Parameters
45
+ #
46
+ # - **id**: Container ID or name (required)
47
+ # - **cmd**: Command to execute (shell-parsed into arguments) (required)
48
+ # - **working_dir**: Working directory for command execution (optional)
49
+ # - **user**: User to run the command as (optional, e.g., "1000" or "username")
50
+ # - **env**: Environment variables as comma-separated KEY=VALUE pairs (optional)
51
+ # - **stdin**: Input to send to command via stdin (optional)
52
+ # - **timeout**: Timeout in seconds (optional, default: 60)
37
53
  #
38
54
  # == Example Usage
39
55
  #
40
- # # Simple command execution
41
- # ExecContainer.call(
56
+ # # Basic command execution
57
+ # response = ExecContainer.call(
42
58
  # server_context: context,
43
- # id: "my-container",
44
- # cmd: "ls -la /app"
59
+ # id: "web-container",
60
+ # cmd: "nginx -t"
45
61
  # )
46
62
  #
47
- # # Advanced execution with custom environment
48
- # ExecContainer.call(
63
+ # # Advanced execution with environment
64
+ # response = ExecContainer.call(
49
65
  # server_context: context,
50
- # id: "web-server",
51
- # cmd: "python manage.py migrate",
66
+ # id: "app-container",
67
+ # cmd: "bundle exec rails console",
52
68
  # working_dir: "/app",
53
- # user: "appuser",
54
- # env: ["DJANGO_ENV=production", "DEBUG=false"],
55
- # timeout: 120
69
+ # user: "rails",
70
+ # env: "RAILS_ENV=production,DEBUG=true",
71
+ # timeout: 300
56
72
  # )
57
73
  #
58
- # @see Docker::Container#exec
74
+ # @see ::Docker::Container#exec
59
75
  # @since 0.1.0
60
- class ExecContainer < RubyLLM::Tool
76
+ EXEC_CONTAINER_DEFINITION = ToolForge.define(:exec_container) do
61
77
  description 'Execute a command inside a running Docker container. ' \
62
78
  'WARNING: This provides arbitrary command execution within the container. ' \
63
79
  'Ensure proper security measures are in place.'
64
80
 
65
- param :id, type: :string, desc: 'Container ID or name'
66
- param :cmd, type: :string, desc: 'Command to execute (e.g., "ls -la /app" or "python script.py")'
67
- param :working_dir, type: :string, desc: 'Working directory for the command (optional)', required: false
68
- param :user, type: :string, desc: 'User to run the command as (optional, e.g., "1000" or "username")',
69
- required: false
70
- param :env, type: :string,
71
- desc: 'Environment variables as comma-separated KEY=VALUE pairs ' \
72
- '(optional, e.g., "VAR1=value1,VAR2=value2")',
73
- required: false
74
- param :stdin, type: :string, desc: 'Input to send to the command via stdin (optional)', required: false
75
- param :timeout, type: :integer, desc: 'Timeout in seconds (optional, default: 60)', required: false
76
-
77
- # Execute a command inside a running Docker container.
78
- #
79
- # This method provides comprehensive command execution capabilities within
80
- # Docker containers, including advanced features like custom user context,
81
- # environment variables, working directory, and stdin input.
82
- #
83
- # The command is parsed using shell-like syntax with support for quoted
84
- # arguments. Output is captured separately for stdout and stderr, and
85
- # the exit code is reported.
86
- #
87
- # @param id [String] container ID or name to execute command in
88
- # @param cmd [String] command to execute (shell-parsed into arguments)
89
- # @param server_context [Object] RubyLLM context (unused but required)
90
- # @param working_dir [String, nil] working directory for command execution
91
- # @param user [String, nil] user to run command as (username or UID)
92
- # @param env [String, nil] environment variables as comma-separated KEY=VALUE pairs
93
- # @param stdin [String, nil] input to send to command via stdin
94
- # @param timeout [Integer] maximum execution time in seconds (default: 60)
95
- #
96
- # @return [RubyLLM::Tool::Response] execution results including stdout, stderr, and exit code
97
- #
98
- # @raise [Docker::Error::NotFoundError] if container doesn't exist
99
- # @raise [Docker::Error::TimeoutError] if execution exceeds timeout
100
- # @raise [StandardError] for other execution failures
101
- #
102
- # @example Basic command execution
103
- # response = ExecContainer.call(
104
- # server_context: context,
105
- # id: "web-container",
106
- # cmd: "nginx -t"
107
- # )
108
- #
109
- # @example Advanced execution with environment
110
- # response = tool.execute(
111
- # id: "app-container",
112
- # cmd: "bundle exec rails console",
113
- # working_dir: "/app",
114
- # user: "rails",
115
- # env: ["RAILS_ENV=production"],
116
- # timeout: 300
117
- # )
118
- #
119
- # @see Docker::Container#exec
120
- def execute(id:, cmd:, working_dir: nil, user: nil,
121
- env: nil, stdin: nil, timeout: 60)
81
+ param :id,
82
+ type: :string,
83
+ description: 'Container ID or name'
84
+
85
+ param :cmd,
86
+ type: :string,
87
+ description: 'Command to execute (e.g., "ls -la /app" or "python script.py")'
88
+
89
+ param :working_dir,
90
+ type: :string,
91
+ description: 'Working directory for the command (optional)',
92
+ required: false
93
+
94
+ param :user,
95
+ type: :string,
96
+ description: 'User to run the command as (optional, e.g., "1000" or "username")',
97
+ required: false
98
+
99
+ param :env,
100
+ type: :string,
101
+ description: 'Environment variables as comma-separated KEY=VALUE pairs (optional)',
102
+ required: false
103
+
104
+ param :stdin,
105
+ type: :string,
106
+ description: 'Input to send to the command via stdin (optional)',
107
+ required: false
108
+
109
+ param :timeout,
110
+ type: :integer,
111
+ description: 'Timeout in seconds (optional, default: 60)',
112
+ required: false,
113
+ default: 60
114
+
115
+ execute do |id:, cmd:, working_dir: nil, user: nil, env: nil, stdin: nil, timeout: 60|
122
116
  container = ::Docker::Container.get(id)
123
117
 
124
118
  # Parse command string into array
125
- # Simple shell-like parsing: split on spaces but respect quoted strings
126
119
  cmd_array = Shellwords.split(cmd)
127
120
 
128
- # Parse environment variables string into array if provided
129
- env_array = nil
130
- env_array = env.split(',').map(&:strip).select { |e| e.include?('=') } if env && !env.empty?
131
-
132
- # Build exec options
133
- exec_options = {
134
- 'Cmd' => cmd_array,
135
- 'AttachStdout' => true,
136
- 'AttachStderr' => true
137
- }
138
- exec_options['WorkingDir'] = working_dir if working_dir
139
- exec_options['User'] = user if user
140
- exec_options['Env'] = env_array if env_array
141
- exec_options['AttachStdin'] = true if stdin
121
+ # Parse environment variables from comma-separated string to array
122
+ env.split(',').map(&:strip) if env && !env.empty?
142
123
 
143
124
  # Execute the command
144
125
  stdout_data = []
@@ -181,5 +162,7 @@ module RubyLLM
181
162
  "Error executing command: #{e.message}"
182
163
  end
183
164
  end
165
+
166
+ ExecContainer = EXEC_CONTAINER_DEFINITION.to_ruby_llm_tool
184
167
  end
185
168
  end
@@ -2,116 +2,92 @@
2
2
 
3
3
  module RubyLLM
4
4
  module Docker
5
- # RubyLLM tool for retrieving Docker container logs.
5
+ # MCP tool for fetching Docker container logs.
6
6
  #
7
- # This tool provides access to container logs with flexible filtering and
8
- # formatting options. It can retrieve both stdout and stderr logs with
9
- # optional timestamps and tail functionality for recent entries.
7
+ # This tool retrieves log output from Docker containers, including both
8
+ # standard output and standard error streams. It supports filtering by
9
+ # stream type, limiting output length, timestamp inclusion, and retrieving
10
+ # logs from both running and stopped containers.
10
11
  #
11
12
  # == Features
12
13
  #
13
- # - Retrieve stdout and/or stderr logs
14
- # - Optional timestamp inclusion
15
- # - Tail functionality for recent logs
16
- # - Flexible log stream selection
17
- # - Comprehensive error handling
18
- # - Works with any container state
19
- #
20
- # == Log Sources
21
- #
22
- # Docker containers can generate logs from multiple sources:
23
- # - **stdout**: Standard output from container processes
24
- # - **stderr**: Standard error from container processes
25
- # - **timestamps**: Docker-generated timestamps for each log line
14
+ # - Fetch logs from running and stopped containers
15
+ # - Separate or combined stdout and stderr streams
16
+ # - Configurable output length limiting (tail functionality)
17
+ # - Optional timestamp inclusion for log entries
18
+ # - Support for container identification by ID or name
19
+ # - Comprehensive error handling and status reporting
26
20
  #
27
21
  # == Security Considerations
28
22
  #
29
23
  # Container logs may contain sensitive information:
30
- # - Application secrets and API keys
31
- # - User data and personal information
32
- # - Internal system information
33
- # - Database connection strings
34
- # - Error messages with stack traces
24
+ # - **Application Data**: Database queries, API keys, user data
25
+ # - **System Information**: Internal paths, configuration details
26
+ # - **Error Details**: Stack traces revealing application internals
27
+ # - **Access Patterns**: User behavior and system usage information
28
+ # - **Debugging Information**: Temporary credentials or session data
29
+ #
30
+ # Implement proper access controls and data sanitization for log access.
35
31
  #
36
- # Security recommendations:
37
- # - Review log content before sharing
38
- # - Limit access to container logs
39
- # - Sanitize logs in production environments
40
- # - Use log rotation to manage log size
41
- # - Be cautious with log forwarding
32
+ # == Parameters
33
+ #
34
+ # - **id**: Container ID or name (required)
35
+ # - **stdout**: Include stdout in logs (optional, default: true)
36
+ # - **stderr**: Include stderr in logs (optional, default: true)
37
+ # - **timestamps**: Show timestamps for log entries (optional, default: false)
38
+ # - **tail**: Number of lines to show from end of logs (optional, default: all)
42
39
  #
43
40
  # == Example Usage
44
41
  #
45
- # # Get all logs
46
- # FetchContainerLogs.call(
42
+ # # Fetch all logs
43
+ # response = FetchContainerLogs.call(
47
44
  # server_context: context,
48
45
  # id: "web-server"
49
46
  # )
50
47
  #
51
- # # Get recent logs with timestamps
52
- # FetchContainerLogs.call(
48
+ # # Fetch recent errors with timestamps
49
+ # response = FetchContainerLogs.call(
53
50
  # server_context: context,
54
51
  # id: "app-container",
55
- # tail: 100,
56
- # timestamps: true
57
- # )
58
- #
59
- # # Get only error logs
60
- # FetchContainerLogs.call(
61
- # server_context: context,
62
- # id: "database",
63
52
  # stdout: false,
64
- # stderr: true
53
+ # stderr: true,
54
+ # timestamps: true,
55
+ # tail: 100
65
56
  # )
66
57
  #
67
- # @see ExecContainer
68
- # @see Docker::Container#logs
58
+ # @see ::Docker::Container#logs
69
59
  # @since 0.1.0
70
- class FetchContainerLogs < RubyLLM::Tool
60
+ FETCH_CONTAINER_LOGS_DEFINITION = ToolForge.define(:fetch_container_logs) do
71
61
  description 'Fetch Docker container logs'
72
62
 
73
- param :id, type: :string, desc: 'Container ID or name'
74
- param :stdout, type: :boolean, desc: 'Include stdout (default: true)', required: false
75
- param :stderr, type: :boolean, desc: 'Include stderr (default: true)', required: false
76
- param :tail, type: :integer, desc: 'Number of lines to show from the end of logs (default: all)',
77
- required: false
78
- param :timestamps, type: :boolean, desc: 'Show timestamps (default: false)', required: false
63
+ param :id,
64
+ type: :string,
65
+ description: 'Container ID or name'
66
+
67
+ param :stdout,
68
+ type: :boolean,
69
+ description: 'Include stdout (default: true)',
70
+ required: false,
71
+ default: true
72
+
73
+ param :stderr,
74
+ type: :boolean,
75
+ description: 'Include stderr (default: true)',
76
+ required: false,
77
+ default: true
79
78
 
80
- # Retrieve logs from a Docker container.
81
- #
82
- # This method fetches logs from the specified container with configurable
83
- # options for log sources (stdout/stderr), formatting (timestamps), and
84
- # quantity (tail). The logs are returned as a text response.
85
- #
86
- # @param id [String] container ID (full or short) or container name
87
- # @param server_context [Object] RubyLLM context (unused but required)
88
- # @param stdout [Boolean] whether to include stdout logs (default: true)
89
- # @param stderr [Boolean] whether to include stderr logs (default: true)
90
- # @param tail [Integer, nil] number of recent lines to return (nil for all)
91
- # @param timestamps [Boolean] whether to include timestamps (default: false)
92
- #
93
- # @return [RubyLLM::Tool::Response] container logs as text
94
- #
95
- # @raise [Docker::Error::NotFoundError] if container doesn't exist
96
- # @raise [StandardError] for other log retrieval failures
97
- #
98
- # @example Get all logs
99
- # response = FetchContainerLogs.call(
100
- # server_context: context,
101
- # id: "nginx-server"
102
- # )
103
- #
104
- # @example Get recent error logs with timestamps
105
- # response = tool.execute(
106
- # id: "app-container",
107
- # stdout: false,
108
- # stderr: true,
109
- # tail: 50,
110
- # timestamps: true
111
- # )
112
- #
113
- # @see Docker::Container#logs
114
- def execute(id:, stdout: true, stderr: true, tail: nil, timestamps: false)
79
+ param :tail,
80
+ type: :integer,
81
+ description: 'Number of lines to show from the end of logs (default: all)',
82
+ required: false
83
+
84
+ param :timestamps,
85
+ type: :boolean,
86
+ description: 'Show timestamps (default: false)',
87
+ required: false,
88
+ default: false
89
+
90
+ execute do |id:, stdout: true, stderr: true, tail: nil, timestamps: false|
115
91
  container = ::Docker::Container.get(id)
116
92
 
117
93
  options = {
@@ -128,5 +104,7 @@ module RubyLLM
128
104
  "Error fetching logs: #{e.message}"
129
105
  end
130
106
  end
107
+
108
+ FetchContainerLogs = FETCH_CONTAINER_LOGS_DEFINITION.to_ruby_llm_tool
131
109
  end
132
110
  end
@@ -2,58 +2,64 @@
2
2
 
3
3
  module RubyLLM
4
4
  module Docker
5
- # RubyLLM tool for listing Docker containers.
5
+ # MCP tool for listing Docker containers.
6
6
  #
7
- # This tool provides functionality to list all Docker containers on the system,
8
- # including both running and stopped containers. It returns detailed information
9
- # about each container including names, images, status, ports, and other metadata.
7
+ # This tool provides comprehensive information about all Docker containers
8
+ # on the system, including both running and stopped containers. It returns
9
+ # detailed metadata for each container including names, images, status,
10
+ # network configuration, and resource usage.
10
11
  #
11
- # == Security Notes
12
+ # == Features
12
13
  #
13
- # This is a read-only operation that provides system information about containers.
14
- # While generally safe, it may reveal information about the Docker environment
15
- # that could be useful for reconnaissance.
14
+ # - Lists all containers (running and stopped)
15
+ # - Provides detailed container metadata
16
+ # - Shows network configuration and port mappings
17
+ # - Displays resource usage and statistics
18
+ # - Includes mount point information
19
+ # - Shows container labels and annotations
16
20
  #
17
- # == Example Usage
21
+ # == Security Considerations
22
+ #
23
+ # This tool provides system information that could be useful for:
24
+ # - **System Reconnaissance**: Reveals running services and configurations
25
+ # - **Network Discovery**: Shows internal network topology
26
+ # - **Resource Analysis**: Exposes system resource usage patterns
18
27
  #
19
- # # List all containers (default behavior)
20
- # ListContainers.call(server_context: context)
28
+ # Use with appropriate access controls in production environments.
21
29
  #
22
- # # Explicitly request all containers
23
- # ListContainers.call(server_context: context, all: true)
30
+ # == Return Format
24
31
  #
25
- # @see Docker::Container.all
32
+ # Returns an array of container objects with comprehensive metadata:
33
+ # - Container names and IDs
34
+ # - Image information and tags
35
+ # - Current state and status
36
+ # - Network settings and port bindings
37
+ # - Mount points and volumes
38
+ # - Labels and environment details
39
+ #
40
+ # == Example Usage
41
+ #
42
+ # containers = ListContainers.call(server_context: context)
43
+ # containers.each do |container|
44
+ # puts "#{container['Names'].first}: #{container['State']}"
45
+ # end
46
+ #
47
+ # @see ::Docker::Container.all
26
48
  # @since 0.1.0
27
- class ListContainers < RubyLLM::Tool
49
+ LIST_CONTAINERS_DEFINITION = ToolForge.define(:list_containers) do
28
50
  description 'List Docker containers'
29
51
 
30
- param :all, type: :boolean, desc: 'Show all containers (default shows all containers including stopped ones)',
31
- required: false
52
+ param :all,
53
+ type: :boolean,
54
+ description: 'Show all containers (default shows all containers including stopped ones)',
55
+ required: false,
56
+ default: true
32
57
 
33
- # List all Docker containers with detailed information.
34
- #
35
- # Retrieves information about all containers on the system, including:
36
- # - Container names and IDs
37
- # - Image information
38
- # - Current state (running, stopped, etc.)
39
- # - Port mappings
40
- # - Network configuration
41
- # - Volume mounts
42
- # - Creation and status timestamps
43
- #
44
- # @param server_context [Object] the RubyLLM context (unused but required)
45
- # @param all [Boolean] whether to show all containers (default: true)
46
- # @return [RubyLLM::Tool::Response] response containing container information
47
- #
48
- # @example List all containers
49
- # response = ListContainers.call(server_context: context)
50
- # # Returns detailed info for all containers
51
- #
52
- # @see Docker::Container.all
53
- def execute(all: true)
54
- require 'docker'
55
- ::Docker::Container.all(all: all).map(&:info).to_s
58
+ execute do |all: true|
59
+ ::Docker::Container.all(all: all).map(&:info)
56
60
  end
57
61
  end
62
+
63
+ ListContainers = LIST_CONTAINERS_DEFINITION.to_ruby_llm_tool
58
64
  end
59
65
  end
@@ -2,78 +2,57 @@
2
2
 
3
3
  module RubyLLM
4
4
  module Docker
5
- # RubyLLM tool for listing Docker images.
5
+ # MCP tool for listing Docker images.
6
6
  #
7
- # This tool provides functionality to list all Docker images available on
8
- # the local system. It returns comprehensive information about each image
9
- # including IDs, tags, sizes, creation dates, and other metadata.
7
+ # This tool provides comprehensive information about all Docker images
8
+ # stored on the local system. It returns detailed metadata including
9
+ # image sizes, creation dates, tags, and usage statistics.
10
10
  #
11
11
  # == Features
12
12
  #
13
- # - List all local Docker images
14
- # - Comprehensive image metadata
15
- # - No configuration required
16
- # - Read-only operation
17
- # - Includes both tagged and untagged images
13
+ # - Lists all locally stored Docker images
14
+ # - Provides detailed image metadata and statistics
15
+ # - Shows image sizes and storage usage
16
+ # - Displays repository tags and digests
17
+ # - Includes creation timestamps and labels
18
+ # - Reports container usage counts
18
19
  #
19
- # == Image Information Included
20
+ # == Security Considerations
20
21
  #
21
- # The response typically includes:
22
- # - **Image ID**: Unique identifier for the image
23
- # - **Repository Tags**: All tags associated with the image
24
- # - **Size**: Virtual and actual size of the image
25
- # - **Created**: Timestamp when image was created
26
- # - **Parent ID**: Base image information
27
- # - **RepoDigests**: Content-addressable identifiers
22
+ # This tool provides information that could be useful for:
23
+ # - **System Analysis**: Reveals installed software and versions
24
+ # - **Vulnerability Assessment**: Shows potential attack surfaces
25
+ # - **Resource Planning**: Exposes storage usage patterns
28
26
  #
29
- # == Security Considerations
27
+ # Monitor access to this tool in production environments.
30
28
  #
31
- # This is a read-only operation that reveals system information:
32
- # - Exposes available images and versions
33
- # - May reveal internal application details
34
- # - Shows image sources and repositories
35
- # - Could aid in reconnaissance activities
29
+ # == Return Format
36
30
  #
37
- # While generally safe, consider access control:
38
- # - Limit exposure of image inventory
39
- # - Be cautious with sensitive image names
40
- # - Monitor for unauthorized image access attempts
31
+ # Returns an array of image objects with comprehensive metadata:
32
+ # - Repository tags and digests
33
+ # - Image sizes and virtual sizes
34
+ # - Creation timestamps
35
+ # - Container usage counts
36
+ # - Labels and annotations
37
+ # - Parent-child relationships
41
38
  #
42
39
  # == Example Usage
43
40
  #
44
- # # List all images
45
- # ListImages.call(server_context: context)
41
+ # images = ListImages.call(server_context: context)
42
+ # images.each do |image|
43
+ # puts "#{image['RepoTags']}: #{image['Size']} bytes"
44
+ # end
46
45
  #
47
- # @example Usage in container management
48
- # # Get available images before container creation
49
- # images_response = ListImages.call(server_context: context)
50
- # # Use image information to select appropriate base images
51
- #
52
- # @see PullImage
53
- # @see BuildImage
54
- # @see Docker::Image.all
46
+ # @see ::Docker::Image.all
55
47
  # @since 0.1.0
56
- class ListImages < RubyLLM::Tool
48
+ LIST_IMAGES_DEFINITION = ToolForge.define(:list_images) do
57
49
  description 'List Docker images'
58
50
 
59
- # List all Docker images available on the local system.
60
- #
61
- # This method retrieves information about all Docker images stored
62
- # locally, including both tagged and untagged images. The information
63
- # includes comprehensive metadata for each image.
64
- #
65
- # @param args [Array] variable arguments (unused but accepted for compatibility)
66
- #
67
- # @return [RubyLLM::Tool::Response] comprehensive image information
68
- #
69
- # @example List all local images
70
- # response = ListImages.call
71
- # # Returns detailed info for all local Docker images
72
- #
73
- # @see Docker::Image.all
74
- def execute
75
- ::Docker::Image.all.map(&:info).to_s
51
+ execute do
52
+ ::Docker::Image.all.map(&:info)
76
53
  end
77
54
  end
55
+
56
+ ListImages = LIST_IMAGES_DEFINITION.to_ruby_llm_tool
78
57
  end
79
58
  end