Skip to main content
Glama
washyu
by washyu

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
NameRequiredDescriptionDefault
nodeYesNode name
vmidYesContainer ID (must be unique)
hostnameYesContainer hostname
ostemplateNoTemplate (e.g., 'local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst')local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst
storageNoStorage for rootfslocal-lvm
memoryNoRAM in MB
coresNoNumber of CPU cores
rootfs_sizeNoRoot filesystem size in GB
passwordNoRoot password
startNoStart container after creation
hostNoProxmox 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)}]}
  • 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"],
        },
    },
  • 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,
    )
  • Registration mapping the tool name 'create_proxmox_lxc' to its handler function in the TOOL_HANDLERS dictionary
    "create_proxmox_lxc": handle_create_proxmox_lxc,

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/washyu/mcp_python_server'

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