create_proxmox_lxc
Create new LXC containers on Proxmox for homelab infrastructure management, specifying node, container ID, hostname, and resource configurations.
Instructions
Create a new LXC container on Proxmox
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| node | Yes | Node name | |
| vmid | Yes | Container ID (must be unique) | |
| hostname | Yes | Container hostname | |
| ostemplate | No | Template (e.g., 'local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst') | local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst |
| storage | No | Storage for rootfs | local-lvm |
| memory | No | RAM in MB | |
| cores | No | Number of CPU cores | |
| rootfs_size | No | Root filesystem size in GB | |
| password | No | Root password | |
| start | No | Start container after creation | |
| host | No | Proxmox host (optional) |
Implementation Reference
- MCP tool handler that receives arguments from the tool request and calls the create_proxmox_lxc API function with proper parameter extraction and JSON response formatting
async def handle_create_proxmox_lxc(arguments: dict[str, Any]) -> dict[str, Any]: """Handle create_proxmox_lxc tool.""" result = await create_proxmox_lxc( node=arguments["node"], vmid=arguments["vmid"], hostname=arguments["hostname"], host=arguments.get("host"), ostemplate=arguments.get("ostemplate", "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst"), storage=arguments.get("storage", "local-lvm"), memory=arguments.get("memory", 512), cores=arguments.get("cores", 1), rootfs_size=arguments.get("rootfs_size", 8), password=arguments.get("password"), start=arguments.get("start", False), ) return {"content": [{"type": "text", "text": json.dumps(result, indent=2)}]} - src/homelab_mcp/proxmox_api.py:369-450 (handler)Core implementation function that creates a Proxmox LXC container by building configuration, making POST request to Proxmox API at /nodes/{node}/lxc endpoint, and returning formatted result
async def create_proxmox_lxc( node: str, vmid: int, hostname: str, host: str | None = None, ostemplate: str = "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst", storage: str = "local-lvm", memory: int = 512, swap: int = 512, cores: int = 1, rootfs_size: int = 8, password: str | None = None, ssh_public_keys: str | None = None, unprivileged: bool = True, start: bool = False, **kwargs: Any, ) -> dict[str, Any]: """ Create a new LXC container. Args: node: Node name vmid: Container ID hostname: Container hostname host: Proxmox host (optional) ostemplate: Template to use storage: Storage for rootfs memory: RAM in MB swap: Swap in MB cores: Number of CPU cores rootfs_size: Root filesystem size in GB password: Root password ssh_public_keys: SSH public keys unprivileged: Create unprivileged container start: Start after creation **kwargs: Additional LXC parameters Returns: Creation result """ client = get_proxmox_client(host=host) try: # Build container config config: dict[str, Any] = { "vmid": vmid, "hostname": hostname, "ostemplate": ostemplate, "storage": storage, "memory": memory, "swap": swap, "cores": cores, "rootfs": f"{storage}:{rootfs_size}", "unprivileged": 1 if unprivileged else 0, "start": 1 if start else 0, } if password: config["password"] = password if ssh_public_keys: config["ssh-public-keys"] = ssh_public_keys # Add any additional parameters config.update(kwargs) result = await client.post(f"/nodes/{node}/lxc", config) return { "status": "success", "node": node, "vmid": vmid, "hostname": hostname, "message": f"LXC container {vmid} created successfully", "data": result, } except (aiohttp.ClientError, ValueError) as e: logger.error("Error creating LXC container: %s", str(e)) return { "status": "error", "message": f"Failed to create LXC container: {str(e)}", } - Input schema definition for create_proxmox_lxc tool, specifying required parameters (node, vmid, hostname) and optional parameters (ostemplate, storage, memory, cores, rootfs_size, password, start, host) with their types and defaults
"create_proxmox_lxc": { "description": "Create a new LXC container on Proxmox", "inputSchema": { "type": "object", "properties": { "node": { "type": "string", "description": "Node name", }, "vmid": { "type": "integer", "description": "Container ID (must be unique)", }, "hostname": { "type": "string", "description": "Container hostname", }, "ostemplate": { "type": "string", "description": "Template (e.g., 'local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst')", "default": "local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst", }, "storage": { "type": "string", "description": "Storage for rootfs", "default": "local-lvm", }, "memory": { "type": "integer", "description": "RAM in MB", "default": 512, }, "cores": { "type": "integer", "description": "Number of CPU cores", "default": 1, }, "rootfs_size": { "type": "integer", "description": "Root filesystem size in GB", "default": 8, }, "password": { "type": "string", "description": "Root password", }, "start": { "type": "boolean", "description": "Start container after creation", "default": False, }, "host": { "type": "string", "description": "Proxmox host (optional)", }, }, "required": ["node", "vmid", "hostname"], }, }, - src/homelab_mcp/tool_handlers/__init__.py:29-40 (registration)Import statement for handle_create_proxmox_lxc handler function
from .proxmox_handlers import ( handle_clone_proxmox_vm, handle_create_proxmox_lxc, handle_create_proxmox_vm, handle_delete_proxmox_vm, handle_get_proxmox_node_status, handle_get_proxmox_script_info, handle_get_proxmox_vm_status, handle_list_proxmox_resources, handle_manage_proxmox_vm, handle_search_proxmox_scripts, ) - src/homelab_mcp/tool_handlers/__init__.py:127-127 (registration)Registration mapping the tool name 'create_proxmox_lxc' to its handler function in the TOOL_HANDLERS dictionary
"create_proxmox_lxc": handle_create_proxmox_lxc,