Maintenance scripts use WikIFactory as well, so all "standard" global variables should be set. Do you have more details about ``wgServer`` variable being empty?