Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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}")]
  • 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": {} } )
  • Input schema for the 'list-containers' tool, indicating it takes no arguments (empty properties).
    inputSchema={ "type": "object", "properties": {} }
  • 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)

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

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