Skip to main content
Glama

docker_container_logs

Fetch Docker container logs to monitor application performance, troubleshoot errors, and analyze system behavior by retrieving log entries from specified containers.

Instructions

Fetch logs from a Docker container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesContainer ID or name
tailNoNumber of lines from end (default: 100)
sinceNoUnix timestamp to start from

Implementation Reference

  • The containerLogs function retrieves logs from a Docker container using the Docker SDK.
    export async function containerLogs(args: Record<string, unknown>): Promise<string> {
      const docker = getDockerClient();
      const id = args.id as string || args.name as string;
      if (!id) throw new Error("Container ID or name is required");
    
      const tail = (args.tail as number) || 100;
      const since = args.since as number | undefined;
    
      const container = docker.getContainer(id);
      const logs = await container.logs({
        stdout: true,
        stderr: true,
        tail,
        since,
        timestamps: true,
      });
    
      const logStr = typeof logs === "string" ? logs : logs.toString("utf-8");
      if (!logStr.trim()) {
        return `No logs found for container '${id}'.`;
      }
    
      return `Logs for container '${id}' (last ${tail} lines):\n\n${logStr}`;
    }
  • Tool registration for 'docker_container_logs' including input schema.
      name: "docker_container_logs",
      description: "Fetch logs from a Docker container",
      inputSchema: {
        type: "object" as const,
        properties: {
          id: { type: "string", description: "Container ID or name" },
          tail: { type: "number", description: "Number of lines from end (default: 100)" },
          since: { type: "number", description: "Unix timestamp to start from" },
        },
        required: ["id"],
      },
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('fetch logs') but doesn't cover critical aspects like authentication requirements, rate limits, output format (e.g., stream vs. static), error handling, or whether it's a read-only operation. This is a significant gap for a tool interacting with system resources.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and avoids unnecessary elaboration, making it easy for an agent to parse quickly.

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 complexity of interacting with Docker containers and the lack of annotations and output schema, the description is insufficient. It doesn't explain what the logs contain, how they're formatted, or potential side effects (e.g., if fetching logs impacts container performance). For a tool with no structured behavioral hints, this leaves too many unknowns for reliable agent use.

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%, with clear descriptions for all parameters (id, tail, since). The description doesn't add any semantic details beyond what's in the schema, such as examples or constraints. This meets the baseline score of 3 since the schema adequately documents the parameters.

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 action ('fetch logs') and resource ('from a Docker container'), which is specific and unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'docker_compose_logs' or 'k8s_get_pod_logs', which handle similar logging functions in different contexts.

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 sibling tools like 'docker_compose_logs' for Docker Compose environments or 'k8s_get_pod_logs' for Kubernetes pods, leaving the agent to infer usage context from the tool 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/batu-sonmez/infraclaude'

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