stop_container
Stop a running Podman container by name or ID. Configure timeout period before automatic termination to manage container lifecycle operations.
Instructions
Stop a running container.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| container | Yes | Container name or ID | |
| timeout | No | Seconds to wait before killing container |
Implementation Reference
- main_b.py:511-515 (handler)Handler function that stops the specified container using the podman stop command with an optional timeout.async def stop_container(self, args: Dict[str, Any]) -> Dict[str, Any]: container = args.get("container") timeout = args.get("timeout", 10) result = run_podman(["stop", "-t", str(timeout), container]) return {"output": f"Stopped container: {container}" if result["success"] else f"Error: {result['stderr']}"}
- main_b.py:211-229 (schema)Input schema definition for the stop_container tool, specifying container (required) and optional timeout.Tool( name="stop_container", description="Stop a running container", inputSchema={ "type": "object", "properties": { "container": { "type": "string", "description": "Container name or ID" }, "timeout": { "type": "integer", "description": "Seconds to wait before killing container", "default": 10 } }, "required": ["container"] } ),
- main_b.py:459-472 (registration)Registration of tool handlers in the dictionary used to dispatch tool calls to the appropriate methods.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:176-182 (handler)Handler function decorated with @mcp.tool that stops the container using podman, with schema defined via Field annotations.@mcp.tool(title="Stop container", description="Stop a running container.") def stop_container( container: str = Field(..., description="Container name or ID"), timeout: int = Field(10, description="Seconds to wait before killing container"), ) -> str: result = run_podman(["stop", "-t", str(timeout), container]) return f"Stopped container: {container}" if result["success"] else f"Error: {result['stderr']}"