restart_container
Restart a Podman container to apply configuration changes, recover from issues, or refresh the container state using the container name or ID.
Instructions
Restart a container.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| container | Yes | Container name or ID |
Implementation Reference
- main_b.py:517-520 (handler)The main handler function for the restart_container tool. It extracts the container name from args, runs 'podman restart' using the run_podman helper, and returns a dictionary with the output or error message.async def restart_container(self, args: Dict[str, Any]) -> Dict[str, Any]: container = args.get("container") result = run_podman(["restart", container]) return {"output": f"Restarted container: {container}" if result["success"] else f"Error: {result['stderr']}"}
- main_b.py:230-243 (registration)Registration of the restart_container tool in the list of tools, including name, description, and input schema definition.Tool( name="restart_container", description="Restart a container", inputSchema={ "type": "object", "properties": { "container": { "type": "string", "description": "Container name or ID" } }, "required": ["container"] } ),
- main_b.py:464-464 (registration)Mapping of the tool name 'restart_container' to its handler method in the tool_handlers dictionary used in handle_tools_call."restart_container": self.restart_container,
- main.py:185-188 (handler)Alternative implementation of the restart_container tool using @mcp.tool decorator, which combines schema (via Field) and handler logic, calling podman restart.@mcp.tool(title="Restart container", description="Restart a container.") def restart_container(container: str = Field(..., description="Container name or ID")) -> str: result = run_podman(["restart", container]) return f"Restarted container: {container}" if result["success"] else f"Error: {result['stderr']}"
- main.py:186-188 (schema)Pydantic Field definition providing input schema for the container parameter in the restart_container tool.def restart_container(container: str = Field(..., description="Container name or ID")) -> str: result = run_podman(["restart", container]) return f"Restarted container: {container}" if result["success"] else f"Error: {result['stderr']}"