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,162 +3,96 @@
|
|
3
3
|
module DockerMCP
|
4
4
|
# MCP tool for removing Docker images.
|
5
5
|
#
|
6
|
-
# This tool provides the ability to
|
7
|
-
#
|
8
|
-
#
|
9
|
-
# handling.
|
6
|
+
# This tool provides the ability to delete Docker images from the
|
7
|
+
# local Docker daemon. It supports various removal options including
|
8
|
+
# forced removal and parent image cleanup management.
|
10
9
|
#
|
11
10
|
# == Features
|
12
11
|
#
|
13
|
-
# - Remove images by ID, name, or
|
12
|
+
# - Remove images by ID, name, or tag
|
14
13
|
# - Force removal of images in use
|
15
|
-
# - Control parent image cleanup
|
14
|
+
# - Control untagged parent image cleanup
|
16
15
|
# - Comprehensive error handling
|
16
|
+
# - Validation of image existence
|
17
17
|
# - Safe removal with dependency checking
|
18
18
|
#
|
19
|
-
# == ⚠️ Data Loss Warning ⚠️
|
20
|
-
#
|
21
|
-
# **DESTRUCTIVE OPERATION - PERMANENT DATA LOSS**
|
22
|
-
#
|
23
|
-
# This operation permanently deletes images and associated data:
|
24
|
-
# - Image layers are deleted from disk
|
25
|
-
# - All tags pointing to the image are removed
|
26
|
-
# - Operation cannot be undone
|
27
|
-
# - Dependent containers may become unusable
|
28
|
-
# - Custom modifications to images are lost
|
29
|
-
#
|
30
|
-
# == Dependency Management
|
31
|
-
#
|
32
|
-
# Docker images have complex dependency relationships:
|
33
|
-
# - **Child Images**: Images built FROM this image
|
34
|
-
# - **Parent Images**: Base images this image depends on
|
35
|
-
# - **Running Containers**: Containers using this image
|
36
|
-
# - **Stopped Containers**: Containers that could be restarted
|
37
|
-
#
|
38
19
|
# == Security Considerations
|
39
20
|
#
|
40
|
-
# Image removal
|
41
|
-
# -
|
42
|
-
# -
|
43
|
-
# -
|
44
|
-
# -
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
21
|
+
# Image removal involves important considerations:
|
22
|
+
# - **Data Loss**: Removed images cannot be recovered locally
|
23
|
+
# - **Service Disruption**: Removing images used by running containers
|
24
|
+
# - **Storage Cleanup**: Improper cleanup can leave orphaned layers
|
25
|
+
# - **Registry Impact**: Local removal doesn't affect registry copies
|
26
|
+
# - **Dependency Conflicts**: Force removal can break container dependencies
|
27
|
+
#
|
28
|
+
# **Security Recommendations**:
|
29
|
+
# - Verify image is not in use before removal
|
30
|
+
# - Use force option only when necessary
|
31
|
+
# - Consider impact on running containers
|
48
32
|
# - Backup important images before removal
|
49
|
-
# -
|
50
|
-
# -
|
51
|
-
# - Maintain image inventory documentation
|
33
|
+
# - Monitor disk space after removal operations
|
34
|
+
# - Implement image lifecycle policies
|
52
35
|
#
|
53
|
-
# ==
|
36
|
+
# == Parameters
|
54
37
|
#
|
55
|
-
# - **
|
56
|
-
# - **Force
|
57
|
-
# - **
|
58
|
-
# - **No Prune**: Keeps parent images even if unused
|
38
|
+
# - **id**: Image ID, name, or name:tag (required)
|
39
|
+
# - **force**: Force removal of the image (optional, default: false)
|
40
|
+
# - **noprune**: Do not delete untagged parents (optional, default: false)
|
59
41
|
#
|
60
42
|
# == Example Usage
|
61
43
|
#
|
62
|
-
# #
|
63
|
-
# RemoveImage.call(
|
44
|
+
# # Remove specific image
|
45
|
+
# response = RemoveImage.call(
|
64
46
|
# server_context: context,
|
65
|
-
# id: "old-
|
47
|
+
# id: "myapp:old-version"
|
66
48
|
# )
|
67
49
|
#
|
68
|
-
# # Force
|
69
|
-
# RemoveImage.call(
|
50
|
+
# # Force remove image in use
|
51
|
+
# response = RemoveImage.call(
|
70
52
|
# server_context: context,
|
71
|
-
# id: "
|
53
|
+
# id: "abc123def456",
|
72
54
|
# force: true
|
73
55
|
# )
|
74
56
|
#
|
75
|
-
# # Remove
|
76
|
-
# RemoveImage.call(
|
57
|
+
# # Remove without cleaning parent images
|
58
|
+
# response = RemoveImage.call(
|
77
59
|
# server_context: context,
|
78
|
-
# id: "
|
60
|
+
# id: "test-image:latest",
|
79
61
|
# noprune: true
|
80
62
|
# )
|
81
63
|
#
|
82
|
-
# @see ListImages
|
83
|
-
# @see BuildImage
|
84
64
|
# @see Docker::Image#remove
|
85
65
|
# @since 0.1.0
|
86
|
-
|
66
|
+
REMOVE_IMAGE_DEFINITION = ToolForge.define(:remove_image) do
|
87
67
|
description 'Remove a Docker image'
|
88
68
|
|
89
|
-
|
90
|
-
|
91
|
-
id: {
|
92
|
-
type: 'string',
|
69
|
+
param :id,
|
70
|
+
type: :string,
|
93
71
|
description: 'Image ID, name, or name:tag'
|
94
|
-
},
|
95
|
-
force: {
|
96
|
-
type: 'boolean',
|
97
|
-
description: 'Force removal of the image (default: false)'
|
98
|
-
},
|
99
|
-
noprune: {
|
100
|
-
type: 'boolean',
|
101
|
-
description: 'Do not delete untagged parents (default: false)'
|
102
|
-
}
|
103
|
-
},
|
104
|
-
required: ['id']
|
105
|
-
)
|
106
72
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
# @raise [Docker::Error::NotFoundError] if image doesn't exist
|
121
|
-
# @raise [StandardError] for removal failures or dependency conflicts
|
122
|
-
#
|
123
|
-
# @example Remove unused image
|
124
|
-
# response = RemoveImage.call(
|
125
|
-
# server_context: context,
|
126
|
-
# id: "old-version:1.0"
|
127
|
-
# )
|
128
|
-
#
|
129
|
-
# @example Force remove problematic image
|
130
|
-
# response = RemoveImage.call(
|
131
|
-
# server_context: context,
|
132
|
-
# id: "corrupted-image",
|
133
|
-
# force: true
|
134
|
-
# )
|
135
|
-
#
|
136
|
-
# @example Remove while preserving layers
|
137
|
-
# response = RemoveImage.call(
|
138
|
-
# server_context: context,
|
139
|
-
# id: "temp-image:build-123",
|
140
|
-
# noprune: true
|
141
|
-
# )
|
142
|
-
#
|
143
|
-
# @see Docker::Image#remove
|
144
|
-
def self.call(id:, server_context:, force: false, noprune: false)
|
73
|
+
param :force,
|
74
|
+
type: :boolean,
|
75
|
+
description: 'Force removal of the image (default: false)',
|
76
|
+
required: false,
|
77
|
+
default: false
|
78
|
+
|
79
|
+
param :noprune,
|
80
|
+
type: :boolean,
|
81
|
+
description: 'Do not delete untagged parents (default: false)',
|
82
|
+
required: false,
|
83
|
+
default: false
|
84
|
+
|
85
|
+
execute do |id:, force: false, noprune: false|
|
145
86
|
image = Docker::Image.get(id)
|
146
87
|
image.remove(force: force, noprune: noprune)
|
147
88
|
|
148
|
-
|
149
|
-
type: 'text',
|
150
|
-
text: "Image #{id} removed successfully"
|
151
|
-
}])
|
89
|
+
"Image #{id} removed successfully"
|
152
90
|
rescue Docker::Error::NotFoundError
|
153
|
-
|
154
|
-
type: 'text',
|
155
|
-
text: "Image #{id} not found"
|
156
|
-
}])
|
91
|
+
"Image #{id} not found"
|
157
92
|
rescue StandardError => e
|
158
|
-
|
159
|
-
type: 'text',
|
160
|
-
text: "Error removing image: #{e.message}"
|
161
|
-
}])
|
93
|
+
"Error removing image: #{e.message}"
|
162
94
|
end
|
163
95
|
end
|
96
|
+
|
97
|
+
RemoveImage = REMOVE_IMAGE_DEFINITION.to_mcp_tool
|
164
98
|
end
|
@@ -3,134 +3,80 @@
|
|
3
3
|
module DockerMCP
|
4
4
|
# MCP tool for removing Docker networks.
|
5
5
|
#
|
6
|
-
# This tool provides the ability to
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# This tool provides the ability to delete Docker networks when they
|
7
|
+
# are no longer needed. Network removal helps maintain clean network
|
8
|
+
# configurations and prevents resource leaks.
|
9
9
|
#
|
10
10
|
# == Features
|
11
11
|
#
|
12
|
-
# - Remove
|
13
|
-
# -
|
12
|
+
# - Remove networks by ID or name
|
13
|
+
# - Validation of network existence
|
14
14
|
# - Comprehensive error handling
|
15
|
-
# -
|
15
|
+
# - Prevention of removing networks in use
|
16
16
|
# - Safe cleanup of network resources
|
17
|
-
#
|
18
|
-
# == ⚠️ Service Disruption Warning ⚠️
|
19
|
-
#
|
20
|
-
# **NETWORK REMOVAL CAN DISRUPT SERVICES**
|
21
|
-
#
|
22
|
-
# Removing networks can cause immediate service disruption:
|
23
|
-
# - Connected containers lose network connectivity
|
24
|
-
# - Inter-container communication is broken
|
25
|
-
# - Services may become unreachable
|
26
|
-
# - Application functionality can be severely impacted
|
27
|
-
# - Network-dependent processes may fail
|
28
|
-
#
|
29
|
-
# == Protected Networks
|
30
|
-
#
|
31
|
-
# Docker protects certain built-in networks from removal:
|
32
|
-
# - **bridge**: Default bridge network
|
33
|
-
# - **host**: Host networking
|
34
|
-
# - **none**: No networking
|
35
|
-
# - **System networks**: Docker-managed networks
|
17
|
+
# - Network dependency checking
|
36
18
|
#
|
37
19
|
# == Security Considerations
|
38
20
|
#
|
39
|
-
# Network removal
|
40
|
-
# -
|
41
|
-
# -
|
42
|
-
# -
|
43
|
-
# -
|
21
|
+
# Network removal involves important considerations:
|
22
|
+
# - **Service Disruption**: Removing active networks disconnects containers
|
23
|
+
# - **Data Isolation**: Network removal can affect container communication
|
24
|
+
# - **Resource Cleanup**: Improper removal can leave network artifacts
|
25
|
+
# - **Container Dependencies**: Containers may fail without expected networks
|
26
|
+
# - **Network Policies**: Removal affects security and access policies
|
44
27
|
#
|
45
|
-
# Security
|
46
|
-
# -
|
47
|
-
# -
|
48
|
-
# -
|
49
|
-
# -
|
28
|
+
# **Security Recommendations**:
|
29
|
+
# - Verify no containers are connected before removal
|
30
|
+
# - Check for dependent services and applications
|
31
|
+
# - Document network removal in change logs
|
32
|
+
# - Implement network lifecycle management
|
33
|
+
# - Monitor for orphaned network resources
|
34
|
+
# - Use network removal as part of cleanup procedures
|
50
35
|
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# -
|
54
|
-
# - Have rollback plans for critical networks
|
55
|
-
# - Document network removal procedures
|
56
|
-
# - Monitor network connectivity after removal
|
36
|
+
# == Parameters
|
37
|
+
#
|
38
|
+
# - **id**: Network ID or name (required)
|
57
39
|
#
|
58
40
|
# == Example Usage
|
59
41
|
#
|
60
|
-
# # Remove
|
61
|
-
# RemoveNetwork.call(
|
42
|
+
# # Remove network by name
|
43
|
+
# response = RemoveNetwork.call(
|
62
44
|
# server_context: context,
|
63
45
|
# id: "app-network"
|
64
46
|
# )
|
65
47
|
#
|
66
|
-
# # Remove by
|
67
|
-
# RemoveNetwork.call(
|
48
|
+
# # Remove network by ID
|
49
|
+
# response = RemoveNetwork.call(
|
68
50
|
# server_context: context,
|
69
51
|
# id: "abc123def456"
|
70
52
|
# )
|
71
53
|
#
|
72
|
-
#
|
73
|
-
#
|
54
|
+
# # Clean up test networks
|
55
|
+
# response = RemoveNetwork.call(
|
56
|
+
# server_context: context,
|
57
|
+
# id: "test-isolated-network"
|
58
|
+
# )
|
59
|
+
#
|
74
60
|
# @see Docker::Network#delete
|
75
61
|
# @since 0.1.0
|
76
|
-
|
62
|
+
REMOVE_NETWORK_DEFINITION = ToolForge.define(:remove_network) do
|
77
63
|
description 'Remove a Docker network'
|
78
64
|
|
79
|
-
|
80
|
-
|
81
|
-
id: {
|
82
|
-
type: 'string',
|
65
|
+
param :id,
|
66
|
+
type: :string,
|
83
67
|
description: 'Network ID or name'
|
84
|
-
}
|
85
|
-
},
|
86
|
-
required: ['id']
|
87
|
-
)
|
88
68
|
|
89
|
-
|
90
|
-
#
|
91
|
-
# This method permanently deletes the specified network. The network
|
92
|
-
# must not have any containers connected to it, and built-in system
|
93
|
-
# networks cannot be removed.
|
94
|
-
#
|
95
|
-
# @param id [String] network ID or name to remove
|
96
|
-
# @param server_context [Object] MCP server context (unused but required)
|
97
|
-
#
|
98
|
-
# @return [MCP::Tool::Response] removal operation results
|
99
|
-
#
|
100
|
-
# @raise [Docker::Error::NotFoundError] if network doesn't exist
|
101
|
-
# @raise [StandardError] for removal failures or dependency conflicts
|
102
|
-
#
|
103
|
-
# @example Remove custom network
|
104
|
-
# response = RemoveNetwork.call(
|
105
|
-
# server_context: context,
|
106
|
-
# id: "frontend-network"
|
107
|
-
# )
|
108
|
-
#
|
109
|
-
# @example Remove by ID
|
110
|
-
# response = RemoveNetwork.call(
|
111
|
-
# server_context: context,
|
112
|
-
# id: "1a2b3c4d5e6f"
|
113
|
-
# )
|
114
|
-
#
|
115
|
-
# @see Docker::Network#delete
|
116
|
-
def self.call(id:, server_context:)
|
69
|
+
execute do |id:|
|
117
70
|
network = Docker::Network.get(id)
|
118
71
|
network.delete
|
119
72
|
|
120
|
-
|
121
|
-
type: 'text',
|
122
|
-
text: "Network #{id} removed successfully"
|
123
|
-
}])
|
73
|
+
"Network #{id} removed successfully"
|
124
74
|
rescue Docker::Error::NotFoundError
|
125
|
-
|
126
|
-
type: 'text',
|
127
|
-
text: "Network #{id} not found"
|
128
|
-
}])
|
75
|
+
"Network #{id} not found"
|
129
76
|
rescue StandardError => e
|
130
|
-
|
131
|
-
type: 'text',
|
132
|
-
text: "Error removing network: #{e.message}"
|
133
|
-
}])
|
77
|
+
"Error removing network: #{e.message}"
|
134
78
|
end
|
135
79
|
end
|
80
|
+
|
81
|
+
RemoveNetwork = REMOVE_NETWORK_DEFINITION.to_mcp_tool
|
136
82
|
end
|
@@ -3,144 +3,90 @@
|
|
3
3
|
module DockerMCP
|
4
4
|
# MCP tool for removing Docker volumes.
|
5
5
|
#
|
6
|
-
# This tool provides the ability to
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# This tool provides the ability to delete Docker volumes when they
|
7
|
+
# are no longer needed. Volume removal is critical for preventing
|
8
|
+
# storage leaks and maintaining clean Docker environments.
|
9
9
|
#
|
10
10
|
# == Features
|
11
11
|
#
|
12
|
-
# - Remove
|
13
|
-
# - Force removal
|
12
|
+
# - Remove volumes by name
|
13
|
+
# - Force removal of volumes in use
|
14
|
+
# - Validation of volume existence
|
14
15
|
# - Comprehensive error handling
|
15
|
-
# -
|
16
|
-
# -
|
17
|
-
#
|
18
|
-
# == ⚠️ CRITICAL DATA LOSS WARNING ⚠️
|
19
|
-
#
|
20
|
-
# **DESTRUCTIVE OPERATION - PERMANENT DATA LOSS**
|
21
|
-
#
|
22
|
-
# This operation permanently and irreversibly deletes data:
|
23
|
-
# - **ALL DATA** in the volume is deleted forever
|
24
|
-
# - No recovery possible after deletion
|
25
|
-
# - Applications may lose critical data
|
26
|
-
# - Databases and persistent state are destroyed
|
27
|
-
# - Configuration files and user data are lost
|
28
|
-
# - Operation cannot be undone
|
29
|
-
#
|
30
|
-
# == Volume Dependencies
|
31
|
-
#
|
32
|
-
# Volumes may have active dependencies:
|
33
|
-
# - **Running Containers**: Containers currently using the volume
|
34
|
-
# - **Stopped Containers**: Containers that could be restarted
|
35
|
-
# - **Application Data**: Critical application state and databases
|
36
|
-
# - **User Data**: User-generated content and files
|
16
|
+
# - Safe volume cleanup procedures
|
17
|
+
# - Prevention of accidental data loss
|
37
18
|
#
|
38
19
|
# == Security Considerations
|
39
20
|
#
|
40
|
-
# Volume removal
|
41
|
-
# -
|
42
|
-
# -
|
43
|
-
# -
|
44
|
-
# -
|
21
|
+
# Volume removal involves critical data considerations:
|
22
|
+
# - **Data Loss**: Removed volumes and their data are permanently deleted
|
23
|
+
# - **Service Disruption**: Removing volumes can break running containers
|
24
|
+
# - **Data Recovery**: Volume data cannot be recovered after removal
|
25
|
+
# - **Container Dependencies**: Applications may fail without expected volumes
|
26
|
+
# - **Storage Cleanup**: Improper removal can leave orphaned data
|
27
|
+
# - **Backup Requirements**: Critical data should be backed up before removal
|
45
28
|
#
|
46
|
-
#
|
47
|
-
# -
|
48
|
-
# - Verify no containers
|
49
|
-
# -
|
50
|
-
# -
|
51
|
-
# -
|
29
|
+
# **Security Recommendations**:
|
30
|
+
# - Always backup critical data before volume removal
|
31
|
+
# - Verify no containers are using the volume
|
32
|
+
# - Use force option only when absolutely necessary
|
33
|
+
# - Document volume removal in change management
|
34
|
+
# - Implement volume lifecycle and retention policies
|
35
|
+
# - Monitor storage usage after volume removal
|
36
|
+
# - Consider data migration instead of removal
|
52
37
|
#
|
53
|
-
# ==
|
38
|
+
# == Parameters
|
54
39
|
#
|
55
|
-
#
|
56
|
-
# -
|
57
|
-
# - Can cause immediate application failures
|
58
|
-
# - May corrupt running applications
|
59
|
-
# - Data loss occurs immediately
|
40
|
+
# - **name**: Volume name (required)
|
41
|
+
# - **force**: Force removal of the volume (optional, default: false)
|
60
42
|
#
|
61
43
|
# == Example Usage
|
62
44
|
#
|
63
|
-
# #
|
64
|
-
# RemoveVolume.call(
|
45
|
+
# # Remove unused volume
|
46
|
+
# response = RemoveVolume.call(
|
65
47
|
# server_context: context,
|
66
|
-
# name: "
|
48
|
+
# name: "old-app-data"
|
67
49
|
# )
|
68
50
|
#
|
69
|
-
# # Force
|
70
|
-
# RemoveVolume.call(
|
51
|
+
# # Force remove volume in use
|
52
|
+
# response = RemoveVolume.call(
|
71
53
|
# server_context: context,
|
72
54
|
# name: "stuck-volume",
|
73
55
|
# force: true
|
74
56
|
# )
|
75
57
|
#
|
76
|
-
#
|
77
|
-
#
|
58
|
+
# # Clean up test volumes
|
59
|
+
# response = RemoveVolume.call(
|
60
|
+
# server_context: context,
|
61
|
+
# name: "test-data-volume"
|
62
|
+
# )
|
63
|
+
#
|
78
64
|
# @see Docker::Volume#remove
|
79
65
|
# @since 0.1.0
|
80
|
-
|
66
|
+
REMOVE_VOLUME_DEFINITION = ToolForge.define(:remove_volume) do
|
81
67
|
description 'Remove a Docker volume'
|
82
68
|
|
83
|
-
|
84
|
-
|
85
|
-
name: {
|
86
|
-
type: 'string',
|
69
|
+
param :name,
|
70
|
+
type: :string,
|
87
71
|
description: 'Volume name'
|
88
|
-
},
|
89
|
-
force: {
|
90
|
-
type: 'boolean',
|
91
|
-
description: 'Force removal of the volume (default: false)'
|
92
|
-
}
|
93
|
-
},
|
94
|
-
required: ['name']
|
95
|
-
)
|
96
72
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
# @param server_context [Object] MCP server context (unused but required)
|
105
|
-
# @param force [Boolean] whether to force removal despite dependencies (default: false)
|
106
|
-
#
|
107
|
-
# @return [MCP::Tool::Response] removal operation results
|
108
|
-
#
|
109
|
-
# @raise [Docker::Error::NotFoundError] if volume doesn't exist
|
110
|
-
# @raise [StandardError] for removal failures or dependency conflicts
|
111
|
-
#
|
112
|
-
# @example Remove unused volume
|
113
|
-
# response = RemoveVolume.call(
|
114
|
-
# server_context: context,
|
115
|
-
# name: "old-cache-data"
|
116
|
-
# )
|
117
|
-
#
|
118
|
-
# @example Force remove problematic volume
|
119
|
-
# response = RemoveVolume.call(
|
120
|
-
# server_context: context,
|
121
|
-
# name: "corrupted-volume",
|
122
|
-
# force: true
|
123
|
-
# )
|
124
|
-
#
|
125
|
-
# @see Docker::Volume#remove
|
126
|
-
def self.call(name:, server_context:, force: false)
|
73
|
+
param :force,
|
74
|
+
type: :boolean,
|
75
|
+
description: 'Force removal of the volume (default: false)',
|
76
|
+
required: false,
|
77
|
+
default: false
|
78
|
+
|
79
|
+
execute do |name:, force: false|
|
127
80
|
volume = Docker::Volume.get(name)
|
128
81
|
volume.remove(force: force)
|
129
82
|
|
130
|
-
|
131
|
-
type: 'text',
|
132
|
-
text: "Volume #{name} removed successfully"
|
133
|
-
}])
|
83
|
+
"Volume #{name} removed successfully"
|
134
84
|
rescue Docker::Error::NotFoundError
|
135
|
-
|
136
|
-
type: 'text',
|
137
|
-
text: "Volume #{name} not found"
|
138
|
-
}])
|
85
|
+
"Volume #{name} not found"
|
139
86
|
rescue StandardError => e
|
140
|
-
|
141
|
-
type: 'text',
|
142
|
-
text: "Error removing volume: #{e.message}"
|
143
|
-
}])
|
87
|
+
"Error removing volume: #{e.message}"
|
144
88
|
end
|
145
89
|
end
|
90
|
+
|
91
|
+
RemoveVolume = REMOVE_VOLUME_DEFINITION.to_mcp_tool
|
146
92
|
end
|