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
data/lib/docker_mcp/tag_image.rb
CHANGED
@@ -3,161 +3,107 @@
|
|
3
3
|
module DockerMCP
|
4
4
|
# MCP tool for tagging Docker images.
|
5
5
|
#
|
6
|
-
# This tool provides the ability to
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# This tool provides the ability to assign repository names and tags
|
7
|
+
# to Docker images. Tagging is essential for image organization,
|
8
|
+
# versioning, and distribution through Docker registries.
|
9
9
|
#
|
10
10
|
# == Features
|
11
11
|
#
|
12
|
-
# - Tag images
|
13
|
-
# - Support for
|
12
|
+
# - Tag existing images with custom repository names
|
13
|
+
# - Support for version and environment tags
|
14
14
|
# - Force tagging to overwrite existing tags
|
15
|
-
# - Registry-compatible
|
16
|
-
# -
|
17
|
-
# -
|
18
|
-
#
|
19
|
-
# == Tag Management Benefits
|
20
|
-
#
|
21
|
-
# Proper tagging enables:
|
22
|
-
# - **Version Control**: Track different image versions
|
23
|
-
# - **Distribution**: Prepare images for registry push
|
24
|
-
# - **Organization**: Group related images logically
|
25
|
-
# - **Deployment**: Reference specific image versions
|
26
|
-
# - **Rollback**: Maintain previous versions for rollback
|
15
|
+
# - Registry-compatible naming conventions
|
16
|
+
# - Automatic tag defaulting to "latest"
|
17
|
+
# - Comprehensive error handling and validation
|
27
18
|
#
|
28
19
|
# == Security Considerations
|
29
20
|
#
|
30
|
-
#
|
31
|
-
# - Tags
|
32
|
-
# - Overwriting tags can affect
|
33
|
-
# -
|
34
|
-
# -
|
21
|
+
# Image tagging involves several security considerations:
|
22
|
+
# - **Registry Authentication**: Tags may trigger registry operations
|
23
|
+
# - **Namespace Conflicts**: Overwriting tags can affect other deployments
|
24
|
+
# - **Image Identity**: Improper tagging can lead to deployment confusion
|
25
|
+
# - **Version Management**: Incorrect tags can compromise CI/CD pipelines
|
26
|
+
# - **Registry Pollution**: Excessive tagging can clutter registries
|
35
27
|
#
|
36
|
-
#
|
37
|
-
# - Use
|
38
|
-
# -
|
39
|
-
# -
|
40
|
-
# -
|
41
|
-
# -
|
28
|
+
# **Security Recommendations**:
|
29
|
+
# - Use consistent naming conventions
|
30
|
+
# - Implement tag governance policies
|
31
|
+
# - Verify image identity before tagging
|
32
|
+
# - Avoid overwriting production tags
|
33
|
+
# - Use semantic versioning for releases
|
34
|
+
# - Monitor tag usage and lifecycle
|
42
35
|
#
|
43
|
-
# ==
|
36
|
+
# == Parameters
|
44
37
|
#
|
45
|
-
#
|
46
|
-
# - **
|
47
|
-
# - **
|
48
|
-
# - **
|
49
|
-
# - **Date Tags**: `2024-01-15`, `20240115`
|
50
|
-
# - **Commit Tags**: `sha-abc123def`
|
38
|
+
# - **id**: Image ID or current name:tag to tag (required)
|
39
|
+
# - **repo**: Repository name (required, e.g., "username/imagename" or "registry/username/imagename")
|
40
|
+
# - **tag**: Tag for the image (optional, default: "latest")
|
41
|
+
# - **force**: Force tag even if it already exists (optional, default: true)
|
51
42
|
#
|
52
43
|
# == Example Usage
|
53
44
|
#
|
54
|
-
# # Tag with version
|
55
|
-
# TagImage.call(
|
45
|
+
# # Tag image with version
|
46
|
+
# response = TagImage.call(
|
56
47
|
# server_context: context,
|
57
|
-
# id: "
|
58
|
-
# repo: "myapp",
|
59
|
-
# tag: "v1.
|
48
|
+
# id: "myapp:dev",
|
49
|
+
# repo: "myregistry/myapp",
|
50
|
+
# tag: "v1.2.3"
|
60
51
|
# )
|
61
52
|
#
|
62
|
-
# # Tag for
|
63
|
-
# TagImage.call(
|
53
|
+
# # Tag for production deployment
|
54
|
+
# response = TagImage.call(
|
64
55
|
# server_context: context,
|
65
|
-
# id: "
|
66
|
-
# repo: "
|
67
|
-
# tag: "
|
56
|
+
# id: "abc123def456",
|
57
|
+
# repo: "production/webapp",
|
58
|
+
# tag: "stable",
|
59
|
+
# force: false
|
68
60
|
# )
|
69
61
|
#
|
70
|
-
# # Tag
|
71
|
-
# TagImage.call(
|
62
|
+
# # Tag with registry prefix
|
63
|
+
# response = TagImage.call(
|
72
64
|
# server_context: context,
|
73
|
-
# id: "
|
74
|
-
# repo: "registry.company.com/team/
|
75
|
-
# tag: "
|
65
|
+
# id: "local-build:latest",
|
66
|
+
# repo: "registry.company.com/team/service",
|
67
|
+
# tag: "release-candidate"
|
76
68
|
# )
|
77
69
|
#
|
78
|
-
# @see BuildImage
|
79
|
-
# @see PushImage
|
80
70
|
# @see Docker::Image#tag
|
81
71
|
# @since 0.1.0
|
82
|
-
|
72
|
+
TAG_IMAGE_DEFINITION = ToolForge.define(:tag_image) do
|
83
73
|
description 'Tag a Docker image'
|
84
74
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
repo: {
|
92
|
-
type: 'string',
|
75
|
+
param :id,
|
76
|
+
type: :string,
|
77
|
+
description: 'Image ID or current name:tag to tag'
|
78
|
+
|
79
|
+
param :repo,
|
80
|
+
type: :string,
|
93
81
|
description: 'Repository name (e.g., "username/imagename" or "registry/username/imagename")'
|
94
|
-
},
|
95
|
-
tag: {
|
96
|
-
type: 'string',
|
97
|
-
description: 'Tag for the image (default: "latest")'
|
98
|
-
},
|
99
|
-
force: {
|
100
|
-
type: 'boolean',
|
101
|
-
description: 'Force tag even if it already exists (default: true)'
|
102
|
-
}
|
103
|
-
},
|
104
|
-
required: %w[id repo]
|
105
|
-
)
|
106
82
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
#
|
121
|
-
# @raise [Docker::Error::NotFoundError] if source image doesn't exist
|
122
|
-
# @raise [StandardError] for other tagging failures
|
123
|
-
#
|
124
|
-
# @example Tag for versioning
|
125
|
-
# response = TagImage.call(
|
126
|
-
# server_context: context,
|
127
|
-
# id: "my-app:latest",
|
128
|
-
# repo: "my-app",
|
129
|
-
# tag: "v1.2.3"
|
130
|
-
# )
|
131
|
-
#
|
132
|
-
# @example Tag for registry push
|
133
|
-
# response = TagImage.call(
|
134
|
-
# server_context: context,
|
135
|
-
# id: "abc123def456",
|
136
|
-
# repo: "myregistry.com/myuser/myapp",
|
137
|
-
# tag: "production",
|
138
|
-
# force: true
|
139
|
-
# )
|
140
|
-
#
|
141
|
-
# @see Docker::Image#tag
|
142
|
-
def self.call(id:, repo:, server_context:, tag: 'latest', force: true)
|
83
|
+
param :tag,
|
84
|
+
type: :string,
|
85
|
+
description: 'Tag for the image (default: "latest")',
|
86
|
+
required: false,
|
87
|
+
default: 'latest'
|
88
|
+
|
89
|
+
param :force,
|
90
|
+
type: :boolean,
|
91
|
+
description: 'Force tag even if it already exists (default: true)',
|
92
|
+
required: false,
|
93
|
+
default: true
|
94
|
+
|
95
|
+
execute do |id:, repo:, tag: 'latest', force: true|
|
143
96
|
image = Docker::Image.get(id)
|
144
97
|
|
145
98
|
image.tag('repo' => repo, 'tag' => tag, 'force' => force)
|
146
99
|
|
147
|
-
|
148
|
-
type: 'text',
|
149
|
-
text: "Image tagged successfully as #{repo}:#{tag}"
|
150
|
-
}])
|
100
|
+
"Image tagged successfully as #{repo}:#{tag}"
|
151
101
|
rescue Docker::Error::NotFoundError
|
152
|
-
|
153
|
-
type: 'text',
|
154
|
-
text: "Image #{id} not found"
|
155
|
-
}])
|
102
|
+
"Image #{id} not found"
|
156
103
|
rescue StandardError => e
|
157
|
-
|
158
|
-
type: 'text',
|
159
|
-
text: "Error tagging image: #{e.message}"
|
160
|
-
}])
|
104
|
+
"Error tagging image: #{e.message}"
|
161
105
|
end
|
162
106
|
end
|
107
|
+
|
108
|
+
TagImage = TAG_IMAGE_DEFINITION.to_mcp_tool
|
163
109
|
end
|
data/lib/docker_mcp/version.rb
CHANGED
data/lib/docker_mcp.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker_mcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron F Stanton
|
@@ -51,6 +51,20 @@ dependencies:
|
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: tool_forge
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
54
68
|
- !ruby/object:Gem::Dependency
|
55
69
|
name: zeitwerk
|
56
70
|
requirement: !ruby/object:Gem::Requirement
|