googleapis/mcp-toolbox · error

failed to list tables: %w

Error message

failed to list tables: %w

What it means

This error wraps failures from the Bigtable Admin client's Tables call in Source.ListTables. The library wraps the underlying error with fmt.Errorf("failed to list tables: %w", err) so the underlying gRPC status and details remain retrievable. It indicates listing failed entirely, not that any individual table is problematic.

Source

Thrown at internal/sources/bigtable/admin_wrappers.go:163

		if err := s.Admin.CreateColumnFamily(ctx, tableId, columnFamily); err != nil {
			return nil, fmt.Errorf("failed to create column family: %w", err)
		}
	}
	return map[string]string{"status": "table created successfully"}, nil
}

func (s *Source) DeleteTable(ctx context.Context, tableId string) (any, error) {
	err := s.Admin.DeleteTable(ctx, tableId)
	if err != nil {
		return nil, fmt.Errorf("failed to delete table: %w", err)
	}
	return map[string]string{"status": "table deleted successfully"}, nil
}

func (s *Source) ListTables(ctx context.Context) (any, error) {
	tables, err := s.Admin.Tables(ctx)
	if err != nil {
		return nil, fmt.Errorf("failed to list tables: %w", err)
	}
	return tables, nil
}

func (s *Source) UpdateTable(ctx context.Context, tableId string, disableChangeStream bool) (any, error) {
	var err error
	if disableChangeStream {
		err = s.Admin.UpdateTableDisableChangeStream(ctx, tableId)
	} else {
		err = s.Admin.UpdateTableWithChangeStream(ctx, tableId, 24*time.Hour)
	}
	if err != nil {
		return nil, fmt.Errorf("failed to update table: %w", err)
	}
	return map[string]string{"status": "table updated successfully"}, nil
}

func (s *Source) GetLogicalView(ctx context.Context, instanceId, logicalViewId string) (any, error) {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Verify the Source was initialized with a valid project and instance ID (check where the Admin client is created).
  2. Ensure Application Default Credentials are configured (GOOGLE_APPLICATION_CREDENTIALS or metadata server) and include roles/bigtable.viewer or admin.
  3. Test network reachability to bigtableadmin.googleapis.com from the runtime environment (proxy/VPN/firewall).
  4. Retry transient gRPC failures with backoff; check status.Code(err) for PermissionDenied vs Unavailable.

Example fix

// before
return nil, fmt.Errorf("failed to list tables: %w", err)
// after: surface the gRPC code for easier triage
return nil, fmt.Errorf("failed to list tables (code=%s): %w", status.Code(err), err)
Defensive patterns

Strategy: retry

Validate before calling

// Go: pre-flight before listing tables
if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS") == "" && !metadata.OnGCE() && os.Getenv("BIGTABLE_EMULATOR_HOST") == "" {
    return fmt.Errorf("no credentials configured for Bigtable admin client")
}
if projectId == "" || instanceId == "" {
    return fmt.Errorf("project and instance must be configured")
}

Type guard

func isRetryable(err error) bool {
    c := status.Code(err)
    return c == codes.Unavailable || c == codes.DeadlineExceeded || c == codes.ResourceExhausted
}

Try / catch

tables, err := src.ListTables(ctx)
if err != nil && isRetryable(err) {
    tables, err = retryWithBackoff(3, func() (any, error) { return src.ListTables(ctx) })
}
if err != nil {
    return fmt.Errorf("list tables: %w", err)
}

Prevention

When it happens

Trigger: Calling the bigtable list_tables tool where s.Admin.Tables(ctx) errors: the bound instance does not exist or the client was opened with a bad project/instance, caller lacks bigtable.tables.list, network/proxy blocking the Bigtable admin endpoint, or quota/transient gRPC failure.

Common situations: Client initialized against a nonexistent project or instance ID; workload running without default credentials (GOOGLE_APPLICATION_CREDENTIALS unset); corporate proxy/firewall blocking bigtableadmin.googleapis.com; regional outage.

Related errors


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