Skip to main content
Glama

set_vm_resources

Update memory and CPU cores of a stopped virtual machine. Requires the VM name; optionally set memory in MiB or CPU core count.

Instructions

Update memory and CPU cores of a stopped VM.

Args: name: VM name (must be stopped) memory: Memory in MiB, or None to keep current cpu_cores: Number of CPU cores, or None to keep current

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
memoryNo
cpu_coresNo

Implementation Reference

  • The @mcp.tool() decorator registers 'set_vm_resources' as an MCP tool. The function delegates to applescript.set_vm_resources and returns the config as dict.
    @mcp.tool()
    def set_vm_resources(
        name: str,
        memory: int | None = None,
        cpu_cores: int | None = None,
    ) -> dict:
        """Update memory and CPU cores of a stopped VM.
    
        Args:
            name: VM name (must be stopped)
            memory: Memory in MiB, or None to keep current
            cpu_cores: Number of CPU cores, or None to keep current
        """
        config = utm.set_vm_resources(name, memory=memory, cpu_cores=cpu_cores)
        return config.to_dict()
  • Core implementation: validates name, validates memory (64–1048576 MiB) and cpu_cores (1–256), builds AppleScript to update the VM configuration via UTM's scripting API, and returns a VMConfig dataclass.
    def set_vm_resources(name: str, memory: int | None = None, cpu_cores: int | None = None) -> VMConfig:
        """Update memory and/or CPU cores of a stopped VM."""
        _validate_vm_name(name)
        parts = []
        if memory is not None:
            memory = int(memory)
            if memory < 64 or memory > _MAX_MEMORY_MIB:
                raise ValueError(f"Memory must be 64–{_MAX_MEMORY_MIB} MiB, got {memory}")
            parts.append(f"set memory of conf to {memory}")
        if cpu_cores is not None:
            cpu_cores = int(cpu_cores)
            if cpu_cores < 1 or cpu_cores > _MAX_CPU_CORES:
                raise ValueError(f"CPU cores must be 1–{_MAX_CPU_CORES}, got {cpu_cores}")
            parts.append(f"set cpu cores of conf to {cpu_cores}")
        if not parts:
            return get_vm_config(name)
    
        updates = "\n            ".join(parts)
        script = f'''
        tell application "UTM"
            set vm to virtual machine named "{_esc(name)}"
            set conf to configuration of vm
            {updates}
            update configuration of vm with conf
        end tell
        '''
        _run(script)
        return get_vm_config(name)
  • VMConfig dataclass defines the output shape (name, memory, cpu_cores, mac_address, network_mode) returned by set_vm_resources.
    @dataclass
    class VMConfig:
        name: str
        memory: int  # MiB
        cpu_cores: int
        mac_address: str
        network_mode: str
    
        def to_dict(self) -> dict:
            return {
                "name": self.name,
                "memory": self.memory,
                "cpu_cores": self.cpu_cores,
                "mac_address": self.mac_address,
                "network_mode": self.network_mode,
            }
  • Validation constants used by set_vm_resources: _MAX_MEMORY_MIB (1048576) and _MAX_CPU_CORES (256).
    _MAX_MEMORY_MIB = 1048576  # 1 TiB
    _MAX_CPU_CORES = 256
  • Name validation helper called at the start of set_vm_resources.
    def _validate_vm_name(name: str) -> str:
        if not name or not _VM_NAME_RE.match(name):
            raise ValueError(f"Invalid VM name: {name!r} — only word characters, spaces, hyphens, and dots allowed")
        return name
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses a behavioral prerequisite (VM must be stopped) and notes that parameters can be None to keep current values, but lacks details on destructiveness, error states, or authorization needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: a single-line purpose followed by clear parameter descriptions. Every sentence serves a purpose with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema and no annotations, the description covers the parameters comprehensively and states the prerequisite. It is nearly complete for this simple mutation tool, though it lacks details on return values or error handling, which is a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant value beyond the input schema by specifying units (MiB for memory), the behavior of None ('keep current'), and a prerequisite ('must be stopped') for the name parameter. With 0% schema description coverage, this fully compensates.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Update' and the resource 'stopped VM', specifying exactly what is being updated (memory and CPU cores). It effectively distinguishes itself from sibling tools like set_vm_display or set_vm_network.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies the VM must be stopped for usage via the arg hint, but it does not explicitly state when to use this tool versus alternatives like set_vm_display, nor does it provide exclusions or alternative tool pointers.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/neverprepared/mcp-utm'

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