list-containers
Retrieve and display all Docker containers currently running or stopped on your system for container management.
Instructions
List all Docker containers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/docker_mcp/handlers.py:182-195 (handler)The handler function for the 'list-containers' tool. It lists all Docker containers (including stopped ones) using the python_on_whales DockerClient, formats their ID, name, and status, and returns the list as text content.@staticmethod async def handle_list_containers(arguments: Dict[str, Any]) -> List[TextContent]: debug_info = [] try: debug_info.append("Listing all Docker containers") containers = await asyncio.to_thread(docker_client.container.list, all=True) container_list = "\n".join( [f"{c.id[:12]} - {c.name} - {c.state.status}" for c in containers]) return [TextContent(type="text", text=f"All Docker Containers:\n{container_list}\n\nDebug Info:\n{chr(10).join(debug_info)}")] except Exception as e: debug_output = "\n".join(debug_info) return [TextContent(type="text", text=f"Error listing containers: {str(e)}\n\nDebug Information:\n{debug_output}")]
- src/docker_mcp/server.py:139-146 (registration)Registration of the 'list-containers' tool in the @server.list_tools() handler, defining its name, description, and empty input schema (no arguments required).types.Tool( name="list-containers", description="List all Docker containers", inputSchema={ "type": "object", "properties": {} } )
- src/docker_mcp/server.py:142-145 (schema)Input schema for the 'list-containers' tool, indicating it takes no arguments (empty properties).inputSchema={ "type": "object", "properties": {} }
- src/docker_mcp/server.py:162-163 (handler)Dispatch in the @server.call_tool() handler that routes 'list-containers' calls to the DockerHandlers.handle_list_containers method.elif name == "list-containers": return await DockerHandlers.handle_list_containers(arguments)