Skip to main content
Glama

deploy_modal_app

Deploy a Modal application by providing the absolute path, enabling AI agents to run serverless cloud functions. Returns deployment results or raises an exception if errors occur.

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 handler function for the 'deploy_modal_app' MCP tool. Decorated with @mcp.tool() for automatic registration. Extracts app directory and name from the absolute path, then invokes 'modal deploy' via the run_modal_command helper, returning the command result.
    @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 that executes Modal CLI commands via subprocess.run, optionally prefixing with 'uv run --directory' for virtual environment support. Handles success/error cases and returns structured dict with stdout/stderr/command.
    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) }
  • The @mcp.tool() decorator registers the deploy_modal_app function as an MCP tool in the FastMCP server instance.
    @mcp.tool()
  • Function signature with type annotations defining input (str absolute_path_to_app) and output (dict[str, Any]), along with comprehensive docstring specifying args, returns, and raises for schema validation.
    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.

Other Tools

Related 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