googleapis/mcp-toolbox · error

unable to create client: %w

Error message

unable to create client: %w

What it means

Initialize wraps any failure from initFalkorDBClient (which constructs the falkordb-go client via FalkorDBNew) with 'unable to create client'. The underlying wrapped error carries the real cause — typically a DNS resolution, address parsing, or client-construction failure.

Source

Thrown at internal/sources/falkordb/falkordb.go:95

	return nil
}

func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
	if err := r.validateTLS(); err != nil {
		return nil, err
	}

	logger, err := util.LoggerFromContext(ctx)
	if err != nil {
		return nil, fmt.Errorf("unable to get logger from ctx: %s", err)
	}
	if r.TLS.InsecureSkipVerify {
		logger.WarnContext(ctx, fmt.Sprintf("TLS certificate verification is skipped (insecureSkipVerify: true) for FalkorDB source %s. This exposes traffic for this source to man-in-the-middle attacks. Do not use in production.", r.Name))
	}

	client, err := initFalkorDBClient(ctx, tracer, r)
	if err != nil {
		return nil, fmt.Errorf("unable to create client: %w", err)
	}

	if err := client.Conn.Ping(ctx).Err(); err != nil {
		client.Conn.Close()
		return nil, fmt.Errorf("unable to connect successfully: %w", err)
	}

	s := &Source{
		Config: r,
		Client: client,
	}
	return s, nil
}

func initFalkorDBClient(ctx context.Context, tracer trace.Tracer, r Config) (*falkordb.FalkorDB, error) {
	//nolint:all // Reassigned ctx
	ctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, r.Name)
	defer span.End()

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the wrapped %w error for the root cause (DNS, address, TLS)
  2. Verify `host` and `port` in tools.yaml are correct and the port is numeric (e.g. "6379")
  3. Test reachability: `redis-cli -h <host> -p <port> PING` or `nc -vz host port`
  4. Check DNS inside the deployment environment (e.g. `nslookup <host>` in the pod)

Example fix

// before
    host: falkordb.default.svc.cluster.local
    port: 63aa79
// after
    host: falkordb.default.svc.cluster.local
    port: "6379"
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight DNS + TCP before Initialize
host, port := cfg.Host, cfg.Port
if net.ParseIP(host) == nil {
    if _, err := net.LookupHost(host); err != nil {
        return fmt.Errorf("cannot resolve falkordb host %q: %w", host, err)
    }
}
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, port), 5*time.Second)
if err != nil {
    return fmt.Errorf("cannot reach falkordb at %s:%s: %w", host, port, err)
}
conn.Close()

Try / catch

// Go: inspect the wrapped cause and retry transient failures
src, err := cfg.Initialize(ctx, tracer)
if err != nil {
    var derr *net.DNSError
    if errors.As(err, &derr) {
        return retryWithBackoff(ctx, initFn) // transient DNS
    }
    return err // config error: fix host/port, don't retry
}

Prevention

When it happens

Trigger: FalkorDBNew fails on an unparseable host:port (net.JoinHostPort output invalid), DNS resolution errors for the hostname, TLS config issues, or an unsupported/invalid option combination.

Common situations: Typoed hostnames; non-numeric or out-of-range port strings; DNS not resolving in container/K8s environments; firewall silently dropping connections during the initial dial.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/e79193e7c06e09cd. Report an issue: GitHub.