remove_file
Delete files or folders directly via the dev-kit-mcp-server by specifying the path, returning status and details of the removed item.
Instructions
Use instead of terminal: Remove a file or folder.
Args:
path: Path to the file or folder to remove
Returns:
A dictionary containing the status and path of the removed file or folder
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- The __call__ method implementing the remove_file tool logic: removes the specified file or directory after validation and returns a success dictionary.async def __call__(self, path: str) -> Dict[str, Any]: """Remove a file or folder. Args: path: Path to the file or folder to remove Returns: A dictionary containing the status and path of the removed file or folder """ # Handle both model and direct path input for backward compatibility self._remove_folder(path) return { "status": "success", "message": f"Successfully removed: {path}", "path": path, }
- Helper method that performs the actual file or directory removal after path validation.def _remove_folder(self, path: str) -> None: """Remove a file or folder at the specified path. Args: path: Path to the file or folder to remove Raises: FileNotFoundError: If the path does not exist """ # Validate that the path is within the root directory root_path = self._root_path abs_path = self._validate_path_in_root(root_path, path) # Check if path exists file_path = Path(abs_path) if not file_path.exists(): raise FileNotFoundError(f"Path does not exist: {path}") # Remove the file or folder if file_path.is_dir(): shutil.rmtree(file_path) else: file_path.unlink()
- dev_kit_mcp_server/create_server.py:52-53 (registration)Registers all tools from the tools module using ToolFactory, which includes RemoveFileOperation instantiated as the 'remove_file' tool.tool_factory = ToolFactory(fastmcp) tool_factory(["dev_kit_mcp_server.tools"], root_dir=root_dir, commands_toml=commands_toml)
- dev_kit_mcp_server/tools/__init__.py:10-27 (registration)Imports and exposes RemoveFileOperation in __all__ for dynamic tool discovery and registration.from .file_sys.remove import RemoveFileOperation from .file_sys.rename import RenameOperation from .git.add import GitAddOperation from .git.checkout import GitCheckoutOperation from .git.commit import GitCommitOperation from .git.create_branch import GitCreateBranchOperation from .git.diff import GitDiffOperation from .git.pull import GitPullOperation from .git.push import GitPushOperation from .git.status import GitStatusOperation # Check if PyGithub is available GITHUB_AVAILABLE = importlib.util.find_spec("github") is not None __all__ = [ "CreateDirOperation", "EditFileOperation", "RemoveFileOperation",
- dev_kit_mcp_server/tools/file_sys/remove.py:15-15 (registration)Sets the tool name to 'remove_file' used during MCP tool registration.name = "remove_file"