docker_mcp 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.
- checksums.yaml +4 -4
- data/lib/docker_mcp/build_image.rb +65 -84
- data/lib/docker_mcp/copy_to_container.rb +87 -161
- data/lib/docker_mcp/create_container.rb +63 -115
- data/lib/docker_mcp/create_network.rb +63 -102
- data/lib/docker_mcp/create_volume.rb +57 -100
- data/lib/docker_mcp/exec_container.rb +94 -147
- data/lib/docker_mcp/fetch_container_logs.rb +64 -117
- data/lib/docker_mcp/list_containers.rb +44 -47
- data/lib/docker_mcp/list_images.rb +32 -56
- data/lib/docker_mcp/list_networks.rb +33 -60
- data/lib/docker_mcp/list_volumes.rb +33 -67
- data/lib/docker_mcp/pull_image.rb +24 -68
- data/lib/docker_mcp/push_image.rb +61 -118
- data/lib/docker_mcp/recreate_container.rb +48 -99
- data/lib/docker_mcp/remove_container.rb +49 -101
- data/lib/docker_mcp/remove_image.rb +53 -119
- data/lib/docker_mcp/remove_network.rb +42 -96
- data/lib/docker_mcp/remove_volume.rb +52 -106
- data/lib/docker_mcp/run_container.rb +72 -82
- data/lib/docker_mcp/start_container.rb +36 -76
- data/lib/docker_mcp/stop_container.rb +41 -86
- data/lib/docker_mcp/tag_image.rb +67 -121
- data/lib/docker_mcp/version.rb +1 -1
- data/lib/docker_mcp.rb +2 -0
- metadata +15 -1
@@ -3,78 +3,54 @@
|
|
3
3
|
module DockerMCP
|
4
4
|
# MCP tool for listing Docker images.
|
5
5
|
#
|
6
|
-
# This tool provides
|
7
|
-
# the local system. It returns
|
8
|
-
#
|
6
|
+
# This tool provides comprehensive information about all Docker images
|
7
|
+
# stored on the local system. It returns detailed metadata including
|
8
|
+
# image sizes, creation dates, tags, and usage statistics.
|
9
9
|
#
|
10
10
|
# == Features
|
11
11
|
#
|
12
|
-
# -
|
13
|
-
# -
|
14
|
-
# -
|
15
|
-
# -
|
16
|
-
# - Includes
|
12
|
+
# - Lists all locally stored Docker images
|
13
|
+
# - Provides detailed image metadata and statistics
|
14
|
+
# - Shows image sizes and storage usage
|
15
|
+
# - Displays repository tags and digests
|
16
|
+
# - Includes creation timestamps and labels
|
17
|
+
# - Reports container usage counts
|
17
18
|
#
|
18
|
-
# ==
|
19
|
+
# == Security Considerations
|
19
20
|
#
|
20
|
-
#
|
21
|
-
# - **
|
22
|
-
# - **
|
23
|
-
# - **
|
24
|
-
# - **Created**: Timestamp when image was created
|
25
|
-
# - **Parent ID**: Base image information
|
26
|
-
# - **RepoDigests**: Content-addressable identifiers
|
21
|
+
# This tool provides information that could be useful for:
|
22
|
+
# - **System Analysis**: Reveals installed software and versions
|
23
|
+
# - **Vulnerability Assessment**: Shows potential attack surfaces
|
24
|
+
# - **Resource Planning**: Exposes storage usage patterns
|
27
25
|
#
|
28
|
-
#
|
26
|
+
# Monitor access to this tool in production environments.
|
29
27
|
#
|
30
|
-
#
|
31
|
-
# - Exposes available images and versions
|
32
|
-
# - May reveal internal application details
|
33
|
-
# - Shows image sources and repositories
|
34
|
-
# - Could aid in reconnaissance activities
|
28
|
+
# == Return Format
|
35
29
|
#
|
36
|
-
#
|
37
|
-
# -
|
38
|
-
# -
|
39
|
-
# -
|
30
|
+
# Returns an array of image objects with comprehensive metadata:
|
31
|
+
# - Repository tags and digests
|
32
|
+
# - Image sizes and virtual sizes
|
33
|
+
# - Creation timestamps
|
34
|
+
# - Container usage counts
|
35
|
+
# - Labels and annotations
|
36
|
+
# - Parent-child relationships
|
40
37
|
#
|
41
38
|
# == Example Usage
|
42
39
|
#
|
43
|
-
#
|
44
|
-
#
|
40
|
+
# images = ListImages.call(server_context: context)
|
41
|
+
# images.each do |image|
|
42
|
+
# puts "#{image['RepoTags']}: #{image['Size']} bytes"
|
43
|
+
# end
|
45
44
|
#
|
46
|
-
# @example Usage in container management
|
47
|
-
# # Get available images before container creation
|
48
|
-
# images_response = ListImages.call(server_context: context)
|
49
|
-
# # Use image information to select appropriate base images
|
50
|
-
#
|
51
|
-
# @see PullImage
|
52
|
-
# @see BuildImage
|
53
45
|
# @see Docker::Image.all
|
54
46
|
# @since 0.1.0
|
55
|
-
|
47
|
+
LIST_IMAGES_DEFINITION = ToolForge.define(:list_images) do
|
56
48
|
description 'List Docker images'
|
57
49
|
|
58
|
-
|
59
|
-
|
60
|
-
# This method retrieves information about all Docker images stored
|
61
|
-
# locally, including both tagged and untagged images. The information
|
62
|
-
# includes comprehensive metadata for each image.
|
63
|
-
#
|
64
|
-
# @param args [Array] variable arguments (unused but accepted for compatibility)
|
65
|
-
#
|
66
|
-
# @return [MCP::Tool::Response] comprehensive image information
|
67
|
-
#
|
68
|
-
# @example List all local images
|
69
|
-
# response = ListImages.call
|
70
|
-
# # Returns detailed info for all local Docker images
|
71
|
-
#
|
72
|
-
# @see Docker::Image.all
|
73
|
-
def self.call(*)
|
74
|
-
MCP::Tool::Response.new([{
|
75
|
-
type: 'text',
|
76
|
-
text: Docker::Image.all.map(&:info).to_s
|
77
|
-
}])
|
50
|
+
execute do
|
51
|
+
Docker::Image.all.map(&:info)
|
78
52
|
end
|
79
53
|
end
|
54
|
+
|
55
|
+
ListImages = LIST_IMAGES_DEFINITION.to_mcp_tool
|
80
56
|
end
|
@@ -3,82 +3,55 @@
|
|
3
3
|
module DockerMCP
|
4
4
|
# MCP tool for listing Docker networks.
|
5
5
|
#
|
6
|
-
# This tool provides
|
7
|
-
# the system
|
8
|
-
#
|
9
|
-
# configuration, drivers, and connected containers.
|
6
|
+
# This tool provides comprehensive information about all Docker networks
|
7
|
+
# configured on the system. It returns detailed network configuration
|
8
|
+
# including IPAM settings, connected containers, and network drivers.
|
10
9
|
#
|
11
10
|
# == Features
|
12
11
|
#
|
13
|
-
# -
|
14
|
-
# -
|
15
|
-
# -
|
16
|
-
# -
|
17
|
-
# - Includes
|
12
|
+
# - Lists all Docker networks (built-in and custom)
|
13
|
+
# - Provides detailed network configuration
|
14
|
+
# - Shows IPAM (IP Address Management) settings
|
15
|
+
# - Displays connected containers
|
16
|
+
# - Includes driver information and options
|
17
|
+
# - Reports network scope and capabilities
|
18
18
|
#
|
19
|
-
# ==
|
19
|
+
# == Security Considerations
|
20
20
|
#
|
21
|
-
#
|
22
|
-
# - **Network
|
23
|
-
# - **
|
24
|
-
# - **
|
25
|
-
# - **
|
26
|
-
# - **IPAM**: IP Address Management configuration
|
27
|
-
# - **Connected Containers**: Containers attached to the network
|
28
|
-
# - **Options**: Driver-specific configuration options
|
21
|
+
# Network information can be sensitive as it reveals:
|
22
|
+
# - **Network Topology**: Internal network architecture
|
23
|
+
# - **IP Addressing**: Subnet configurations and ranges
|
24
|
+
# - **Container Connectivity**: Service interconnections
|
25
|
+
# - **Network Isolation**: Security boundary configurations
|
29
26
|
#
|
30
|
-
#
|
27
|
+
# Restrict access to this tool in production environments.
|
31
28
|
#
|
32
|
-
#
|
33
|
-
# - Exposes network architecture and segmentation
|
34
|
-
# - Shows container connectivity patterns
|
35
|
-
# - May reveal internal network design
|
36
|
-
# - Could aid in network reconnaissance
|
29
|
+
# == Return Format
|
37
30
|
#
|
38
|
-
#
|
39
|
-
# -
|
40
|
-
# -
|
41
|
-
# -
|
42
|
-
# -
|
31
|
+
# Returns an array of network objects with comprehensive metadata:
|
32
|
+
# - Network names and IDs
|
33
|
+
# - Driver types and configurations
|
34
|
+
# - IPAM settings and subnet information
|
35
|
+
# - Connected container details
|
36
|
+
# - Network options and labels
|
37
|
+
# - Scope and capability flags
|
43
38
|
#
|
44
39
|
# == Example Usage
|
45
40
|
#
|
46
|
-
#
|
47
|
-
#
|
41
|
+
# networks = ListNetworks.call(server_context: context)
|
42
|
+
# networks.each do |network|
|
43
|
+
# puts "#{network['Name']}: #{network['Driver']}"
|
44
|
+
# end
|
48
45
|
#
|
49
|
-
# @example Usage in network management
|
50
|
-
# # Get available networks before container creation
|
51
|
-
# networks_response = ListNetworks.call(server_context: context)
|
52
|
-
# # Use network information to select appropriate networks
|
53
|
-
#
|
54
|
-
# @see CreateNetwork
|
55
|
-
# @see RemoveNetwork
|
56
46
|
# @see Docker::Network.all
|
57
47
|
# @since 0.1.0
|
58
|
-
|
48
|
+
LIST_NETWORKS_DEFINITION = ToolForge.define(:list_networks) do
|
59
49
|
description 'List Docker networks'
|
60
50
|
|
61
|
-
|
62
|
-
|
63
|
-
# This method retrieves information about all Docker networks, including
|
64
|
-
# both system-created networks (bridge, host, none) and user-defined
|
65
|
-
# custom networks. The information includes comprehensive metadata for
|
66
|
-
# each network.
|
67
|
-
#
|
68
|
-
# @param args [Array] variable arguments (unused but accepted for compatibility)
|
69
|
-
#
|
70
|
-
# @return [MCP::Tool::Response] comprehensive network information
|
71
|
-
#
|
72
|
-
# @example List all networks
|
73
|
-
# response = ListNetworks.call
|
74
|
-
# # Returns detailed info for all Docker networks
|
75
|
-
#
|
76
|
-
# @see Docker::Network.all
|
77
|
-
def self.call(*)
|
78
|
-
MCP::Tool::Response.new([{
|
79
|
-
type: 'text',
|
80
|
-
text: Docker::Network.all.map(&:info).to_s
|
81
|
-
}])
|
51
|
+
execute do
|
52
|
+
Docker::Network.all.map(&:info)
|
82
53
|
end
|
83
54
|
end
|
55
|
+
|
56
|
+
ListNetworks = LIST_NETWORKS_DEFINITION.to_mcp_tool
|
84
57
|
end
|
@@ -3,89 +3,55 @@
|
|
3
3
|
module DockerMCP
|
4
4
|
# MCP tool for listing Docker volumes.
|
5
5
|
#
|
6
|
-
# This tool provides
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# This tool provides comprehensive information about all Docker volumes
|
7
|
+
# configured on the system. It returns detailed volume metadata including
|
8
|
+
# mount points, drivers, usage statistics, and associated containers.
|
9
9
|
#
|
10
10
|
# == Features
|
11
11
|
#
|
12
|
-
# -
|
13
|
-
# -
|
14
|
-
# -
|
15
|
-
# -
|
16
|
-
# - Includes
|
12
|
+
# - Lists all Docker volumes (named and anonymous)
|
13
|
+
# - Provides detailed volume metadata
|
14
|
+
# - Shows mount points and storage locations
|
15
|
+
# - Displays driver information and options
|
16
|
+
# - Includes creation timestamps and labels
|
17
|
+
# - Reports volume scope and capabilities
|
17
18
|
#
|
18
|
-
# ==
|
19
|
-
#
|
20
|
-
# The response typically includes:
|
21
|
-
# - **Volume Name**: Unique identifier for the volume
|
22
|
-
# - **Driver**: Volume driver (local, nfs, etc.)
|
23
|
-
# - **Mountpoint**: Physical location on host filesystem
|
24
|
-
# - **Labels**: User-defined metadata labels
|
25
|
-
# - **Options**: Driver-specific configuration options
|
26
|
-
# - **Scope**: Volume scope (local, global)
|
27
|
-
# - **CreatedAt**: Volume creation timestamp
|
28
|
-
#
|
29
|
-
# == Volume Types
|
19
|
+
# == Security Considerations
|
30
20
|
#
|
31
|
-
#
|
32
|
-
# - **
|
33
|
-
# - **
|
34
|
-
# - **
|
35
|
-
# - **
|
21
|
+
# Volume information can reveal sensitive details about:
|
22
|
+
# - **Data Storage**: Persistent data locations and structures
|
23
|
+
# - **File System Access**: Mount points and storage paths
|
24
|
+
# - **Container Dependencies**: Volume usage patterns
|
25
|
+
# - **Data Persistence**: Backup and recovery points
|
36
26
|
#
|
37
|
-
#
|
27
|
+
# Monitor access to this tool and implement appropriate controls.
|
38
28
|
#
|
39
|
-
#
|
40
|
-
# - Exposes data storage architecture
|
41
|
-
# - Shows volume naming patterns
|
42
|
-
# - May reveal application data locations
|
43
|
-
# - Could aid in data discovery attacks
|
29
|
+
# == Return Format
|
44
30
|
#
|
45
|
-
#
|
46
|
-
# -
|
47
|
-
# -
|
48
|
-
# -
|
49
|
-
# -
|
31
|
+
# Returns an array of volume objects with comprehensive metadata:
|
32
|
+
# - Volume names and mount points
|
33
|
+
# - Driver types and configurations
|
34
|
+
# - Creation timestamps
|
35
|
+
# - Labels and options
|
36
|
+
# - Scope information
|
37
|
+
# - Storage usage details
|
50
38
|
#
|
51
39
|
# == Example Usage
|
52
40
|
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
# # Get available volumes before container creation
|
58
|
-
# volumes_response = ListVolumes.call(server_context: context)
|
59
|
-
# # Use volume information to select appropriate storage
|
41
|
+
# volumes = ListVolumes.call(server_context: context)
|
42
|
+
# volumes.each do |volume|
|
43
|
+
# puts "#{volume['Name']}: #{volume['Mountpoint']}"
|
44
|
+
# end
|
60
45
|
#
|
61
|
-
# @see CreateVolume
|
62
|
-
# @see RemoveVolume
|
63
46
|
# @see Docker::Volume.all
|
64
47
|
# @since 0.1.0
|
65
|
-
|
48
|
+
LIST_VOLUMES_DEFINITION = ToolForge.define(:list_volumes) do
|
66
49
|
description 'List Docker volumes'
|
67
50
|
|
68
|
-
|
69
|
-
|
70
|
-
# This method retrieves information about all Docker volumes, including
|
71
|
-
# both named volumes created by users and anonymous volumes created
|
72
|
-
# automatically by containers. The information includes comprehensive
|
73
|
-
# metadata for each volume.
|
74
|
-
#
|
75
|
-
# @param args [Array] variable arguments (unused but accepted for compatibility)
|
76
|
-
#
|
77
|
-
# @return [MCP::Tool::Response] comprehensive volume information
|
78
|
-
#
|
79
|
-
# @example List all volumes
|
80
|
-
# response = ListVolumes.call
|
81
|
-
# # Returns detailed info for all Docker volumes
|
82
|
-
#
|
83
|
-
# @see Docker::Volume.all
|
84
|
-
def self.call(*)
|
85
|
-
MCP::Tool::Response.new([{
|
86
|
-
type: 'text',
|
87
|
-
text: Docker::Volume.all.map(&:info).to_s
|
88
|
-
}])
|
51
|
+
execute do
|
52
|
+
Docker::Volume.all.map(&:info)
|
89
53
|
end
|
90
54
|
end
|
55
|
+
|
56
|
+
ListVolumes = LIST_VOLUMES_DEFINITION.to_mcp_tool
|
91
57
|
end
|
@@ -25,7 +25,7 @@ module DockerMCP
|
|
25
25
|
# - **Supply Chain Attacks**: Legitimate-looking images may be malicious
|
26
26
|
# - **Resource Consumption**: Large images can consume significant disk space
|
27
27
|
#
|
28
|
-
# Security
|
28
|
+
# **Security Recommendations**:
|
29
29
|
# - Only pull images from trusted registries and publishers
|
30
30
|
# - Verify image signatures when available
|
31
31
|
# - Scan pulled images for vulnerabilities
|
@@ -41,78 +41,41 @@ module DockerMCP
|
|
41
41
|
# - If no tag specified, default to "latest"
|
42
42
|
# - Supports all Docker tag conventions
|
43
43
|
#
|
44
|
+
# == Parameters
|
45
|
+
#
|
46
|
+
# - **from_image**: Image name to pull (required, e.g., "ubuntu" or "ubuntu:22.04")
|
47
|
+
# - **tag**: Tag to pull (optional, defaults to "latest" if not specified in from_image)
|
48
|
+
#
|
44
49
|
# == Example Usage
|
45
50
|
#
|
46
51
|
# # Pull latest version
|
47
|
-
# PullImage.call(
|
52
|
+
# response = PullImage.call(
|
48
53
|
# server_context: context,
|
49
54
|
# from_image: "nginx"
|
50
55
|
# )
|
51
56
|
#
|
52
57
|
# # Pull specific version
|
53
|
-
# PullImage.call(
|
58
|
+
# response = PullImage.call(
|
54
59
|
# server_context: context,
|
55
|
-
# from_image: "postgres
|
60
|
+
# from_image: "postgres",
|
61
|
+
# tag: "13.8"
|
56
62
|
# )
|
57
63
|
#
|
58
|
-
# # Pull with separate tag parameter
|
59
|
-
# PullImage.call(
|
60
|
-
# server_context: context,
|
61
|
-
# from_image: "redis",
|
62
|
-
# tag: "7-alpine"
|
63
|
-
# )
|
64
|
-
#
|
65
|
-
# @see BuildImage
|
66
|
-
# @see ListImages
|
67
64
|
# @see Docker::Image.create
|
68
65
|
# @since 0.1.0
|
69
|
-
|
66
|
+
PULL_IMAGE_DEFINITION = ToolForge.define(:pull_image) do
|
70
67
|
description 'Pull a Docker image'
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
from_image: {
|
75
|
-
type: 'string',
|
69
|
+
param :from_image,
|
70
|
+
type: :string,
|
76
71
|
description: 'Image name to pull (e.g., "ubuntu" or "ubuntu:22.04")'
|
77
|
-
},
|
78
|
-
tag: {
|
79
|
-
type: 'string',
|
80
|
-
description: 'Tag to pull (optional, defaults to "latest" if not specified in from_image)'
|
81
|
-
}
|
82
|
-
},
|
83
|
-
required: ['from_image']
|
84
|
-
)
|
85
72
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
# @param from_image [String] image name (may include registry and tag)
|
93
|
-
# @param server_context [Object] MCP server context (unused but required)
|
94
|
-
# @param tag [String, nil] specific tag to pull (overrides tag in from_image)
|
95
|
-
#
|
96
|
-
# @return [MCP::Tool::Response] pull operation results with image ID
|
97
|
-
#
|
98
|
-
# @raise [Docker::Error::NotFoundError] if image doesn't exist in registry
|
99
|
-
# @raise [StandardError] for network or authentication failures
|
100
|
-
#
|
101
|
-
# @example Pull official image
|
102
|
-
# response = PullImage.call(
|
103
|
-
# server_context: context,
|
104
|
-
# from_image: "ubuntu:22.04"
|
105
|
-
# )
|
106
|
-
#
|
107
|
-
# @example Pull from custom registry
|
108
|
-
# response = PullImage.call(
|
109
|
-
# server_context: context,
|
110
|
-
# from_image: "registry.example.com/myapp",
|
111
|
-
# tag: "v1.0"
|
112
|
-
# )
|
113
|
-
#
|
114
|
-
# @see Docker::Image.create
|
115
|
-
def self.call(from_image:, server_context:, tag: nil)
|
73
|
+
param :tag,
|
74
|
+
type: :string,
|
75
|
+
description: 'Tag to pull (optional, defaults to "latest" if not specified in from_image)',
|
76
|
+
required: false
|
77
|
+
|
78
|
+
execute do |from_image:, tag: nil|
|
116
79
|
# If tag is provided separately, append it to from_image
|
117
80
|
# If from_image already has a tag (contains :), use as-is
|
118
81
|
# Otherwise default to :latest
|
@@ -126,20 +89,13 @@ module DockerMCP
|
|
126
89
|
|
127
90
|
image = Docker::Image.create('fromImage' => image_with_tag)
|
128
91
|
|
129
|
-
|
130
|
-
type: 'text',
|
131
|
-
text: "Image #{image_with_tag} pulled successfully. ID: #{image.id}"
|
132
|
-
}])
|
92
|
+
"Image #{image_with_tag} pulled successfully. ID: #{image.id}"
|
133
93
|
rescue Docker::Error::NotFoundError
|
134
|
-
|
135
|
-
type: 'text',
|
136
|
-
text: "Image #{image_with_tag} not found"
|
137
|
-
}])
|
94
|
+
"Image #{image_with_tag} not found"
|
138
95
|
rescue StandardError => e
|
139
|
-
|
140
|
-
type: 'text',
|
141
|
-
text: "Error pulling image: #{e.message}"
|
142
|
-
}])
|
96
|
+
"Error pulling image: #{e.message}"
|
143
97
|
end
|
144
98
|
end
|
99
|
+
|
100
|
+
PullImage = PULL_IMAGE_DEFINITION.to_mcp_tool
|
145
101
|
end
|