Skip to main content
Glama
Heht571
by Heht571

list_docker_volumes

List Docker volumes on remote servers to manage storage and inspect data persistence across containers.

Instructions

列出Docker卷

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostnameYes
usernameYes
passwordNo
portNo
timeoutNo

Implementation Reference

  • The primary handler function for the 'list_docker_volumes' tool. It connects via SSH to the target server, checks for Docker, runs 'docker volume ls', parses the output using ServerInspector.parse_docker_volumes, and returns structured results including volumes list and summary.
    def list_docker_volumes(
        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 volume ls", timeout=timeout)
                volumes_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()
    
                # 解析卷信息
                volumes = ServerInspector.parse_docker_volumes(volumes_output)
    
                # 设置结果
                result.status = "success"
                result.data = {"volumes": volumes}
                result.raw_outputs = {"volume_list": volumes_output}
    
                volume_count = len(volumes)
                result.summary = f"找到 {volume_count} 个Docker卷"
    
        except Exception as e:
            result.status = "error"
            result.error = f"获取卷列表失败: {str(e)}"
    
        return result.dict()
  • The JSON schema definition for the MCP tool 'list_docker_volumes', including description and input parameters (hostname, username, password, port, timeout). Used by list_tools() to generate the tool schema.
    {"name": "list_docker_volumes", "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}
    ]},
  • Registration and dispatching logic in the MCP app.call_tool() method. Checks required args and calls the list_docker_volumes handler with provided arguments.
    elif name == "list_docker_volumes":
        required_args = ["hostname", "username"]
        for arg in required_args:
            if arg not in arguments:
                raise ValueError(f"Missing required argument '{arg}'")
    
        result = list_docker_volumes(
            hostname=arguments["hostname"],
            username=arguments["username"],
            password=arguments.get("password", ""),
            port=arguments.get("port", 22),
            timeout=arguments.get("timeout", 30)
        )
  • Import registration of the list_docker_volumes function from docker_tools.py into the tools package, making it available for use in the MCP server.
    from .docker_tools import (
        list_docker_containers,
        list_docker_images,
        list_docker_volumes,
  • Pydantic/TypedDict model for VolumeInfo used in the output data structure of list_docker_volumes.
    class VolumeInfo(TypedDict):
        """卷信息数据结构"""
        volume_name: str
        driver: str
        mountpoint: str
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. '列出Docker卷' only states the action without any information about authentication requirements (though parameters suggest SSH connection), rate limits, error conditions, or what the output looks like. For a tool with 5 parameters including credentials, this is a significant transparency gap.

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 - a single phrase '列出Docker卷' - which is appropriately sized for what it communicates. There's no wasted language, though this conciseness comes at the cost of completeness. The structure is front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters including authentication, no annotations, no output schema, 0% schema coverage), the description is completely inadequate. It doesn't explain the SSH connection requirement, authentication needs, what information is returned about volumes, or how this differs from other Docker listing tools. For a tool that appears to connect remotely to list Docker resources, this minimal description leaves critical gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 5 parameters have descriptions in the schema. The tool description provides absolutely no information about parameters - it doesn't mention that this requires SSH connection parameters (hostname, username, password, port, timeout) or explain their purpose. The description fails to compensate for the complete lack of schema documentation.

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 '列出Docker卷' (List Docker volumes) states a clear verb ('list') and resource ('Docker volumes'), which is better than a tautology. However, it doesn't distinguish this tool from its sibling 'list_docker_containers' or 'list_docker_images' - all three appear to list different Docker resources without clear differentiation in the description itself.

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. There are multiple listing tools in the sibling set (list_docker_containers, list_docker_images, list_docker_volumes), but the description doesn't help an agent choose between them or indicate any specific context for volume listing versus other Docker 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/Heht571/ops-mcp-server'

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