Skip to main content
Glama

set_vm_shares

Replace all shared directories on a stopped VM. Provide a list of host paths to share; an empty list clears all shares.

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

  • Core handler that replaces all shared directories for a VM via AppleScript. Validates inputs, constructs AppleScript to update the registry, and returns the updated 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)
  • MCP tool registration (via @mcp.tool() decorator) for set_vm_shares. Delegates to utm.set_vm_shares (applescript module) and returns structured dict result.
    @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}
  • Path validation helper called by set_vm_shares to ensure each path is absolute and contains no path 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
  • Test confirming set_vm_shares is registered as an MCP tool with the expected name.
    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
Behavior4/5

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

Discloses overwrites entire share list and VM must be stopped, though no annotations exist; could mention safety/reversibility but adequate.

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 short sentences plus concise args, front-loaded with main action, no fluff.

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?

Covers behavior, prerequisites, and alternatives; lacks return value description and path format details, but sufficient for this tool.

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?

Provides meaning for both parameters beyond schema: name (VM name, must be stopped) and paths (list of host paths, empty clears all).

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?

States 'Replace all shared directories on a VM' with clear verb and resource, and distinguishes from siblings add_vm_share/remove_vm_share.

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?

Explicitly says to use add_vm_share/remove_vm_share for incremental changes, and notes 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