Skip to main content
Glama

Container stats

container_stats

Monitor container resource usage statistics including CPU, memory, and network metrics to track performance and identify resource bottlenecks in Podman containers.

Instructions

Get resource usage statistics for containers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerNoContainer name or ID (all containers if not specified)
no_streamNoDisable streaming stats and only pull the first result

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function that implements the container_stats tool logic by running the 'podman stats' command with appropriate arguments and returning the JSON-formatted output or error message.
    async def container_stats(self, args: Dict[str, Any]) -> Dict[str, Any]:
        container = args.get("container")
        no_stream = args.get("no_stream", True)
        cmd_args = ["stats", "--format", "json"]
        if no_stream:
            cmd_args.append("--no-stream")
        if container:
            cmd_args.append(container)
        result = run_podman(cmd_args)
        return {"output": result["stdout"] if result["success"] else f"Error: {result['stderr']}"}
  • The input schema for the container_stats tool, defining optional 'container' parameter (string) and 'no_stream' parameter (boolean, default true).
    inputSchema={
        "type": "object",
        "properties": {
            "container": {
                "type": "string",
                "description": "Container name or ID (all containers if not specified)"
            },
            "no_stream": {
                "type": "boolean",
                "description": "Disable streaming stats and only pull the first result",
                "default": True
            }
        }
    }
  • main_b.py:370-387 (registration)
    Registration of the container_stats tool in the server's tools list, including name, description, and input schema.
    Tool(
        name="container_stats",
        description="Get resource usage statistics for containers",
        inputSchema={
            "type": "object",
            "properties": {
                "container": {
                    "type": "string",
                    "description": "Container name or ID (all containers if not specified)"
                },
                "no_stream": {
                    "type": "boolean",
                    "description": "Disable streaming stats and only pull the first result",
                    "default": True
                }
            }
        }
    )
  • main_b.py:471-472 (registration)
    Mapping the 'container_stats' tool name to its handler method in the tool_handlers dictionary used in handle_tools_call.
        "container_stats": self.container_stats,
    }
  • main.py:444-454 (handler)
    Alternative synchronous handler for container_stats using @mcp.tool decorator, which also implies schema from Field annotations and auto-registration.
    def container_stats(
        container: str = Field(None, description="Container name or ID (all containers if not specified)"),
        no_stream: bool = Field(True, description="Disable streaming stats and only pull the first result")
    ) -> str:
        args = ["stats", "--format", "json"]
        if no_stream:
            args.append("--no-stream")
        if container:
            args.append(container)
        result = run_podman(args)
        return result["stdout"] if result["success"] else f"Error: {result['stderr']}"
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. It states the tool 'gets' statistics, implying a read-only operation, but doesn't clarify aspects like whether it requires specific permissions, how it handles errors, if it's rate-limited, or what the output format entails. For a tool with no annotation coverage, this leaves significant behavioral gaps unexplained.

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 directly states the tool's purpose without any unnecessary words. It's front-loaded and appropriately sized for its function, making it easy to parse quickly. Every word earns its place, resulting in a perfect score for conciseness.

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

Completeness3/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 (2 parameters, no annotations, but with an output schema), the description is minimally adequate. The output schema exists, so the description doesn't need to explain return values, but it lacks details on behavioral aspects like error handling or performance implications. With no annotations and incomplete behavioral transparency, it meets a basic threshold but has clear gaps.

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, so the schema already fully documents both parameters ('container' and 'no_stream'). The description adds no additional meaning beyond what the schema provides, such as explaining the implications of streaming vs. non-streaming or how container identification works. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 tool's purpose with a specific verb ('Get') and resource ('resource usage statistics for containers'), making it immediately understandable. It distinguishes itself from siblings like 'container_info' (general info) and 'container_logs' (logs) by focusing specifically on resource usage statistics. However, it doesn't explicitly contrast with all siblings, keeping it from a perfect score.

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 siblings like 'container_info' (which might include some stats) and 'list_containers' (for listing), there's no indication of when this tool is preferred or what its specific use cases are. The lack of any usage context or exclusions results in a minimal score.

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/kunwarmahen/podman-mcp-server'

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