Skip to main content
Glama

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

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']}"

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