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
| Name | Required | Description | Default |
|---|---|---|---|
| absolute_path_to_app | Yes |
Implementation Reference
- src/modal_mcp/server.py:72-94 (handler)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
- src/modal_mcp/server.py:15-41 (helper)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) }