protected function buildRequestUri(Server $server, array $query = [], array $settings = []): string
    {
        $uri = $server->getOptions()->getProtocol() . '://' . $server->getHost() . ':' . $server->getPort();

        if (!is_null($server->getDatabase())) {
            $query['database'] = $server->getDatabase();
        }

        if (!is_null($server->getUsername())) {
            $query['user'] = $server->getUsername();
        }

        if (!is_null($server->getPassword())) {
            $query['password'] = $server->getPassword();
        }

        $query = array_merge($query, $settings);

        return $uri . '?' . http_build_query($query);
    }