Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

docker_rm

Remove Docker containers by name or ID, with options to force removal of running containers and delete associated anonymous volumes.

Instructions

Remove one or more containers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containersYesContainer name(s) or ID(s) to remove
forceNoForce removal of running containers
volumesNoRemove anonymous volumes
cwdNoWorking directory

Implementation Reference

  • The core handler function for the 'docker_rm' tool. It processes input arguments, constructs the 'docker rm' command with optional flags, and executes it via the shared executeDockerCommand helper.
    export async function dockerRm(args: z.infer<typeof dockerRmSchema>): Promise<ToolResponse> {
      const containers = Array.isArray(args.containers) ? args.containers.join(' ') : args.containers;
      const forceFlag = args.force ? '-f' : '';
      const volumesFlag = args.volumes ? '-v' : '';
    
      return executeDockerCommand(`docker rm ${forceFlag} ${volumesFlag} ${containers}`.trim(), args.cwd);
    }
  • Zod schema used for input validation of the 'docker_rm' tool arguments.
    export const dockerRmSchema = z.object({
      containers: z.union([z.string(), z.array(z.string())]).describe('Container name(s) or ID(s) to remove'),
      force: z.boolean().optional().default(false).describe('Force removal of running containers'),
      volumes: z.boolean().optional().default(false).describe('Remove anonymous volumes'),
      cwd: z.string().optional().describe('Working directory')
    });
  • MCP tool definition/registration for 'docker_rm' in the exported dockerTools array, providing the JSON schema for tool listing.
      name: 'docker_rm',
      description: 'Remove one or more containers',
      inputSchema: {
        type: 'object',
        properties: {
          containers: {
            oneOf: [
              { type: 'string' },
              { type: 'array', items: { type: 'string' } }
            ],
            description: 'Container name(s) or ID(s) to remove'
          },
          force: { type: 'boolean', default: false, description: 'Force removal of running containers' },
          volumes: { type: 'boolean', default: false, description: 'Remove anonymous volumes' },
          cwd: { type: 'string', description: 'Working directory' }
        },
        required: ['containers']
      }
    },
  • src/index.ts:499-502 (registration)
    Tool dispatch/registration in the main MCP server request handler for CallToolRequestSchema.
    if (name === 'docker_rm') {
      const validated = dockerRmSchema.parse(args);
      return await dockerRm(validated);
    }
  • Shared helper function that executes all Docker commands and formats ToolResponse, used by dockerRm.
    async function executeDockerCommand(command: string, cwd?: string): Promise<ToolResponse> {
      try {
        const { stdout, stderr } = await execAsync(command, {
          cwd: cwd || process.cwd(),
          shell: '/bin/bash',
          maxBuffer: 10 * 1024 * 1024, // 10MB buffer for logs
          timeout: 60000 // 60 second timeout for builds
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: true,
                command: command,
                stdout: stdout.trim(),
                stderr: stderr.trim(),
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: false,
                command: command,
                stdout: error.stdout?.trim() || '',
                stderr: error.stderr?.trim() || error.message,
                exitCode: error.code || 1,
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ],
          isError: true
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. 'Remove' implies a destructive operation, but the description doesn't specify that this permanently deletes containers, whether removal can be undone, what happens to associated resources, or typical error conditions. It mentions 'one or more containers' which hints at batch capability, but lacks details about atomicity or partial failures.

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?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource. Every word earns its place - 'Remove' (action), 'one or more' (scope), 'containers' (resource). No unnecessary elaboration or repetition.

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 destructive operation with 4 parameters and no annotations or output schema, the description is insufficient. It doesn't cover behavioral aspects like permanence of removal, error handling, or what the tool returns. While the schema documents parameters well, the description fails to provide the contextual understanding needed for safe and effective use of this potentially dangerous tool.

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 adds no additional parameter semantics beyond what's in the schema. It doesn't explain parameter interactions (e.g., force with volumes), provide examples of container identifiers, or clarify the cwd parameter's purpose in this context. Baseline 3 is appropriate when schema does the heavy lifting.

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 verb ('Remove') and resource ('one or more containers'), making the purpose immediately understandable. It distinguishes from siblings like docker_stop (stop containers) and docker_rmi (remove images). However, it doesn't explicitly differentiate from docker_compose_down which also removes containers in a compose context, leaving some ambiguity.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to use docker_rm versus docker_stop (stop without removal), docker_rmi (remove images), or docker_compose_down (remove compose containers). There's also no mention of prerequisites like containers needing to be stopped first unless using the force parameter.

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/ConnorBoetig-dev/mcp2'

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