Skip to main content
Glama

list_modal_volumes

Retrieve all Modal volumes in JSON format using the Modal CLI. This tool helps manage and interact with serverless cloud storage efficiently.

Instructions

List all Modal volumes using the Modal CLI with JSON output. Returns: A dictionary containing the parsed JSON output of the Modal volumes list.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_modal_volumes' tool. It executes 'modal volume list --json' using the run_modal_command helper and processes the response with handle_json_response.
    async def list_modal_volumes() -> dict[str, Any]: """ List all Modal volumes using the Modal CLI with JSON output. Returns: A dictionary containing the parsed JSON output of the Modal volumes list. """ try: result = run_modal_command(["modal", "volume", "list", "--json"]) response = handle_json_response(result, "Failed to list volumes") if response["success"]: return {"success": True, "volumes": response["data"]} return response except Exception as e: logger.error(f"Failed to list Modal volumes: {e}") raise
  • Helper function to execute Modal CLI commands via subprocess, capturing output and handling errors.
    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) }
  • Helper function to standardize responses from Modal commands by parsing JSON output from stdout and handling errors.
    def handle_json_response(result: Dict[str, Any], error_prefix: str) -> Dict[str, Any]: """ Handle JSON parsing of command output and return a standardized response. Args: result: The result from run_modal_command error_prefix: Prefix to use in error messages Returns: A dictionary with standardized success/error format """ if not result["success"]: response = {"success": False, "error": f"{error_prefix}: {result.get('error', 'Unknown error')}"} if result.get("stdout"): response["stdout"] = result["stdout"] if result.get("stderr"): response["stderr"] = result["stderr"] return response try: data = json.loads(result["stdout"]) return {"success": True, "data": data} except json.JSONDecodeError as e: response = {"success": False, "error": f"Failed to parse JSON output: {str(e)}"} if result.get("stdout"): response["stdout"] = result["stdout"] if result.get("stderr"): response["stderr"] = result["stderr"] return response

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