list_containers
View running Podman containers or display all containers when needed to manage containerized applications and monitor container status.
Instructions
List containers (running by default, all if requested).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| all | No | Show all containers, not just running |
Implementation Reference
- main_b.py:493-499 (handler)The asynchronous handler method that executes the list_containers tool by running the 'podman ps' command with optional --all flag.async def list_containers(self, args: Dict[str, Any]) -> Dict[str, Any]: all_containers = args.get("all", False) cmd_args = ["ps", "--format", "json"] if all_containers: cmd_args.append("--all") result = run_podman(cmd_args) return {"output": result["stdout"] if result["success"] else f"Error: {result['stderr']}"}
- main.py:155-161 (handler)The handler function decorated with @mcp.tool that implements the list_containers tool using 'podman ps' command.@mcp.tool(title="List containers", description="List containers (running by default, all if requested).") def list_containers(all: bool = Field(False, description="Show all containers, not just running")) -> str: args = ["ps", "--format", "json"] if all: args.append("--all") result = run_podman(args) return result["stdout"] if result["success"] else f"Error: {result['stderr']}"
- main_b.py:172-181 (schema)The JSON schema definition for the input parameters of the list_containers tool, specifying the optional 'all' boolean parameter.inputSchema={ "type": "object", "properties": { "all": { "type": "boolean", "description": "Show all containers, not just running", "default": False } } }
- main_b.py:459-472 (registration)The dictionary mapping tool names to their handler methods, registering 'list_containers' to self.list_containers.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_b.py:169-182 (registration)Registration of the list_containers tool in the server's tools list with name, description, and schema.Tool( name="list_containers", description="List containers (running by default, all if requested)", inputSchema={ "type": "object", "properties": { "all": { "type": "boolean", "description": "Show all containers, not just running", "default": False } } } ),