Skip to main content
Glama

set_vm_shares

Replace all shared directories on a stopped VM by specifying a list of host paths. Clears shares if list is empty. Use for bulk configuration; for incremental changes see add/remove tools.

Instructions

Replace all shared directories on a VM.

Overwrites the entire share list. Use add_vm_share/remove_vm_share for incremental changes.

Args: name: VM name (must be stopped) paths: List of host directory paths to share (empty list clears all)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
pathsYes

Implementation Reference

  • MCP tool handler for set_vm_shares – registered via @mcp.tool() decorator, delegates to utm.set_vm_shares() in applescript module.
    @mcp.tool()
    def set_vm_shares(name: str, paths: list[str]) -> dict:
        """Replace all shared directories on a VM.
    
        Overwrites the entire share list. Use add_vm_share/remove_vm_share
        for incremental changes.
    
        Args:
            name: VM name (must be stopped)
            paths: List of host directory paths to share (empty list clears all)
        """
        shares = utm.set_vm_shares(name, paths)
        return {"name": name, "shares": shares}
  • Core AppleScript implementation of set_vm_shares – replaces all shared directories for a VM by updating its registry via osascript, then returns the current share list.
    def set_vm_shares(name: str, paths: list[str]) -> list[str]:
        """Replace all shared directories for a VM."""
        _validate_vm_name(name)
        for p in paths:
            _validate_path(p)
    
        if not paths:
            script = f'''
            tell application "UTM"
                set vm to virtual machine named "{_esc(name)}"
                update registry of vm with {{}}
            end tell
            '''
        else:
            share_items = ", ".join(f'POSIX file "{_esc(p)}"' for p in paths)
            script = f'''
            tell application "UTM"
                set vm to virtual machine named "{_esc(name)}"
                update registry of vm with {{{share_items}}}
            end tell
            '''
        _run(script)
        return list_vm_shares(name)
  • Path validation helper used by set_vm_shares to ensure paths are absolute and prevent traversal.
    def _validate_path(path: str) -> str:
        if not path.startswith("/"):
            raise ValueError(f"Path must be absolute: {path!r}")
        if ".." in path.split("/"):
            raise ValueError(f"Path traversal not allowed: {path!r}")
        return path
  • VM name validation helper used by set_vm_shares to ensure the VM name is valid.
    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
  • Test confirming set_vm_shares is registered as an MCP tool by checking the tool manager's list of tools.
    def test_expected_tools(self):
        names = {t.name for t in mcp._tool_manager.list_tools()}
        expected = {
            "list_vms", "get_vm", "clone_vm", "start_vm", "stop_vm", "delete_vm",
            "suspend_vm", "wait_for_vm", "get_vm_ip", "set_vm_network",
            "set_vm_resources", "rename_vm", "set_vm_display", "list_vm_shares",
            "add_vm_share", "remove_vm_share", "set_vm_shares", "list_vm_drives",
            "attach_drive", "export_vm", "import_vm", "get_serial_port",
        }
        assert expected == names
Behavior5/5

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

Discloses that it overwrites the entire share list, clearing all if paths is empty, and requires the VM to be stopped. With no annotations, the description fully conveys behavioral traits.

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?

Three sentences plus an Args list; no wasted words, front-loaded with main purpose.

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?

Complete for a simple tool: covers purpose, usage, parameters, and preconditions. Lacks error details, but sufficient given no output schema.

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?

Schema coverage is 0%, but the description adds detailed semantics: name must be a stopped VM, paths is a list of host directory paths, and empty list clears all shares.

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 'Replace all shared directories on a VM', specifying a specific verb and resource. It also explicitly differentiates from siblings by mentioning use add_vm_share/remove_vm_share for incremental changes.

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

Usage Guidelines5/5

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

Provides explicit guidance: overwrites entire share list, suggests alternative tools for incremental changes, and states that the VM must be stopped.

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