{"record":{"id":"fba59197efbbb0b7","repo":"googleapis/mcp-toolbox","slug":"error-creating-service-from-adc-w","errorCode":null,"errorMessage":"error creating service from ADC: %w","messagePattern":"error creating service from ADC: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudhealthcare/cloud_healthcare.go","lineNumber":90,"sourceCode":"\tRegion             string   `yaml:\"region\" validate:\"required\"`\n\tDataset            string   `yaml:\"dataset\" validate:\"required\"`\n\tAllowedFHIRStores  []string `yaml:\"allowedFhirStores\"`\n\tAllowedDICOMStores []string `yaml:\"allowedDicomStores\"`\n\tUseClientOAuth     bool     `yaml:\"useClientOAuth\"`\n}\n\nfunc (c Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (c Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tvar service *healthcare.Service\n\tvar serviceCreator HealthcareServiceCreator\n\tvar tokenSource oauth2.TokenSource\n\n\tsvc, tok, err := initHealthcareConnection(ctx, tracer, c.Name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating service from ADC: %w\", err)\n\t}\n\tif c.UseClientOAuth {\n\t\tserviceCreator, err = newHealthcareServiceCreator(ctx, tracer, c.Name)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error constructing service creator: %w\", err)\n\t\t}\n\t} else {\n\t\tservice = svc\n\t\ttokenSource = tok\n\t}\n\n\tdsName := fmt.Sprintf(\"projects/%s/locations/%s/datasets/%s\", c.Project, c.Region, c.Dataset)\n\tif _, err = svc.Projects.Locations.Datasets.FhirStores.Get(dsName).Do(); err != nil {\n\t\tif gerr, ok := err.(*googleapi.Error); ok && gerr.Code == http.StatusNotFound {\n\t\t\treturn nil, fmt.Errorf(\"dataset '%s' not found\", dsName)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"failed to verify existence of dataset '%s': %w\", dsName, err)\n\t}","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudhealthcare/cloud_healthcare.go#L72-L108","documentation":"CloudHealthcare's Initialize calls initHealthcareConnection, which builds a healthcare.Service from Application Default Credentials (ADC). Any failure there is re-wrapped with this message, aborting source initialization.","triggerScenarios":"Declaring a cloud-healthcare source without UseClientOAuth; Initialize -> initHealthcareConnection fails because ADC are missing/invalid, the Cloud Healthcare API is disabled, or the project/location/dataset/store values are rejected during service setup.","commonSituations":"Local runs without 'gcloud auth application-default login', CI containers lacking a mounted service-account key, or GCP projects where the Healthcare API hasn't been enabled.","solutions":["Set up ADC: gcloud auth application-default login or GOOGLE_APPLICATION_CREDENTIALS pointing to a valid service-account key","Enable the Cloud Healthcare API for the project","Verify the healthcare dataset/FHIR store names in the source config are correct","Consider UseClientOAuth: true so the caller's token is used instead of ADC"],"exampleFix":"// before\n# shell\n./toolbox --sources healthcare.yaml\n# error creating service from ADC\n// after\ngcloud auth application-default login \\\n  --scopes=https://www.googleapis.com/auth/cloud-platform\n./toolbox --sources healthcare.yaml","handlingStrategy":"validation","validationCode":"import \"google.golang.org/api/healthcare\"\n// verify ADC + API access before starting toolbox\ncreds, err := google.FindDefaultCredentials(ctx, healthcare.CloudPlatformScope)\nif err != nil { return fmt.Errorf(\"ADC missing for Cloud Healthcare: %w\", err) }","typeGuard":null,"tryCatchPattern":"// Go: classify initialization failure at startup\nsrc, err := cfg.Initialize(ctx, tracer)\nif err != nil && strings.Contains(err.Error(), \"ADC\") {\n    return fmt.Errorf(\"fix credentials before retrying: %w\", err)\n}","preventionTips":["Run gcloud auth application-default login locally","Provide a service-account key via GOOGLE_APPLICATION_CREDENTIALS in containers","Enable the Cloud Healthcare API and grant healthcare.* roles to the identity","Validate dataset/FHIR store identifiers in the config"],"tags":["cloudhealthcare","google-cloud","authentication","adc"],"backgroundTag":"adc-credentials-missing","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}