Skip to main content
Glama

copy_modal_volume_files

Copy files within a Modal volume, moving source files to a destination file or directory for file management in serverless cloud environments.

Instructions

Copy files within a Modal volume. Can copy a source file to a destination file
or multiple source files to a destination directory.

Args:
    volume_name: Name of the Modal volume to perform copy operation in.
    paths: List of paths for the copy operation. The last path is the destination,
          all others are sources. For example: ["source1.txt", "source2.txt", "dest_dir/"]

Returns:
    A dictionary containing the result of the copy operation.

Raises:
    Exception: If the copy operation fails for any reason.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
volume_nameYes
pathsYes

Implementation Reference

  • The handler function for the 'copy_modal_volume_files' tool, decorated with @mcp.tool() for registration. It validates input, runs 'modal volume cp' via run_modal_command helper, and formats the response.
    @mcp.tool()
    async def copy_modal_volume_files(volume_name: str, paths: List[str]) -> dict[str, Any]:
        """
        Copy files within a Modal volume. Can copy a source file to a destination file
        or multiple source files to a destination directory.
    
        Args:
            volume_name: Name of the Modal volume to perform copy operation in.
            paths: List of paths for the copy operation. The last path is the destination,
                  all others are sources. For example: ["source1.txt", "source2.txt", "dest_dir/"]
    
        Returns:
            A dictionary containing the result of the copy operation.
    
        Raises:
            Exception: If the copy operation fails for any reason.
        """
        if len(paths) < 2:
            return {
                "success": False,
                "error": "At least one source and one destination path are required"
            }
    
        try:
            result = run_modal_command(["modal", "volume", "cp", volume_name] + paths)
            response = {
                "success": result["success"],
                "command": result["command"]
            }
            
            if not result["success"]:
                response["error"] = f"Failed to copy files: {result.get('error', 'Unknown error')}"
            else:
                response["message"] = f"Successfully copied files in volume {volume_name}"
                
            if result.get("stdout"):
                response["stdout"] = result["stdout"]
            if result.get("stderr"):
                response["stderr"] = result["stderr"]
                
            return response
        except Exception as e:
            logger.error(f"Failed to copy files in Modal volume: {e}")
            raise
  • Shared helper function that executes Modal CLI commands using subprocess and returns structured success/error results with stdout/stderr.
    def run_modal_command(command: list[str], uv_directory: str = None) -> dict[str, Any]:
        """Run a Modal CLI command and return the result"""
        try:
            # uv_directory is necessary for modal deploy, since deploying the app requires the app to use the uv venv
            command = (["uv", "run", f"--directory={uv_directory}"] if uv_directory else []) + command
            logger.info(f"Running command: {' '.join(command)}")
            result = subprocess.run(
                command,
                capture_output=True,
                text=True,
                check=True
            )
            return {
                "success": True,
                "stdout": result.stdout,
                "stderr": result.stderr,
                "command": ' '.join(command)
            }
        except subprocess.CalledProcessError as e:
            return {
                "success": False,
                "error": str(e),
                "stdout": e.stdout,
                "stderr": e.stderr,
                "command": ' '.join(command)
            }
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the operation type (copy) and mentions failure cases ('Raises: Exception'), but doesn't cover permissions needed, rate limits, or what happens with existing destination files. It adds some context but lacks comprehensive behavioral details.

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 well-structured with clear sections (Args, Returns, Raises), front-loaded purpose statement, and no wasted sentences. Each part earns its place by providing essential information efficiently.

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 2 parameters with 0% schema coverage and no output schema, the description does well by fully explaining parameters and return format. However, as a mutation tool with no annotations, it could better cover behavioral aspects like idempotency or error specifics for completeness.

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 description coverage is 0%, so the description must compensate. It fully explains both parameters: 'volume_name' as the Modal volume name, and 'paths' with detailed semantics including source/destination roles and an example. This adds significant 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 verb ('Copy files') and resource ('within a Modal volume'), specifying it can copy single files or multiple files to directories. It distinguishes from siblings like 'get_modal_volume_file' (read) and 'put_modal_volume_file' (upload).

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

Usage Guidelines4/5

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

The description implies usage for copying files within a Modal volume, but doesn't explicitly state when to use this vs. alternatives like 'put_modal_volume_file' for uploading external files or 'remove_modal_volume_file' for deletion. It provides clear context but lacks explicit exclusions.

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/smehmood/modal-mcp-server'

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