build server function