docker_info
Retrieve Docker system information, version details, container statistics, or disk usage data to monitor and manage Docker environments.
Instructions
Get Docker system information and statistics
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| type | Yes | Type of information to retrieve |
Implementation Reference
- src/index.ts:1331-1370 (handler)Handler for the docker_info tool: executes specific Docker system commands based on input 'type' (info, version, stats, disk_usage), captures output using executeDockerCommand, and returns formatted text response or error.try { let command: string; switch (type) { case "info": command = "docker system info"; break; case "version": command = "docker --version && docker-compose --version"; break; case "stats": command = "docker stats --no-stream"; break; case "disk_usage": command = "docker system df"; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Docker ${type}:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting Docker information: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/index.ts:1324-1330 (schema)Schema definition for docker_info tool including title, description, and inputSchema with 'type' enum.title: "Docker System Information", description: "Get Docker system information and statistics", inputSchema: { type: z.enum(["info", "version", "stats", "disk_usage"]).describe("Type of information to retrieve") } }, async ({ type }) => {
- src/index.ts:1322-1372 (registration)Registration of the 'docker_info' tool on the MCP server with name, schema, and handler function."docker_info", { title: "Docker System Information", description: "Get Docker system information and statistics", inputSchema: { type: z.enum(["info", "version", "stats", "disk_usage"]).describe("Type of information to retrieve") } }, async ({ type }) => { try { let command: string; switch (type) { case "info": command = "docker system info"; break; case "version": command = "docker --version && docker-compose --version"; break; case "stats": command = "docker stats --no-stream"; break; case "disk_usage": command = "docker system df"; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Docker ${type}:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error getting Docker information: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- src/index.ts:383-390 (helper)Helper function executeDockerCommand used by the docker_info handler to run shell commands via promisified child_process.exec.async function executeDockerCommand(command: string): Promise<{ stdout: string; stderr: string }> { try { const result = await execAsync(command); return result; } catch (error: any) { throw new Error(`Docker command failed: ${error.message}`); } }