Skip to main content
Glama
milkymap

MCP4Modal Sandbox

by milkymap

make_directory

Create directories in the MCP4Modal Sandbox to organize files and prepare for operations by specifying paths and optional parent directories.

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

  • Registers the 'make_directory' tool using mcp_app.tool decorator with name, description from ToolDescriptions, bound to the make_directory method.
    mcp_app.tool( name="make_directory", description=ToolDescriptions.MAKE_DIRECTORY, )(self.make_directory)
  • The main handler function that creates a directory in the specified Modal sandbox using mkdir.aio, checks if sandbox is running, and returns a 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, )
  • Pydantic BaseModel defining the response schema for the make_directory tool, including success flag, message, and created path.
    class SandboxMakeDirectoryResponse(BaseModel): success: bool message: str path_created: str
  • Detailed docstring description 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