googleapis/mcp-toolbox · error

error constructing service creator: %w

Error message

error constructing service creator: %w

What it means

When the cloud-healthcare source is configured with UseClientOAuth, Initialize additionally builds a HealthcareServiceCreator that will construct per-request services from caller tokens; failure to construct this creator yields this wrapped error and stops initialization.

Source

Thrown at internal/sources/cloudhealthcare/cloud_healthcare.go:95

}

func (c Config) SourceConfigType() string {
	return SourceType
}

func (c Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
	var service *healthcare.Service
	var serviceCreator HealthcareServiceCreator
	var tokenSource oauth2.TokenSource

	svc, tok, err := initHealthcareConnection(ctx, tracer, c.Name)
	if err != nil {
		return nil, fmt.Errorf("error creating service from ADC: %w", err)
	}
	if c.UseClientOAuth {
		serviceCreator, err = newHealthcareServiceCreator(ctx, tracer, c.Name)
		if err != nil {
			return nil, fmt.Errorf("error constructing service creator: %w", err)
		}
	} else {
		service = svc
		tokenSource = tok
	}

	dsName := fmt.Sprintf("projects/%s/locations/%s/datasets/%s", c.Project, c.Region, c.Dataset)
	if _, err = svc.Projects.Locations.Datasets.FhirStores.Get(dsName).Do(); err != nil {
		if gerr, ok := err.(*googleapi.Error); ok && gerr.Code == http.StatusNotFound {
			return nil, fmt.Errorf("dataset '%s' not found", dsName)
		}
		return nil, fmt.Errorf("failed to verify existence of dataset '%s': %w", dsName, err)
	}

	allowedFHIRStores := make(map[string]struct{})
	for _, store := range c.AllowedFHIRStores {
		name := fmt.Sprintf("%s/fhirStores/%s", dsName, store)
		_, err := svc.Projects.Locations.Datasets.FhirStores.Get(name).Do()

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Ensure baseline ADC exist even in client-OAuth mode, if the creator requires them for bootstrapping
  2. Verify the configured project, location, and custom endpoint values are valid
  3. Check the wrapped error for the concrete construction failure
  4. Confirm the Cloud Healthcare API is enabled and the network can reach googleapis.com
Defensive patterns

Strategy: validation

Validate before calling

// ensure bootstrap credentials and endpoint config exist before Initialize
if cfg.UseClientOAuth {
    if _, err := google.FindDefaultCredentials(ctx, "https://www.googleapis.com/auth/cloud-platform"); err != nil {
        return fmt.Errorf("client-OAuth mode still needs bootstrap ADC: %w", err)
    }
}

Prevention

When it happens

Trigger: UseClientOAuth: true and newHealthcareServiceCreator fails during Initialize — typically ADC/credential setup needed to bootstrap the creator itself fails, or client options for the healthcare endpoint are invalid (bad project/location/endpoint).

Common situations: Client-OAuth setups bootstrapped in environments that still lack baseline credentials or with a misconfigured custom endpoint for the Healthcare API.

Related errors


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