Skip to content

[bigquery] Prebuilt config missing impersonateServiceAccount env var #2769

@kwkeefer

Description

@kwkeefer

Prerequisites

  • I've searched the current open issues
  • I've updated to the latest version of Toolbox

Toolbox version

toolbox version 0.29.0+binary.darwin.arm64.39832a0

Environment

  1. OS type and version: Darwin 24.6.0 (macOS, arm64)
  2. How are you running Toolbox: As a downloaded binary

Client

  1. Client: Claude Code (Anthropic CLI for MCP)
  2. Version: Latest
  3. Example .mcp.json:
{
  "mcpServers": {
    "bigquery": {
      "command": "toolbox",
      "args": ["--prebuilt", "bigquery", "--stdio"],
      "env": {
        "BIGQUERY_PROJECT": "my-project"
      }
    }
  }
}

Expected Behavior

The prebuilt BigQuery config should expose impersonateServiceAccount via an env var, consistent with how every other configurable source field (location, useClientOAuth, scopes, maxQueryResultRows) is exposed. This field was added to the BigQuery source in #1641 but was not wired into the prebuilt YAML.

Expected: setting BIGQUERY_IMPERSONATE_SERVICE_ACCOUNT with --prebuilt bigquery should cause queries to run as the impersonated service account.

Current Behavior

There is no env var to enable impersonateServiceAccount with --prebuilt bigquery. The prebuilt YAML at internal/prebuiltconfigs/tools/bigquery.yaml does not include the field. CLOUDSDK_ACTIVE_CONFIG_NAME and GOOGLE_IMPERSONATE_SERVICE_ACCOUNT are not honored by toolbox. SESSION_USER() always returns the personal account.

Steps to reproduce?

  1. Configure an MCP client with --prebuilt bigquery and BIGQUERY_PROJECT set
  2. Set CLOUDSDK_ACTIVE_CONFIG_NAME to a gcloud config that uses impersonate_service_account, or set GOOGLE_IMPERSONATE_SERVICE_ACCOUNT — neither has any effect
  3. Run SELECT SESSION_USER() via the execute_sql tool
  4. Result: returns the personal account, not the service account
  5. There is no env var available to enable impersonation with --prebuilt

Additional Details

The fix is one line in internal/prebuiltconfigs/tools/bigquery.yaml:

impersonateServiceAccount: ${BIGQUERY_IMPERSONATE_SERVICE_ACCOUNT:}

The empty default means existing users are unaffected. I built and tested a patched binary locally — impersonation works with the env var set, and behavior is unchanged when unset. Happy to open a PR.

The current workaround is to use --tools-file with a custom YAML, but this requires manually redefining all 9 BigQuery tools with their descriptions. It's also fragile since new tools added in future releases won't be picked up.

Related: #906, #1641

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions