Skip to main content
Glama
Toowiredd

ChatGPT MCP Server

container_logs

Retrieve Docker container logs to monitor application output and debug issues by specifying container ID and optional line count.

Instructions

Get container logs

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerYesContainer ID or name
tailNoNumber of lines to show from the end

Implementation Reference

  • Core handler function that implements the 'container_logs' tool logic by executing the 'docker logs' command with optional --tail parameter.
    async getContainerLogs(id: string, tail?: number): Promise<string> {
      return this.executeCommand(`logs ${tail ? `--tail ${tail}` : ''} ${id}`);
    }
  • Tool registration in the MCP server's listTools handler, defining name, description, and input schema for 'container_logs'.
    {
      name: 'container_logs',
      description: 'Get container logs',
      inputSchema: {
        type: 'object',
        properties: {
          container: {
            type: 'string',
            description: 'Container ID or name',
          },
          tail: {
            type: 'number',
            description: 'Number of lines to show from the end',
          },
        },
        required: ['container'],
      },
    },
  • Dispatch handler in MCP server's callToolRequestSchema that parses arguments and invokes the DockerService handler for 'container_logs'.
    case 'container_logs': {
      const { container, tail } = request.params.arguments as {
        container: string;
        tail?: number;
      };
      const output = await this.dockerService.getContainerLogs(container, tail);
      return {
        content: [{ type: 'text', text: output }],
      };
    }
  • Input schema definition for the 'container_logs' tool, specifying required 'container' and optional 'tail' parameters.
    inputSchema: {
      type: 'object',
      properties: {
        container: {
          type: 'string',
          description: 'Container ID or name',
        },
        tail: {
          type: 'number',
          description: 'Number of lines to show from the end',
        },
      },
      required: ['container'],
    },
  • Helper method used by getContainerLogs to execute Docker CLI commands asynchronously.
    async executeCommand(command: string): Promise<string> {
      try {
        const { stdout } = await execAsync(`docker ${command}`);
        return stdout;
      } catch (error: any) {
        throw new McpError(
          ErrorCode.InternalError,
          `Docker command failed: ${error.message}`
        );
      }
    }
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. 'Get container logs' implies a read-only operation, but it doesn't specify if this requires special permissions, if logs are streamed or fetched once, rate limits, or error conditions. For a tool with no annotations, this leaves significant gaps in understanding its behavior beyond the basic action.

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 extremely concise with just three words, front-loading the core action without any wasted text. It efficiently communicates the tool's purpose in minimal space, though this brevity contributes to gaps in other dimensions. Every word earns its place by directly stating the function.

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 moderate complexity (fetching logs from containers), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the logs contain, how they're formatted, or any prerequisites like container state. For a tool with no structured behavioral data, more context is needed to fully understand its use and limitations.

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?

The input schema has 100% description coverage, with clear documentation for 'container' (ID or name) and 'tail' (number of lines from the end). The description adds no additional meaning beyond what the schema provides, such as explaining log format or default behavior. Given the high schema coverage, a baseline score of 3 is appropriate as the schema does the heavy lifting.

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

Purpose3/5

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

The description 'Get container logs' clearly states the verb ('Get') and resource ('container logs'), making the basic purpose understandable. However, it lacks specificity about what kind of logs (e.g., stdout/stderr, real-time vs. historical) and doesn't distinguish it from potential sibling tools like 'container_exec' which might also access logs. It's adequate but vague in scope.

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 sibling tools like 'container_exec' (which might run commands in containers) and 'containers_list' (which lists containers), there's no indication of when logs are needed over other operations. It's a basic statement of function without context for selection.

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/Toowiredd/chatgpt-mcp-server'

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