Skip to main content
Glama

put_modal_volume_file

Upload files or directories from local storage to a Modal volume for cloud deployment and serverless function execution.

Instructions

Upload a file or directory to a Modal volume.

Args:
    volume_name: Name of the Modal volume to upload to.
    local_path: Path to the local file or directory to upload.
    remote_path: Path in the volume to upload to. Defaults to root ("/").
                If ending with "/", it's treated as a directory and the file keeps its name.
    force: If True, overwrite existing files. Defaults to False.

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

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
volume_nameYes
local_pathYes
remote_pathNo/
forceNo

Implementation Reference

  • The handler function for the 'put_modal_volume_file' tool. It is decorated with @mcp.tool() for registration and implements the logic to upload a local file or directory to a Modal volume using the 'modal volume put' command via subprocess.
    @mcp.tool()
    async def put_modal_volume_file(volume_name: str, local_path: str, remote_path: str = "/", force: bool = False) -> dict[str, Any]:
        """
        Upload a file or directory to a Modal volume.
    
        Args:
            volume_name: Name of the Modal volume to upload to.
            local_path: Path to the local file or directory to upload.
            remote_path: Path in the volume to upload to. Defaults to root ("/").
                        If ending with "/", it's treated as a directory and the file keeps its name.
            force: If True, overwrite existing files. Defaults to False.
    
        Returns:
            A dictionary containing the result of the upload operation.
    
        Raises:
            Exception: If the upload operation fails for any reason.
        """
        try:
            command = ["modal", "volume", "put"]
            if force:
                command.append("-f")
            command.extend([volume_name, local_path, remote_path])
            
            result = run_modal_command(command)
            response = {
                "success": result["success"],
                "command": result["command"]
            }
            
            if not result["success"]:
                response["error"] = f"Failed to upload {local_path}: {result.get('error', 'Unknown error')}"
            else:
                response["message"] = f"Successfully uploaded {local_path} to {volume_name}:{remote_path}"
                
            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 upload to Modal volume: {e}")
            raise
  • Helper function used by the tool to execute Modal CLI commands via subprocess and standardize the output.
    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 of behavioral disclosure. It explains the upload operation, overwrite behavior via the 'force' parameter, and error handling ('Raises: Exception'), but doesn't cover aspects like authentication requirements, rate limits, or what specific data the return dictionary contains.

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 well-structured with clear sections (Args, Returns, Raises) and front-loaded purpose statement. It's appropriately sized for a 4-parameter tool, though the 'Raises' section could be more specific than 'Exception' to be fully optimal.

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 no annotations and no output schema, the description provides adequate coverage for core functionality but has gaps. It explains parameters well and mentions return type (dictionary) and error handling, but doesn't detail the dictionary structure or other behavioral aspects like side effects or prerequisites, leaving some context incomplete.

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?

The description adds significant semantic value beyond the input schema, which has 0% description coverage. It explains all four parameters clearly: volume_name identifies the target, local_path specifies the source, remote_path defines the destination with default and directory-handling rules, and force controls overwrite behavior. This fully compensates for the schema's lack of descriptions.

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 ('Upload a file or directory') and target resource ('to a Modal volume'), distinguishing it from sibling tools like get_modal_volume_file (download) or remove_modal_volume_file (delete). It uses precise terminology that matches the tool name without being tautological.

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 for uploading files to Modal volumes but doesn't explicitly state when to use this tool versus alternatives like copy_modal_volume_files or when not to use it (e.g., for downloading). It provides some context through parameter explanations but lacks explicit guidance on tool selection.

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