create_dir
Create files or folders in the workspace by specifying a target path, eliminating the need for manual terminal commands. Returns status and path details for the created items.
Instructions
Use instead of terminal: Create a file or folder in the workspace.
Args:
path: Path to the folder to create
Returns:
A dictionary containing the status and path of the created file or folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- The CreateDirOperation class implements the core logic for the 'create_dir' tool. It validates the path is within the root directory, checks if it exists, and creates the directory (including parents) using Path.mkdir. The __call__ method handles the tool execution and returns a success response.@dataclass class CreateDirOperation(AsyncOperation): """Class to create a folder in the workspace.""" name = "create_dir" def _create_folder(self, path: str) -> None: """Create a folder at the specified path. Args: path: Path to the folder to create Raises: FileExistsError: If the path already exists """ # Validate that the path is within the root directory root_path = self._root_path abs_path = self._validate_path_in_root(root_path, path) # Create the folder folder_path = Path(abs_path) if folder_path.exists(): raise FileExistsError(f"Path already exists: {path}") # Create parent directories if they don't exist folder_path.mkdir(parents=True, exist_ok=False) async def __call__(self, path: str) -> Dict[str, Any]: """Create a file or folder in the workspace. Args: path: Path to the folder to create Returns: A dictionary containing the status and path of the created file or folder """ # Handle both model and direct path input for backward compatibility self._create_folder(path) return { "status": "success", "message": f"Successfully created folder: {path}", "path": path, }
- dev_kit_mcp_server/create_server.py:51-54 (registration)In server_init, the ToolFactory registers all AsyncOperation tools from the 'dev_kit_mcp_server.tools' package, which includes the CreateDirOperation for 'create_dir'.# Register all tools tool_factory = ToolFactory(fastmcp) tool_factory(["dev_kit_mcp_server.tools"], root_dir=root_dir, commands_toml=commands_toml) return fastmcp
- The input schema is defined by the __call__ method signature: single string parameter 'path', returns Dict[str, Any] with status, message, path.async def __call__(self, path: str) -> Dict[str, Any]: """Create a file or folder in the workspace. Args: path: Path to the folder to create Returns: A dictionary containing the status and path of the created file or folder """ # Handle both model and direct path input for backward compatibility self._create_folder(path) return { "status": "success", "message": f"Successfully created folder: {path}", "path": path, }