Skip to main content
Glama

get_modal_volume_file

Download files from Modal volumes to local systems or stdout for data access and transfer.

Instructions

Download files from a Modal volume.

Args:
    volume_name: Name of the Modal volume to download from.
    remote_path: Path to the file or directory in the volume to download.
    local_destination: Local path to save the downloaded file(s). Defaults to current directory.
                     Use "-" to write file contents to stdout.
    force: If True, overwrite existing files. Defaults to False.

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
volume_nameYes
remote_pathYes
local_destinationNo.
forceNo

Implementation Reference

  • The primary handler function for the 'get_modal_volume_file' tool. It constructs and executes the 'modal volume get' command to download files or directories from a Modal volume to a local destination, handling success/error responses and logging.
    @mcp.tool()
    async def get_modal_volume_file(volume_name: str, remote_path: str, local_destination: str = ".", force: bool = False) -> dict[str, Any]:
        """
        Download files from a Modal volume.
    
        Args:
            volume_name: Name of the Modal volume to download from.
            remote_path: Path to the file or directory in the volume to download.
            local_destination: Local path to save the downloaded file(s). Defaults to current directory.
                             Use "-" to write file contents to stdout.
            force: If True, overwrite existing files. Defaults to False.
    
        Returns:
            A dictionary containing the result of the download operation.
    
        Raises:
            Exception: If the download operation fails for any reason.
        """
        try:
            command = ["modal", "volume", "get"]
            if force:
                command.append("--force")
            command.extend([volume_name, remote_path, local_destination])
            
            result = run_modal_command(command)
            response = {
                "success": result["success"],
                "command": result["command"]
            }
            
            if not result["success"]:
                response["error"] = f"Failed to download {remote_path}: {result.get('error', 'Unknown error')}"
            else:
                response["message"] = f"Successfully downloaded {remote_path} from 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 download from Modal volume: {e}")
            raise
  • The @mcp.tool() decorator registers the get_modal_volume_file function as an available MCP tool in the FastMCP server.
    @mcp.tool()
  • Helper function used by get_modal_volume_file to execute Modal CLI commands via subprocess, capturing output and standardizing success/error responses.
    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 the full burden. It discloses key behavioral traits: it's a download operation (implies read-only but not explicitly stated), can overwrite files with 'force', supports stdout output, and may raise exceptions on failure. However, it doesn't mention rate limits, authentication needs, or detailed error handling beyond generic exceptions.

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 and front-loaded with the core purpose. Each sentence earns its place: the opening statement sets context, the Args section details parameters efficiently, and the Returns/Raises sections provide necessary completion info without redundancy. No wasted words.

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 annotations and no output schema, the description does a good job covering the tool's complexity. It explains parameters thoroughly, hints at behavior (overwrite, stdout), and mentions error handling. However, it could be more complete by explicitly stating read-only nature or contrasting with upload/list siblings more directly.

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 fully. It provides detailed semantics for all 4 parameters: explains what 'volume_name' and 'remote_path' are, clarifies 'local_destination' defaults and special case ('-'), and defines 'force' behavior. 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 specific action ('Download files from a Modal volume') and distinguishes it from siblings like 'list_modal_volume_contents' (which lists contents) and 'put_modal_volume_file' (which uploads). It specifies the resource (Modal volume) and verb (download) precisely.

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 context by mentioning downloading from a volume, but does not explicitly state when to use this tool versus alternatives like 'copy_modal_volume_files' or 'list_modal_volume_contents'. It provides clear parameter defaults and behavior hints (e.g., using '-' for stdout), but lacks explicit sibling differentiation.

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