Skip to main content
Glama

list_containers

Retrieve a list of Docker containers to monitor and manage running or all container instances for system oversight.

Instructions

List all Docker containers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
allNoShow all containers (default shows just running)

Implementation Reference

  • The handler function for 'list_containers' tool. Executes 'docker ps' (with optional -a for all containers), parses tabular output into JSON array of {id, image, status, name}, returns as 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), }, ], }; }
  • src/index.ts:69-81 (registration)
    Tool registration in ListToolsRequestHandler response, including name, description, and input schema.
    { name: 'list_containers', description: 'List all Docker containers', inputSchema: { type: 'object', properties: { all: { type: 'boolean', description: 'Show all containers (default shows just running)', }, }, }, },
  • TypeScript interface defining the input arguments for the list_containers tool.
    interface ContainerArgs { all?: boolean; }
  • src/index.ts:189-190 (registration)
    Switch case in CallToolRequestHandler that routes 'list_containers' calls to the handler function.
    case 'list_containers': return await this.listContainers(request.params.arguments as unknown as ContainerArgs);

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