googleapis/mcp-toolbox · error

error constructing client creator: %w

Error message

error constructing client creator: %w

What it means

When useClientOAuth is enabled, Initialize constructs a per-client creator via newBigQueryClientCreator, which sets up the machinery to create a BigQuery client from each end user's credentials at invocation time. Failure to build this creator (e.g. invalid endpoint or project configuration) is wrapped in this error.

Source

Thrown at internal/sources/bigquery/bigquery.go:215

		if err != nil {
			return nil, fmt.Errorf("error creating client from ADC: %w", err)
		}
		s.Client = client
		s.RestService = restService
		s.TokenSource = tokenSource

		if r.WriteMode == WriteModeProtected {
			// session-based connections
			s.SessionProvider = s.newBigQuerySessionProvider()
		}
	} else {
		if strings.ToLower(r.UseClientOAuth) != "true" {
			s.AuthTokenHeaderName = r.UseClientOAuth
		}
		// use client OAuth
		baseClientCreator, err := newBigQueryClientCreator(ctx, tracer, r.Project, r.Location, r.QuotaProject, r.Name, endpoint)
		if err != nil {
			return nil, fmt.Errorf("error constructing client creator: %w", err)
		}
		setupClientCaching(s, baseClientCreator)
	}

	allowedDatasets := make(map[string]struct{})
	// Get full id of allowed datasets and verify they exist.
	if len(r.AllowedDatasets) > 0 {
		for _, allowed := range r.AllowedDatasets {
			var projectID, datasetID, allowedFullID string
			if strings.Contains(allowed, ".") {
				parts := strings.Split(allowed, ".")
				if len(parts) != 2 {
					return nil, fmt.Errorf("invalid allowedDataset format: %q, expected 'project.dataset' or 'dataset'", allowed)
				}
				projectID = parts[0]
				datasetID = parts[1]
				allowedFullID = allowed
			} else {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify apiEndpoint is a valid BigQuery REST endpoint host (or remove it to use the default).
  2. Check project and location values are correct and reachable.
  3. Temporarily disable useClientOAuth to isolate whether the failure is in ADC or client-creator setup.

Example fix

// before
apiEndpoint: bigquery.invalid-endpoint.googleapis.com
// after
apiEndpoint: bigquery.googleapis.com
Defensive patterns

Strategy: validation

Validate before calling

u, err := url.Parse("https://" + endpoint)
if err != nil || u.Host == "" {
	return fmt.Errorf("apiEndpoint %q is not a valid host", endpoint)
}

Try / catch

src, err := sourceRegistry.Initialize(ctx, cfg)
if err != nil {
	if strings.Contains(err.Error(), "error constructing client creator") {
		log.Printf("client creator setup failed; check apiEndpoint/project/location: %v", err)
		return err
	}
	return err
}

Prevention

When it happens

Trigger: Initializing the BigQuery source with useClientOAuth enabled when newBigQueryClientCreator fails — typically due to an invalid/normalized API endpoint or unresolvable project/location/quotaProject parameters.

Common situations: Setting apiEndpoint to a malformed or unreachable host for restricted/VPC-SC environments; typos in project ID passed to the client creator; misconfigured options transport settings.

Related errors


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