Skip to main content
Glama

list_containers

Retrieve a list of Docker containers with options to display running or all containers. Enables efficient container management and monitoring through the Docker MCP Server.

Instructions

List all Docker containers

Input Schema

NameRequiredDescriptionDefault
allNoShow all containers (default shows just running)

Input Schema (JSON Schema)

{ "properties": { "all": { "description": "Show all containers (default shows just running)", "type": "boolean" } }, "type": "object" }

Implementation Reference

  • The main handler function for the 'list_containers' tool. It executes 'docker ps' with optional '-a' flag based on args.all, parses the output into a structured list of containers (id, image, status, name), and returns it as JSON text content.
    private async listContainers(args: ContainerArgs) { const showAll = args?.all === true ? '-a' : ''; const { stdout } = await execAsync(`docker ps ${showAll} --format "{{.ID}}\\t{{.Image}}\\t{{.Status}}\\t{{.Names}}"`); const containers = stdout.trim().split('\n') .filter(line => line.trim() !== '') .map(line => { const [id, image, status, name] = line.split('\t'); return { id, image, status, name }; }); return { content: [ { type: 'text', text: JSON.stringify(containers, null, 2), }, ], }; }
  • TypeScript interface defining the input arguments for the list_containers tool: optional 'all' boolean to show all containers.
    interface ContainerArgs { all?: boolean; }
  • src/index.ts:69-81 (registration)
    Tool registration in the ListToolsRequestHandler: defines name, description, and inputSchema for list_containers.
    { name: 'list_containers', description: 'List all Docker containers', inputSchema: { type: 'object', properties: { all: { type: 'boolean', description: 'Show all containers (default shows just running)', }, }, }, },
  • src/index.ts:189-190 (registration)
    Dispatch case in CallToolRequestHandler switch statement that routes 'list_containers' calls to the handler function.
    case 'list_containers': return await this.listContainers(request.params.arguments as unknown as ContainerArgs);

Other Tools

Related Tools

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

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