googleapis/mcp-toolbox · error
failed to create DataChatClient: %w
Error message
failed to create DataChatClient: %w
What it means
When the cloudgda source is not configured for client-side OAuth, Initialize creates a shared google.golang.org/api geminidataanalytics.DataChatClient with the server's Application Default Credentials. Failure to construct that client aborts source initialization with this wrapped error.
Source
Thrown at internal/sources/cloudgda/cloud_gda.go:80
return SourceType
}
// Initialize initializes a Gemini Data Analytics Source instance.
func (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {
ua, err := util.UserAgentFromContext(ctx)
if err != nil {
return nil, fmt.Errorf("error in User Agent retrieval: %s", err)
}
s := &Source{
Config: r,
userAgent: ua,
}
if !r.UseClientOAuth {
client, err := NewDataChatClient(ctx, option.WithUserAgent(ua))
if err != nil {
return nil, fmt.Errorf("failed to create DataChatClient: %w", err)
}
s.Client = client
}
return s, nil
}
var _ sources.Source = &Source{}
type Source struct {
Config
Client *geminidataanalytics.DataChatClient
userAgent string
}
func (s *Source) IsReadOnly() bool {
return false
}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Set up Application Default Credentials (gcloud auth application-default login or a service-account key via GOOGLE_APPLICATION_CREDENTIALS)
- Enable the Gemini Data Analytics API on the project in Google Cloud Console
- Set UseClientOAuth: true in the source config to use the caller's OAuth token instead of ADC
- Check the wrapped error for quota or API-disabled details
Example fix
// before source: my-gda kind: cloud-gda project: my-project // after source: my-gda kind: cloud-gda project: my-project useClientOAuth: true
Defensive patterns
Strategy: try-catch
Validate before calling
// verify ADC before initializing
creds, err := google.FindDefaultCredentials(ctx, "https://www.googleapis.com/auth/cloud-platform")
if err != nil { return fmt.Errorf("ADC unavailable: %w", err) }
_ = creds Try / catch
// Go: wrap Initialize and surface the wrapped client error
src, err := cfg.Initialize(ctx, tracer)
if err != nil {
if strings.Contains(err.Error(), "DataChatClient") {
return fmt.Errorf("check ADC / enable Gemini Data Analytics API: %w", err)
}
return err
} Prevention
- Set GOOGLE_APPLICATION_CREDENTIALS or run gcloud auth application-default login before startup
- Enable the Gemini Data Analytics API on the project
- Use UseClientOAuth: true when deploying where server credentials are impractical
- Smoke-test client creation in CI with a minimal project
When it happens
Trigger: UseClientOAuth is false (or unset) and NewDataChatClient fails — typically because ADC are absent, the Gemini Data Analytics API is not enabled on the project, or the client options are invalid.
Common situations: Running the toolbox in an environment without GOOGLE_APPLICATION_CREDENTIALS or metadata-server credentials, or a GCP project where the Cloud Gemini/Data Analytics API hasn't been enabled.
Related errors
- failed to find default credentials: %w
- failed to create per-request DataChatClient: %w
- failed to initialize dataplex client: %w
- error creating client from OAuth access token: %w
- failed to get dataplex client: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/a5e2783702f8e86b.
Report an issue: GitHub.