Skip to main content
Glama

container_logs

Retrieve Docker container logs to monitor application output and debug issues. Specify container ID and optional line count for targeted log access.

Instructions

Get logs from a Docker container.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesContainer ID or name
tailNoNumber of lines from the end

Implementation Reference

  • Handler function that fetches logs from a Docker container using the Docker API. It retrieves the container by ID, fetches logs with specified tail lines, and strips control characters from the output.
    export async function containerLogs(id: string, tail: number): Promise<string> {
      const container = docker.getContainer(id);
      const logs = await container.logs({
        stdout: true,
        stderr: true,
        tail,
        follow: false,
      });
      // Strip Docker log control characters (eslint: intentional for Docker output)
      return logs.toString("utf-8").replace(/[\x00-\x08]/g, ""); // eslint-disable-line no-control-regex
    }
  • src/index.ts:53-68 (registration)
    Registration of the 'container_logs' MCP tool with the server. Includes the tool name, description, input schema, and the async handler that calls the containerLogs function.
    server.tool(
      "container_logs",
      "Get logs from a Docker container.",
      {
        id: z.string().describe("Container ID or name"),
        tail: z
          .number()
          .optional()
          .default(100)
          .describe("Number of lines from the end"),
      },
      async ({ id, tail }) => {
        const logs = await containerLogs(id, tail);
        return { content: [{ type: "text", text: logs || "(no logs)" }] };
      },
    );
  • Zod schema defining the input parameters for container_logs: 'id' (required string for container ID or name) and 'tail' (optional number with default 100 for number of log lines).
    id: z.string().describe("Container ID or name"),
    tail: z
      .number()
      .optional()
      .default(100)
      .describe("Number of lines from the end"),
Behavior2/5

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

No annotations are provided, so the description carries full burden. While 'Get logs' implies a read operation, it doesn't disclose important behavioral traits like whether this requires specific permissions, if it streams or returns static output, rate limits, or what happens with invalid container IDs. The description is minimal and lacks operational context.

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 appropriately sized for a simple tool and front-loads the essential information ('Get logs from a Docker container'). Every word earns its place.

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?

For a tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what format the logs are returned in (e.g., text, JSON), whether it includes timestamps, or how errors are handled. Given the lack of structured fields, more descriptive context is needed for effective 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%, so the schema already documents both parameters ('id' and 'tail') with their types and descriptions. The description adds no additional parameter semantics beyond what's in the schema, but the schema provides adequate documentation, meeting the baseline for high coverage.

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 ('Get logs') and resource ('from a Docker container'), making the tool's purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'container_stats' or 'exec_command' which also interact with containers but serve different purposes.

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. With siblings like 'list_containers' (for discovery) and 'exec_command' (for executing commands), there's no indication that this tool is specifically for retrieving log output rather than other container operations.

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

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