delete_instruction
Remove a .instructions.md file from the prompts directory in VS Code using Mode Manager MCP. Specify the instruction name for precise deletion to declutter your workspace.
Instructions
Delete a VS Code .instructions.md file from the prompts directory.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instruction_name | Yes | The name of the instruction to delete (with or without extension) |
Implementation Reference
- The MCP tool handler function for 'delete_instruction'. Checks read-only mode, calls InstructionManager.delete_instruction(instruction_name), and returns formatted success or error message.def delete_instruction( instruction_name: Annotated[str, "The name of the instruction to delete (with or without extension)"], ) -> str: """Delete a VS Code .instructions.md file from the prompts directory.""" if read_only: return "Error: Server is running in read-only mode" try: success = instruction_manager.delete_instruction(instruction_name) if success: return f"Successfully deleted VS Code instruction: {instruction_name}" else: return f"Failed to delete VS Code instruction: {instruction_name}" except Exception as e: return f"Error deleting VS Code instruction '{instruction_name}': {str(e)}"
- src/mode_manager_mcp/tools/instruction_tools.py:152-168 (registration)Registers the 'delete_instruction' tool on the MCP app using @app.tool decorator. Includes tool metadata, tags, schema descriptions for parameters and returns.@app.tool( name="delete_instruction", description="Delete a VS Code .instructions.md file from the prompts directory.", tags={"public", "instruction"}, annotations={ "idempotentHint": False, "readOnlyHint": False, "title": "Delete Instruction", "parameters": { "instruction_name": "The name of the instruction to delete. If a full filename is provided, it will be used as-is. Otherwise, .instructions.md will be appended automatically. You can provide just the name (e.g. my-instruction) or the full filename (e.g. my-instruction.instructions.md)." }, "returns": "Returns a success message if the instruction was deleted, or an error message if the operation failed or the file was not found.", }, meta={ "category": "instruction", }, )
- Core helper method in InstructionManager class that implements the file deletion logic: ensures extension, checks existence, performs safe deletion with backup using safe_delete_file.def delete_instruction(self, instruction_name: str) -> bool: """ Delete an instruction file with automatic backup. Args: instruction_name: Name of the .instructions.md file Returns: True if successful Raises: FileOperationError: If file cannot be deleted """ # Ensure filename has correct extension instruction_name = self._ensure_instruction_extension(instruction_name) file_path = self.prompts_dir / instruction_name if not file_path.exists(): raise FileOperationError(f"Instruction file not found: {instruction_name}") try: # Use safe delete which creates backup automatically safe_delete_file(file_path, create_backup=True) logger.info(f"Deleted instruction file with backup: {instruction_name}") return True except Exception as e: raise FileOperationError(f"Error deleting instruction file {instruction_name}: {e}")