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 }; } }

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