Skip to main content
Glama

vm_snapshot

Create snapshots of Incus virtual machines and containers to preserve their current state for backup or rollback purposes.

Instructions

Create a snapshot of a VM/container (Incus).

Args:
    vm: Name of the VM or container.
    name: Name for the snapshot (alphanumeric, hyphens, underscores).

Returns:
    Success confirmation or error message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vmYes
nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core implementation of vm_snapshot that validates inputs and executes the 'incus snapshot create' command
    async def vm_snapshot(vm: str, name: str) -> ExecResult:
        """Create a snapshot of a VM/container.
    
        Uses `incus snapshot create <vm> <name>`.
        """
        _validate_vm_name(vm)
        _validate_snapshot_name(name)
        return await _run_incus("snapshot", "create", vm, name)
  • MCP tool registration with @mcp.tool() decorator that wraps the implementation and provides user-friendly output messages
    @mcp.tool()
    async def vm_snapshot(vm: str, name: str) -> str:
        """Create a snapshot of a VM/container (Incus).
    
        Args:
            vm: Name of the VM or container.
            name: Name for the snapshot (alphanumeric, hyphens, underscores).
    
        Returns:
            Success confirmation or error message.
        """
        try:
            result = await _vm_snapshot(vm, name)
            if result.exit_code == 0:
                return f"Snapshot '{name}' created for {vm}"
            return f"ERROR creating snapshot: {result.stderr.strip()}"
        except (ValueError, RuntimeError, OSError) as e:
            return f"ERROR: {e}"
  • Validation functions for VM names and snapshot names using regex patterns to ensure safe input values
    def _validate_vm_name(name: str) -> None:
        """Validate that a VM/container name is safe."""
        if not name or not name.strip():
            raise ValueError("VM name cannot be empty")
        if not _VALID_NAME.match(name):
            raise ValueError(
                f"Invalid VM name '{name}': must start with a letter, "
                "contain only alphanumeric characters and hyphens"
            )
    
    
    def _validate_snapshot_name(name: str) -> None:
        """Validate a snapshot name."""
        if not name or not name.strip():
            raise ValueError("Snapshot name cannot be empty")
        if not re.match(r"^[a-zA-Z0-9_\-]+$", name):
            raise ValueError(
                f"Invalid snapshot name '{name}': "
                "only alphanumeric, hyphens, and underscores allowed"
            )
  • Helper function that executes incus CLI commands asynchronously, captures stdout/stderr, and returns an ExecResult with timeout handling
    async def _run_incus(
        *args: str,
        timeout: int = 120,
    ) -> ExecResult:
        """Run an incus CLI command and capture output.
    
        Args:
            *args: Arguments to pass to `incus`.
            timeout: Maximum seconds to wait.
    
        Returns:
            ExecResult with stdout, stderr, and exit code.
        """
        proc = await asyncio.create_subprocess_exec(
            "incus", *args,
            stdout=asyncio.subprocess.PIPE,
            stderr=asyncio.subprocess.PIPE,
            stdin=asyncio.subprocess.DEVNULL,
        )
    
        try:
            stdout_bytes, stderr_bytes = await asyncio.wait_for(
                proc.communicate(),
                timeout=timeout,
            )
        except asyncio.TimeoutError:
            proc.kill()
            await proc.wait()
            raise TimeoutError(
                f"incus command timed out after {timeout}s: incus {' '.join(args)}"
            )
    
        return ExecResult(
            stdout=stdout_bytes.decode("utf-8", errors="replace"),
            stderr=stderr_bytes.decode("utf-8", errors="replace"),
            exit_code=proc.returncode or 0,
        )
  • Dataclass that represents the result of executing a CLI command with stdout, stderr, and exit_code fields
    @dataclass
    class ExecResult:
        """Result of running a CLI command."""
    
        stdout: str
        stderr: str
        exit_code: int
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the action ('Create a snapshot') but doesn't describe important behavioral traits like whether this operation is reversible, what permissions are required, whether it affects VM availability during snapshot creation, or any rate limits. The return statement is minimal.

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

Conciseness4/5

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

The description is appropriately sized and well-structured with clear sections for Args and Returns. Each sentence earns its place by providing essential information. It could be slightly more concise by integrating the format guidance more smoothly.

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

Completeness3/5

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

Given the tool's complexity (mutating operation with no annotations) and the presence of an output schema, the description is moderately complete. It covers purpose and parameters adequately but lacks behavioral context about the mutation's impact. The output schema existence reduces the need to detail return values, but more operational context would be helpful.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate for the schema's lack of parameter documentation. It provides meaningful context for both parameters: 'vm' is explained as 'Name of the VM or container' and 'name' gets format guidance ('alphanumeric, hyphens, underscores'). This adds substantial value beyond the bare schema.

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 specific action ('Create a snapshot') and resource ('of a VM/container (Incus)'), distinguishing it from siblings like vm_restore (which restores snapshots) or vm_exec (which executes commands). It provides a complete, unambiguous purpose statement.

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 usage when snapshot creation is needed, but doesn't explicitly state when to use this tool versus alternatives like vm_restore or other VM management tools. No guidance on prerequisites, timing, or exclusions is provided.

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/bobbyhiddn/Sympathy-MCP'

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