{"record":{"id":"da6997e9131198ba","repo":"googleapis/mcp-toolbox","slug":"unable-to-create-client-w-da6997","errorCode":null,"errorMessage":"unable to create client: %w","messagePattern":"unable to create client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudstorage/cloudstorage.go","lineNumber":78,"sourceCode":"\treturn actual, nil\n}\n\ntype Config struct {\n\tName              string   `yaml:\"name\" validate:\"required\"`\n\tType              string   `yaml:\"type\" validate:\"required\"`\n\tProject           string   `yaml:\"project\" validate:\"required\"`\n\tAllowedBuckets    []string `yaml:\"allowedBuckets,omitempty\"`\n\tAllowedLocalRoots []string `yaml:\"allowedLocalRoots,omitempty\"`\n}\n\nfunc (r Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tclient, err := initGCSClient(ctx, tracer, r.Name, r.Project)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create client: %w\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig: r,\n\t\tclient: client,\n\t}\n\treturn s, nil\n}\n\nvar _ sources.Source = &Source{}\n\ntype Source struct {\n\tConfig\n\tclient *storage.Client\n}\n\nfunc (s *Source) validateBucket(bucket string) error {\n\tif len(s.AllowedBuckets) == 0 {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudstorage/cloudstorage.go#L60-L96","documentation":"CloudStorage Config.Initialize creates a Google Cloud Storage client via initGCSClient (project-scoped, with tracing). Any failure constructing the client — bad ADC, invalid project, network/API errors — is wrapped with this message. The source cannot be registered without a working GCS client.","triggerScenarios":"Initializing a cloud-storage source where storage.NewClient fails: missing/invalid Application Default Credentials, invalid 'project' id, Cloud Storage API disabled, or outbound network blocked (e.g. PRIVATE_IP options in an unsupported environment).","commonSituations":"Running locally without gcloud ADC; wrong project id in config; firewalled environment blocking googleapis.com; quota/billing not enabled on the project.","solutions":["Authenticate: run 'gcloud auth application-default login' or set GOOGLE_APPLICATION_CREDENTIALS to a valid key file.","Verify the 'project' field in the source config matches a real, billing-enabled project.","Ensure storage.googleapis.com is reachable and the Cloud Storage API is enabled.","Grant the identity storage-related roles (e.g. roles/storage.admin or objectViewer) as needed."],"exampleFix":"// before: no credentials\n// after:\n//   export GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa-key.json\n// or gcloud auth application-default login","handlingStrategy":"try-catch","validationCode":"creds, err := google.FindDefaultCredentials(ctx, storage.ScopeFullControl)\nif err != nil {\n    return fmt.Errorf(\"GCS auth missing: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := toolbox.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"unable to create client\") {\n        // check ADC, project id, and network before retrying\n    }\n    return err\n}","preventionTips":["Authenticate with ADC before starting the toolbox","Validate the project id exists and has billing/APIs enabled","Ensure egress to storage.googleapis.com is permitted","Test client creation with a tiny 'gsutil ls' / SDK call first"],"tags":["gcp","cloud-storage","gcs","credentials","client-init"],"backgroundTag":"missing-application-default-credentials","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"}