Skip to main content
Glama

get-logs

Retrieve container logs from Docker to monitor application behavior and troubleshoot issues by specifying the container name.

Instructions

Retrieve the latest logs for a specified Docker container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
container_nameYes

Implementation Reference

  • Implements the core logic for the 'get-logs' tool: extracts container_name from arguments, fetches the last 100 logs using docker_client.container.logs, and returns formatted text content with logs or error.
    @staticmethod async def handle_get_logs(arguments: Dict[str, Any]) -> List[TextContent]: debug_info = [] try: container_name = arguments.get("container_name") if not container_name: raise ValueError("Missing required container_name") debug_info.append(f"Fetching logs for container '{ container_name}'") logs = await asyncio.to_thread(docker_client.container.logs, container_name, tail=100) return [TextContent(type="text", text=f"Logs for container '{container_name}':\n{logs}\n\nDebug Info:\n{chr(10).join(debug_info)}")] except Exception as e: debug_output = "\n".join(debug_info) return [TextContent(type="text", text=f"Error retrieving logs: {str(e)}\n\nDebug Information:\n{debug_output}")]
  • Registers the 'get-logs' tool in the MCP server's list_tools() method, including its description and input schema requiring 'container_name'.
    types.Tool( name="get-logs", description="Retrieve the latest logs for a specified Docker container", inputSchema={ "type": "object", "properties": { "container_name": {"type": "string"} }, "required": ["container_name"] } ),
  • Dispatches 'get-logs' tool calls to the DockerHandlers.handle_get_logs implementation.
    elif name == "get-logs": return await DockerHandlers.handle_get_logs(arguments)
  • Defines the input schema for the 'get-logs' tool: object with required 'container_name' string property.
    inputSchema={ "type": "object", "properties": { "container_name": {"type": "string"} }, "required": ["container_name"] }

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

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