Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

docker_logs

Fetch container logs to monitor application output and debug issues by retrieving log entries with optional filtering by time, line count, and timestamp display.

Instructions

Fetch logs from a container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerYesContainer name or ID
tailNoNumber of lines to show from the end of logs
followNoFollow log output (not recommended for MCP)
sinceNoShow logs since timestamp (e.g., "2023-01-01T00:00:00")
timestampsNoShow timestamps
cwdNoWorking directory

Implementation Reference

  • Main handler function that constructs and executes the 'docker logs' command using flags from input args and the executeDockerCommand helper.
    export async function dockerLogs(args: z.infer<typeof dockerLogsSchema>): Promise<ToolResponse> {
      const tailFlag = args.tail ? `--tail ${args.tail}` : '';
      const followFlag = args.follow ? '-f' : '';
      const sinceFlag = args.since ? `--since ${args.since}` : '';
      const timestampsFlag = args.timestamps ? '-t' : '';
    
      return executeDockerCommand(
        `docker logs ${tailFlag} ${followFlag} ${sinceFlag} ${timestampsFlag} ${args.container}`.trim(),
        args.cwd
      );
    }
  • Zod schema defining the input parameters and validation for the docker_logs tool.
    export const dockerLogsSchema = z.object({
      container: z.string().describe('Container name or ID'),
      tail: z.number().optional().describe('Number of lines to show from the end of logs'),
      follow: z.boolean().optional().default(false).describe('Follow log output (not recommended for MCP)'),
      since: z.string().optional().describe('Show logs since timestamp (e.g., "2023-01-01T00:00:00")'),
      timestamps: z.boolean().optional().default(false).describe('Show timestamps'),
      cwd: z.string().optional().describe('Working directory')
    });
  • Tool registration object in the dockerTools array, which is exported and included in the server's tool list response.
    {
      name: 'docker_logs',
      description: 'Fetch logs from a container',
      inputSchema: {
        type: 'object',
        properties: {
          container: { type: 'string', description: 'Container name or ID' },
          tail: { type: 'number', description: 'Number of lines to show from the end of logs' },
          follow: { type: 'boolean', default: false, description: 'Follow log output (not recommended for MCP)' },
          since: { type: 'string', description: 'Show logs since timestamp (e.g., "2023-01-01T00:00:00")' },
          timestamps: { type: 'boolean', default: false, description: 'Show timestamps' },
          cwd: { type: 'string', description: 'Working directory' }
        },
        required: ['container']
      }
    },
  • src/index.ts:447-449 (registration)
    Dispatch logic in the main MCP server request handler that routes 'docker_logs' calls to the handler function after schema validation.
    if (name === 'docker_logs') {
      const validated = dockerLogsSchema.parse(args);
      return await dockerLogs(validated);
  • Helper function that executes Docker shell commands via child_process.exec and formats the ToolResponse.
    async function executeDockerCommand(command: string, cwd?: string): Promise<ToolResponse> {
      try {
        const { stdout, stderr } = await execAsync(command, {
          cwd: cwd || process.cwd(),
          shell: '/bin/bash',
          maxBuffer: 10 * 1024 * 1024, // 10MB buffer for logs
          timeout: 60000 // 60 second timeout for builds
        });
    
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: true,
                command: command,
                stdout: stdout.trim(),
                stderr: stderr.trim(),
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text" as const,
              text: JSON.stringify({
                success: false,
                command: command,
                stdout: error.stdout?.trim() || '',
                stderr: error.stderr?.trim() || error.message,
                exitCode: error.code || 1,
                cwd: cwd || process.cwd()
              }, null, 2)
            }
          ],
          isError: true
        };
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It doesn't disclose whether this is read-only, if it requires specific permissions, potential side effects, or output format. The schema's 'follow' parameter hints at streaming behavior, but the description doesn't elaborate on this or other operational traits.

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 that immediately conveys the core functionality without unnecessary words. It's perfectly front-loaded and wastes no space, 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?

For a tool with 6 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what kind of logs are fetched, format of output, error conditions, or behavioral constraints. The agent would need to infer much from the schema alone, leaving gaps in understanding.

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 parameters are well-documented in the schema itself. The description adds no additional parameter context beyond implying 'container' is the target, which is already clear from schema descriptions. 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 action ('Fetch logs') and target resource ('from a container'), making the purpose immediately understandable. It distinguishes from siblings like docker_compose_logs by specifying 'container' rather than 'compose', though it doesn't explicitly contrast with other logging tools.

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?

No guidance is provided on when to use this tool versus alternatives like docker_compose_logs or when it's appropriate. The description lacks context about prerequisites (e.g., container must be running) or typical use cases, offering minimal usage direction.

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/ConnorBoetig-dev/mcp2'

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