Skip to main content
Glama

remove_container

Delete a container from the Podman MCP Server by specifying its name or ID. Use the force option to remove running containers.

Instructions

Remove a container.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerYesContainer name or ID
forceNoForce remove running container

Implementation Reference

  • The main handler function for the 'remove_container' tool. It extracts container name/ID and force flag from args, constructs 'podman rm [-f] container' command, executes it via run_podman helper, and returns success/error output.
    async def remove_container(self, args: Dict[str, Any]) -> Dict[str, Any]:
        container = args.get("container")
        force = args.get("force", False)
        cmd_args = ["rm"]
        if force:
            cmd_args.append("-f")
        cmd_args.append(container)
        result = run_podman(cmd_args)
        return {"output": f"Removed container: {container}" if result["success"] else f"Error: {result['stderr']}"}
  • Input schema definition for the remove_container tool, specifying required 'container' string and optional 'force' boolean.
    Tool(
        name="remove_container",
        description="Remove a container",
        inputSchema={
            "type": "object",
            "properties": {
                "container": {
                    "type": "string",
                    "description": "Container name or ID"
                },
                "force": {
                    "type": "boolean",
                    "description": "Force remove running container",
                    "default": False
                }
            },
            "required": ["container"]
        }
    ),
  • main_b.py:459-472 (registration)
    Dictionary mapping tool names to handler methods, registering 'remove_container' to self.remove_container in the tools/call handler.
    tool_handlers = {
        "list_containers": self.list_containers,
        "container_info": self.container_info,
        "start_container": self.start_container,
        "stop_container": self.stop_container,
        "restart_container": self.restart_container,
        "container_logs": self.container_logs,
        "run_container": self.run_container,
        "remove_container": self.remove_container,
        "exec_container": self.exec_container,
        "list_images": self.list_images,
        "pull_image": self.pull_image,
        "container_stats": self.container_stats,
    }
  • main.py:227-236 (handler)
    Alternative implementation of the 'remove_container' tool using FastMCP decorator, with pydantic-typed parameters serving as schema. Executes identical podman rm logic.
    def remove_container(
        container: str = Field(..., description="Container name or ID"),
        force: bool = Field(False, description="Force remove running container"),
    ) -> str:
        args = ["rm"]
        if force:
            args.append("-f")
        args.append(container)
        result = run_podman(args)
        return f"Removed container: {container}" if result["success"] else f"Error: {result['stderr']}"

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/kunwarmahen/podman-mcp-server'

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