Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

docker_rmi

Remove Docker images from your system by name or ID to free up disk space and manage container resources during development workflows.

Instructions

Remove one or more images

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
imagesYesImage name(s) or ID(s) to remove
forceNoForce removal
cwdNoWorking directory

Implementation Reference

  • Main handler function that executes 'docker rmi' command with optional force flag and cwd.
    export async function dockerRmi(args: z.infer<typeof dockerRmiSchema>): Promise<ToolResponse> {
      const images = Array.isArray(args.images) ? args.images.join(' ') : args.images;
      const forceFlag = args.force ? '-f' : '';
    
      return executeDockerCommand(`docker rmi ${forceFlag} ${images}`.trim(), args.cwd);
    }
  • Zod schema defining input parameters for the docker_rmi tool: images (string or array), force (boolean), cwd (string).
    export const dockerRmiSchema = z.object({
      images: z.union([z.string(), z.array(z.string())]).describe('Image name(s) or ID(s) to remove'),
      force: z.boolean().optional().default(false).describe('Force removal'),
      cwd: z.string().optional().describe('Working directory')
    });
  • MCP tool definition/registration for 'docker_rmi' in the exported dockerTools array, including JSON schema.
    {
      name: 'docker_rmi',
      description: 'Remove one or more images',
      inputSchema: {
        type: 'object',
        properties: {
          images: {
            oneOf: [
              { type: 'string' },
              { type: 'array', items: { type: 'string' } }
            ],
            description: 'Image name(s) or ID(s) to remove'
          },
          force: { type: 'boolean', default: false, description: 'Force removal' },
          cwd: { type: 'string', description: 'Working directory' }
        },
        required: ['images']
      }
    }
  • Dispatcher in main MCP server CallToolRequest handler that validates arguments with dockerRmiSchema and calls dockerRmi function.
    if (name === 'docker_rmi') {
      const validated = dockerRmiSchema.parse(args);
      return await dockerRmi(validated);
    }
  • Shared helper function used by all Docker tools to execute docker commands via child_process.exec with proper error handling and JSON output formatting.
    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 it doesn't specify consequences (e.g., images are permanently deleted, cannot be undone, may fail if images are in use or have dependent containers). It also doesn't mention authentication needs, rate limits, or what happens on success/failure.

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, making it immediately understandable without unnecessary elaboration.

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 tool with no annotations and no output schema, the description is incomplete. It lacks critical context: what happens on success/failure, error conditions (e.g., if images don't exist or are in use), and behavioral details like whether removal is permanent. The 100% schema coverage helps with parameters, but overall context is insufficient.

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 (images, force, cwd) thoroughly. The description adds no additional parameter semantics beyond what's in the schema, such as explaining what 'force' overrides or why cwd might be relevant. 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 'Remove one or more images' clearly states the action (remove) and target resource (images), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like docker_rm (which removes containers) or fs_delete_file (which deletes files), though the 'images' context makes the distinction reasonably clear.

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. There's no mention of prerequisites (e.g., images must exist and not be in use), when to use force removal, or how this differs from related tools like docker_rm (for containers) or docker_prune (for cleanup).

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