Skip to main content
Glama
milkymap

MCP4Modal Sandbox

by milkymap

remove_path

Remove files or directories from a Modal sandbox environment to clean up temporary data, manage storage, and delete unwanted content.

Instructions

Removes a file or directory from the sandbox. Parameters: - sandbox_id: The unique identifier of the sandbox - path: Path to remove from the sandbox - recursive: Whether to remove the path recursively Returns a SandboxRemovePathResponse containing: - success: Boolean indicating if removal was successful - message: Descriptive message about the operation - path_removed: The path that was removed This tool is useful for: - Cleaning up temporary files - Removing unwanted content - Managing sandbox storage The tool will: 1. Verify sandbox exists and is running 2. Remove specified path (file or directory) 3. Return status of the operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sandbox_idYes
pathYes
recursiveNo

Implementation Reference

  • The core handler function that executes the tool logic: fetches the sandbox, calls modal_sandbox.rm.aio to remove the path (recursively if specified), logs the action, and returns a SandboxRemovePathResponse.
    async def remove_path(self, sandbox_id: str, path: str, recursive: bool = False) -> SandboxRemovePathResponse: # Get sandbox from Modal using from_id modal_sandbox = await modal.Sandbox.from_id.aio(sandbox_id) await modal_sandbox.rm.aio(path, recursive=recursive) logger.info(f"Removed path {path} in sandbox {sandbox_id}") return SandboxRemovePathResponse( success=True, message=f"Path {path} removed successfully", path_removed=path, )
  • Registers the 'remove_path' tool with the FastMCP server, linking it to the handler method and providing the description.
    mcp_app.tool( name="remove_path", description=ToolDescriptions.REMOVE_PATH, )(self.remove_path)
  • Pydantic model defining the structure of the tool's response, used for output validation.
    class SandboxRemovePathResponse(BaseModel): success: bool message: str path_removed: str
  • Tool description string used in registration, detailing parameters, returns, and usage.
    REMOVE_PATH = """ Removes a file or directory from the sandbox. Parameters: - sandbox_id: The unique identifier of the sandbox - path: Path to remove from the sandbox - recursive: Whether to remove the path recursively Returns a SandboxRemovePathResponse containing: - success: Boolean indicating if removal was successful - message: Descriptive message about the operation - path_removed: The path that was removed This tool is useful for: - Cleaning up temporary files - Removing unwanted content - Managing sandbox storage The tool will: 1. Verify sandbox exists and is running 2. Remove specified path (file or directory) 3. Return status of the operation """

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/milkymap/mcp4modal_sandbox'

If you have feedback or need assistance with the MCP directory API, please join our Discord server