Skip to main content
Glama

remove_image

Delete Docker images to free up disk space and manage container resources. Use force option to remove images that are in use.

Instructions

Remove a Docker image. Use force=true to force removal.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesImage ID or tag
forceNoForce remove

Implementation Reference

  • The handler function that executes the remove_image tool logic. Uses Dockerode to get the image by ID and calls its remove() method with the force option, returning a success message.
    export async function removeImage(id: string, force: boolean): Promise<string> {
      const image = docker.getImage(id);
      await image.remove({ force });
      return `Image ${id} removed`;
    }
  • src/index.ts:175-186 (registration)
    Registration of the 'remove_image' MCP tool using server.tool(). Defines the tool name, description, Zod schema for input validation (id: string, force: boolean with default false), and the async handler that calls removeImage().
    server.tool(
      "remove_image",
      "Remove a Docker image. Use force=true to force removal.",
      {
        id: z.string().describe("Image ID or tag"),
        force: z.boolean().optional().default(false).describe("Force remove"),
      },
      async ({ id, force }) => {
        const result = await removeImage(id, force);
        return { content: [{ type: "text", text: result }] };
      },
    );
  • Zod schema definition for remove_image tool inputs: 'id' (required string for image ID or tag) and 'force' (optional boolean defaulting to false for forced removal).
    {
      id: z.string().describe("Image ID or tag"),
      force: z.boolean().optional().default(false).describe("Force remove"),
    },
  • Import statement that brings the removeImage function from ./docker.js into the main server module for use in tool registration.
    removeImage,
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the 'force' parameter, which hints at potential resistance (e.g., if the image is in use), but doesn't explain what happens without force, whether removal is permanent, if it affects running containers, or any error conditions. For a destructive operation with zero annotation coverage, this leaves significant gaps in understanding the tool's behavior.

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 extremely concise with two short sentences that are front-loaded: the first states the core purpose, and the second adds crucial parameter guidance. There is zero waste or redundancy, making it highly efficient and easy to parse.

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?

Given the complexity (a destructive operation with potential side effects), lack of annotations, and no output schema, the description is incomplete. It doesn't cover important aspects like what happens on success/failure, whether removal is reversible, or how it interacts with sibling tools (e.g., containers using the image). For a tool that modifies system state, this leaves too much unspecified.

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 both parameters ('id' as 'Image ID or tag' and 'force' as 'Force remove'). The description adds minimal value by reiterating the 'force' parameter usage but doesn't provide additional context like examples of image IDs/tags or what 'force' specifically overrides. Baseline 3 is appropriate when the 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 action ('Remove') and resource ('Docker image'), making the purpose immediately understandable. It distinguishes from siblings like 'remove_container' by specifying the resource type. However, it doesn't explicitly contrast with other image-related tools (none in the sibling list), so it's not a perfect 5.

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

Usage Guidelines3/5

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

The description provides some usage guidance by mentioning 'force=true to force removal', which implies when to use that parameter. However, it doesn't explicitly state when to use this tool versus alternatives like 'list_images' (for checking before removal) or 'remove_container' (for different resources). The guidance is limited to parameter usage rather than tool selection.

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/ofershap/mcp-server-docker'

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