Skip to main content
Glama

list_docker_images

Retrieve a list of Docker images on a remote server by specifying hostname, username, and optional parameters like port and timeout. Simplify remote Docker image management with this tool.

Instructions

列出Docker镜像

Input Schema

NameRequiredDescriptionDefault
hostnameYes
passwordNo
portNo
timeoutNo
usernameYes

Input Schema (JSON Schema)

{ "properties": { "hostname": { "title": "Hostname", "type": "string" }, "password": { "default": "", "title": "Password", "type": "string" }, "port": { "default": 22, "title": "Port", "type": "integer" }, "timeout": { "default": 30, "title": "Timeout", "type": "integer" }, "username": { "title": "Username", "type": "string" } }, "required": [ "hostname", "username" ], "title": "list_docker_imagesArguments", "type": "object" }

Implementation Reference

  • Core handler function for the 'list_docker_images' MCP tool. Executes 'docker images' via SSH, checks Docker installation, parses output using ServerInspector.parse_docker_images, and returns structured InspectionResult.
    def list_docker_images( hostname: str, username: str, password: str = "", port: int = 22, timeout: int = 30 ) -> dict: """列出Docker镜像及其信息""" result = InspectionResult() try: with SSHManager(hostname, username, password, port, timeout) as ssh: # 检查Docker是否安装 stdin, stdout, stderr = ssh.exec_command("command -v docker", timeout=timeout) if not stdout.read().strip(): result.status = "error" result.error = "Docker未安装在目标服务器上" return result.dict() # 执行命令 stdin, stdout, stderr = ssh.exec_command("docker images", timeout=timeout) images_output = stdout.read().decode('utf-8') error_output = stderr.read().decode('utf-8') if error_output: result.status = "error" result.error = f"获取镜像列表失败: {error_output}" return result.dict() # 解析镜像信息 images = ServerInspector.parse_docker_images(images_output) # 设置结果 result.status = "success" result.data = {"images": images} result.raw_outputs = {"image_list": images_output} image_count = len(images) result.summary = f"找到 {image_count} 个Docker镜像" except Exception as e: result.status = "error" result.error = f"获取镜像列表失败: {str(e)}" return result.dict()
  • JSON schema definition for the 'list_docker_images' tool, including name, description, and input parameters used in list_available_tools and MCP tool listing.
    {"name": "list_docker_images", "description": "列出Docker镜像及其信息", "parameters": [ {"name": "hostname", "type": "str", "default": None}, {"name": "username", "type": "str", "default": None}, {"name": "password", "type": "str", "default": ""}, {"name": "port", "type": "int", "default": 22}, {"name": "timeout", "type": "int", "default": 30} ]},
  • MCP tool registration and dispatch logic in the @app.call_tool() handler, matching tool name and invoking list_docker_images with arguments.
    elif name == "list_docker_images": required_args = ["hostname", "username"] for arg in required_args: if arg not in arguments: raise ValueError(f"Missing required argument '{arg}'") result = list_docker_images( hostname=arguments["hostname"], username=arguments["username"], password=arguments.get("password", ""), port=arguments.get("port", 22), timeout=arguments.get("timeout", 30) )
  • TypedDict model for Docker image information used in the tool's output data structure.
    class ImageInfo(TypedDict): """镜像信息数据结构""" repository: str tag: str image_id: str created: str size: str
  • Import registration of the list_docker_images handler into the MCP server module.
    list_docker_images, list_docker_volumes, get_container_logs, monitor_container_stats, check_docker_health, list_available_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/Heht571/ops-mcp-server'

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