list_modal_volume_contents
Retrieve files and directories within a specified Modal volume by providing the volume name and optional path. Returns a JSON-formatted output of the volume's contents.
Instructions
List files and directories in a Modal volume.
Args:
volume_name: Name of the Modal volume to list contents from.
path: Path within the volume to list contents from. Defaults to root ("/").
Returns:
A dictionary containing the parsed JSON output of the volume contents.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | / | |
| volume_name | Yes |
Implementation Reference
- src/modal_mcp/server.py:113-133 (handler)The handler function for the 'list_modal_volume_contents' tool. It is registered via the @mcp.tool() decorator and implements listing volume contents using Modal CLI 'volume ls --json' command, with helper functions for command execution and JSON response handling.@mcp.tool() async def list_modal_volume_contents(volume_name: str, path: str = "/") -> dict[str, Any]: """ List files and directories in a Modal volume. Args: volume_name: Name of the Modal volume to list contents from. path: Path within the volume to list contents from. Defaults to root ("/"). Returns: A dictionary containing the parsed JSON output of the volume contents. """ try: result = run_modal_command(["modal", "volume", "ls", "--json", volume_name, path]) response = handle_json_response(result, "Failed to list volume contents") if response["success"]: return {"success": True, "contents": response["data"]} return response except Exception as e: logger.error(f"Failed to list Modal volume contents: {e}") raise