Skip to main content
Glama

Docker Monitoring and Troubleshooting

docker_monitoring

Monitor Docker containers to view logs, inspect resources, execute commands, and troubleshoot issues with real-time metrics and events.

Instructions

Monitor containers, get logs, inspect resources, and troubleshoot issues

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesMonitoring action to perform
containerNoContainer name or ID
followNoFollow log output
tailNoNumber of lines to show from end of logs
commandNoCommand to execute in container (for exec)
sinceNoShow logs since timestamp
untilNoShow logs until timestamp

Implementation Reference

  • Handler function for the 'docker_monitoring' tool. Constructs Docker commands for monitoring actions (logs, inspect, exec, top, port, stats, events, diff) based on input parameters and executes them using executeDockerCommand.
    async ({ action, container, follow, tail, command, since, until }) => {
      try {
        let dockerCommand: string;
        
        switch (action) {
          case "logs":
            if (!container) throw new Error("Container name is required for logs");
            dockerCommand = `docker logs`;
            if (follow) dockerCommand += " -f";
            if (tail) dockerCommand += ` --tail ${tail}`;
            if (since) dockerCommand += ` --since ${since}`;
            if (until) dockerCommand += ` --until ${until}`;
            dockerCommand += ` ${container}`;
            break;
          case "inspect":
            if (!container) throw new Error("Container name is required for inspect");
            dockerCommand = `docker inspect ${container}`;
            break;
          case "exec":
            if (!container) throw new Error("Container name is required for exec");
            const execCommand = command || "bash";
            dockerCommand = `docker exec -it ${container} ${execCommand}`;
            break;
          case "top":
            if (!container) throw new Error("Container name is required for top");
            dockerCommand = `docker top ${container}`;
            break;
          case "port":
            if (!container) throw new Error("Container name is required for port");
            dockerCommand = `docker port ${container}`;
            break;
          case "stats":
            dockerCommand = container ? `docker stats --no-stream ${container}` : "docker stats --no-stream";
            break;
          case "events":
            dockerCommand = "docker events --since 1h";
            if (container) dockerCommand += ` --filter container=${container}`;
            break;
          case "diff":
            if (!container) throw new Error("Container name is required for diff");
            dockerCommand = `docker diff ${container}`;
            break;
        }
        
        const result = await executeDockerCommand(dockerCommand);
        
        return {
          content: [
            {
              type: "text",
              text: `Monitoring ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}`
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error with monitoring operation: ${error instanceof Error ? error.message : String(error)}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema for the 'docker_monitoring' tool defining parameters for various monitoring actions.
    inputSchema: {
      action: z.enum(["logs", "inspect", "exec", "top", "port", "stats", "events", "diff"]).describe("Monitoring action to perform"),
      container: z.string().optional().describe("Container name or ID"),
      follow: z.boolean().optional().describe("Follow log output"),
      tail: z.number().optional().describe("Number of lines to show from end of logs"),
      command: z.string().optional().describe("Command to execute in container (for exec)"),
      since: z.string().optional().describe("Show logs since timestamp"),
      until: z.string().optional().describe("Show logs until timestamp")
    }
  • src/index.ts:1732-1736 (registration)
    Registration of the 'docker_monitoring' MCP tool with title, description, and input schema.
    server.registerTool(
      "docker_monitoring",
      {
        title: "Docker Monitoring and Troubleshooting",
        description: "Monitor containers, get logs, inspect resources, and troubleshoot issues",
  • Helper function executeDockerCommand used by the docker_monitoring handler to run Docker commands.
    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}`);
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It lists actions but doesn't explain what 'troubleshoot issues' entails, whether operations are read-only or have side effects (e.g., 'exec' might modify container state), or any constraints like permissions or rate limits. This is inadequate for a tool with multiple action types.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads key actions. However, it could be more structured by explicitly listing the 'action' enum values or grouping related functionalities, but it avoids unnecessary verbosity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (7 parameters, multiple actions) and lack of annotations and output schema, the description is insufficient. It doesn't cover behavioral aspects like side effects, error handling, or return formats, which are critical for an agent to use it correctly, especially with actions like 'exec' that may have security implications.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, providing clear documentation for all 7 parameters. The description adds no parameter-specific information beyond what's in the schema, such as clarifying how 'action' maps to the listed verbs or explaining parameter interactions. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('monitor', 'get logs', 'inspect resources', 'troubleshoot issues') and identifies the resource (containers). It distinguishes from some siblings like 'create_container' or 'manage_images' but doesn't explicitly differentiate from 'docker_monitoring_advanced', which appears to be a more specialized version.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over 'docker_monitoring_advanced' or other sibling tools like 'execute_docker_command', leaving the agent to infer usage from the name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/TauqeerAhmad5201/docker-mcp-extension'

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