Skip to main content
Glama

Docker Volume Management

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}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only lists actions without behavioral details. It doesn't disclose permissions needed, whether operations are destructive, what happens during 'prune' (mentioned in schema but not description), or error conditions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise single sentence with zero wasted words. Every word earns its place by specifying the resource (Docker volumes) and available actions in a clear, front-loaded manner.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a multi-action mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'prune' does (though in schema), doesn't describe return values, and provides minimal behavioral context for operations that could be destructive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description doesn't add meaningful parameter semantics beyond what's in the schema, maintaining the baseline score for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as managing Docker volumes with specific actions (list, create, remove, inspect). It distinguishes from siblings by focusing on volumes rather than containers, images, or networks, but doesn't explicitly differentiate from all volume-related alternatives.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. While it's clear this is for volume management, there's no mention of when to choose this over other Docker tools or when specific actions are appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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