Skip to main content
Glama

deploy_modal_app

Deploy Modal applications to a serverless cloud environment by specifying the absolute path to your app files.

Instructions

Deploy a Modal application using the provided parameters.

Args:
    absolute_path_to_app: The absolute path to the Modal application to deploy.

Returns:
    A dictionary containing deployment results.

Raises:
    Exception: If deployment fails for any reason.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
absolute_path_to_appYes

Implementation Reference

  • The main asynchronous handler function for the deploy_modal_app tool. It is registered via the @mcp.tool() decorator and implements the deployment logic by calling run_modal_command to execute 'modal deploy' on the specified app path.
    @mcp.tool()
    async def deploy_modal_app(absolute_path_to_app: str) -> dict[str, Any]:
        """
        Deploy a Modal application using the provided parameters.
    
        Args:
            absolute_path_to_app: The absolute path to the Modal application to deploy.
    
        Returns:
            A dictionary containing deployment results.
    
        Raises:
            Exception: If deployment fails for any reason.
        """
        uv_directory = os.path.dirname(absolute_path_to_app)
        app_name = os.path.basename(absolute_path_to_app)
        try:
            result = run_modal_command(["modal", "deploy", app_name], uv_directory)
            return result
        except Exception as e:
            logger.error(f"Failed to deploy Modal app: {e}")
            raise
  • Supporting utility function used by deploy_modal_app to run Modal CLI commands via subprocess, handling uv run if directory provided, and returning structured success/error results.
    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)
            }

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