Skip to main content
Glama
milkymap

MCP4Modal Sandbox

by milkymap

make_directory

Create directories in Modal sandbox environments to organize files and prepare for operations. Specify path and optional parent directory creation.

Instructions

Creates a new directory in the sandbox. Parameters: - sandbox_id: The unique identifier of the sandbox - path: Directory path to create in the sandbox - parents: Whether to create parent directories if they don't exist Returns a SandboxMakeDirectoryResponse containing: - success: Boolean indicating if directory creation was successful - message: Descriptive message about the operation - path_created: The path that was created This tool is useful for: - Setting up directory structures - Preparing for file operations - Organizing sandbox content The tool will: 1. Verify sandbox exists and is running 2. Create directory at specified path 3. Return status of the operation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sandbox_idYes
pathYes
parentsNo

Implementation Reference

  • The asynchronous handler function that executes the make_directory tool logic: fetches the sandbox, checks if running, creates directory using modal_sandbox.mkdir.aio(), logs, and returns success response.
    async def make_directory(self, sandbox_id: str, path: str, parents: bool = False) -> SandboxMakeDirectoryResponse: # Get sandbox from Modal using from_id modal_sandbox = await modal.Sandbox.from_id.aio(sandbox_id) # Check if sandbox is running before creating directory sandbox_status = await modal_sandbox.poll.aio() if sandbox_status is not None: raise ToolError(f"Sandbox {sandbox_id} is not running") await modal_sandbox.mkdir.aio(path, parents=parents) logger.info(f"Created directory {path} in sandbox {sandbox_id}") return SandboxMakeDirectoryResponse( success=True, message=f"Directory {path} created successfully", path_created=path, )
  • Registration of the make_directory tool using FastMCP's mcp_app.tool decorator, specifying name, description from ToolDescriptions, bound to self.make_directory method.
    mcp_app.tool( name="make_directory", description=ToolDescriptions.MAKE_DIRECTORY, )(self.make_directory)
  • Pydantic BaseModel defining the output schema/response structure for the make_directory tool.
    class SandboxMakeDirectoryResponse(BaseModel): success: bool message: str path_created: str
  • Tool description string defining input parameters, output, and usage for the make_directory tool, used in registration.
    MAKE_DIRECTORY = """ Creates a new directory in the sandbox. Parameters: - sandbox_id: The unique identifier of the sandbox - path: Directory path to create in the sandbox - parents: Whether to create parent directories if they don't exist Returns a SandboxMakeDirectoryResponse containing: - success: Boolean indicating if directory creation was successful - message: Descriptive message about the operation - path_created: The path that was created This tool is useful for: - Setting up directory structures - Preparing for file operations - Organizing sandbox content The tool will: 1. Verify sandbox exists and is running 2. Create directory at specified path 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