Skip to main content
Glama

start_container

Start a stopped container to resume its operations. Specify the container name or ID to initiate the container lifecycle process.

Instructions

Start a stopped container.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
containerYesContainer name or ID

Implementation Reference

  • The primary handler function for the 'start_container' tool. It extracts the container name from arguments, runs 'podman start' via the run_podman helper, and returns a success or error message.
    async def start_container(self, args: Dict[str, Any]) -> Dict[str, Any]:
        container = args.get("container")
        result = run_podman(["start", container])
        return {"output": f"Started container: {container}" if result["success"] else f"Error: {result['stderr']}"}
  • JSON schema definition for the 'start_container' tool input, specifying the required 'container' string parameter.
    Tool(
        name="start_container",
        description="Start a stopped container",
        inputSchema={
            "type": "object",
            "properties": {
                "container": {
                    "type": "string",
                    "description": "Container name or ID"
                }
            },
            "required": ["container"]
        }
    ),
  • main_b.py:459-472 (registration)
    Registration of tool handlers in a dictionary used in handle_tools_call to map 'start_container' to its handler method.
    tool_handlers = {
        "list_containers": self.list_containers,
        "container_info": self.container_info,
        "start_container": self.start_container,
        "stop_container": self.stop_container,
        "restart_container": self.restart_container,
        "container_logs": self.container_logs,
        "run_container": self.run_container,
        "remove_container": self.remove_container,
        "exec_container": self.exec_container,
        "list_images": self.list_images,
        "pull_image": self.pull_image,
        "container_stats": self.container_stats,
    }
  • main.py:170-173 (handler)
    Alternative handler for 'start_container' using FastMCP decorator, which also serves as registration and schema via Pydantic Field.
    @mcp.tool(title="Start container", description="Start a stopped container.")
    def start_container(container: str = Field(..., description="Container name or ID")) -> str:
        result = run_podman(["start", container])
        return f"Started container: {container}" if result["success"] else f"Error: {result['stderr']}"
  • Shared helper function that executes podman subprocess commands and returns structured results, used by the start_container handler.
    def run_podman(args: List[str]) -> Dict[str, Any]:
        """Run a podman command and capture output"""
        try:
            cmd = ["podman"] + args
            logger.info(f"Running command: {' '.join(cmd)}")
            result = subprocess.run(
                cmd,
                capture_output=True,
                text=True,
                timeout=30
            )
            return {
                "success": result.returncode == 0,
                "stdout": result.stdout.strip(),
                "stderr": result.stderr.strip(),
                "returncode": result.returncode,
            }
        except subprocess.TimeoutExpired:
            logger.error("Command timed out")
            return {"success": False, "stdout": "", "stderr": "Command timed out", "returncode": -1}
        except Exception as e:
            logger.error(f"Command error: {e}")
            return {"success": False, "stdout": "", "stderr": str(e), "returncode": -1}

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