googleapis / googleapis/mcp-toolbox

BigQuery default-ADC source keeps using stale credentials after gcloud re-auth (requires process restart)

Open
#3,573 0 comments 0 reactions 1 assignee Claimed by @Genesis929 View on GitHub
priority: p1 product: bigquery
Dominant language
Go
Stars
16.5k
Forks
1.7k
Avg merge
4d 9h
Merged PRs (30d)
85

Description

## What happens

A BigQuery source using Application Default Credentials (the default, non-`useClientOAuth` path) fetches credentials once at `Initialize` via `google.FindDefaultCredentials(...)` in `internal/sources/bigquery/bigquery.go` and holds the resulting in-memory `oauth2.TokenSource` (and the `Client`/`RestService` built from it) for the lifetime of the process.

That in-memory token source transparently refreshes *access* tokens from its cached refresh material, so ordinary expiry is handled. The gap: it never re-reads ADC from disk. If a user re-runs

```
gcloud auth application-default login
```

a new refresh token is written to disk and the old one is revoked. Once the cached access token expires, the held source can no longer mint tokens (its refresh token is dead), and every BigQuery tool invocation on that long-running process fails with an authentication error. The only way to recover today is to restart the whole MCP Toolbox process so `Initialize` runs again.

## Expected

After re-authenticating on disk with `gcloud auth application-default login`, a long-running session should recover on its own once its cached access token refreshes — no process restart.

## Repro

1. Run the toolbox with a BigQuery source using default ADC (no `useClientOAuth`).
2. Invoke a BigQuery tool (e.g. `bigquery-execute-sql`); confirm it works.
3. In another terminal, run `gcloud auth application-default login` and complete the flow (a new refresh token is written and the old one revoked).
4. After the cached access token expires, invoke the tool again on the still-running process.

**Observed:** invocations keep failing with an authentication error until the process is restarted.
**Expected:** the invocation picks up the new on-disk credentials and succeeds.

## Note

This is the same class of problem as #2173 (which moved token acquisition per-invoke for the conversational-analytics tool); the default-ADC source path — shared by the BigQuery tools and the source's Dataplex client used by `bigquery-search-catalog` — wasn't covered.

Fix proposed in #3567.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.