Skip to main content
Glama

manage_volumes

Manage Docker volumes by listing, creating, removing, inspecting, or pruning them to organize storage for containers.

Instructions

Manage Docker volumes (list, create, remove, inspect)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform on volumes
volumeNoVolume name (required for create, remove, inspect)
driverNoVolume driver (optional for create)

Implementation Reference

  • The main handler function for the 'manage_volumes' tool. It takes action, volume, and driver parameters, constructs the corresponding Docker volume command (ls, create, rm, inspect, prune), executes it using executeDockerCommand, and returns formatted text output or error response.
    try { let command: string; switch (action) { case "list": command = "docker volume ls"; break; case "create": if (!volume) throw new Error("Volume name is required for create action"); command = `docker volume create${driver ? ` --driver ${driver}` : ""} ${volume}`; break; case "remove": if (!volume) throw new Error("Volume name is required for remove action"); command = `docker volume rm ${volume}`; break; case "inspect": if (!volume) throw new Error("Volume name is required for inspect action"); command = `docker volume inspect ${volume}`; break; case "prune": command = "docker volume prune -f"; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Volume ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error managing volumes: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
  • Input schema for the manage_volumes tool defined using Zod. Specifies the action enum and optional volume name and driver parameters with descriptions.
    action: z.enum(["list", "create", "remove", "inspect", "prune"]).describe("Action to perform on volumes"), volume: z.string().optional().describe("Volume name (required for create, remove, inspect)"), driver: z.string().optional().describe("Volume driver (optional for create)") } },
  • src/index.ts:1375-1433 (registration)
    Registration of the 'manage_volumes' MCP tool using server.registerTool, including title, description, input schema, and inline handler function.
    "manage_volumes", { title: "Docker Volume Management", description: "Manage Docker volumes (list, create, remove, inspect)", inputSchema: { action: z.enum(["list", "create", "remove", "inspect", "prune"]).describe("Action to perform on volumes"), volume: z.string().optional().describe("Volume name (required for create, remove, inspect)"), driver: z.string().optional().describe("Volume driver (optional for create)") } }, async ({ action, volume, driver }) => { try { let command: string; switch (action) { case "list": command = "docker volume ls"; break; case "create": if (!volume) throw new Error("Volume name is required for create action"); command = `docker volume create${driver ? ` --driver ${driver}` : ""} ${volume}`; break; case "remove": if (!volume) throw new Error("Volume name is required for remove action"); command = `docker volume rm ${volume}`; break; case "inspect": if (!volume) throw new Error("Volume name is required for inspect action"); command = `docker volume inspect ${volume}`; break; case "prune": command = "docker volume prune -f"; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Volume ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error managing volumes: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
  • Helper function executeDockerCommand used by the manage_volumes handler (and other tools) to run Docker commands asynchronously via child_process.exec.
    async function executeDockerCommand(command: string): Promise<{ stdout: string; stderr: string }> { try { const result = await execAsync(command); return result; } catch (error: any) { throw new Error(`Docker command failed: ${error.message}`); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TauqeerAhmad5201/docker-mcp-extension'

If you have feedback or need assistance with the MCP directory API, please join our Discord server