Skip to content

Persist Google OAuth 2.1 tokens across container restarts - #2

Open
ibulgakov wants to merge 1 commit into
mainfrom
fix/google-oauth21-token-persistence
Open

Persist Google OAuth 2.1 tokens across container restarts#2
ibulgakov wants to merge 1 commit into
mainfrom
fix/google-oauth21-token-persistence

Conversation

@ibulgakov

Copy link
Copy Markdown

Problem

With MCP_ENABLE_OAUTH21=true, the google_workspace_mcp image does not store Google OAuth tokens under WORKSPACE_MCP_CREDENTIALS_DIR (/home/app/.google_workspace_mcp/credentials, bind-mounted as ./google-credentials). Instead it stores refresh/upstream tokens via its internal fastmcp OAuth-proxy under /home/app/.local/share/fastmcp/oauth-proxy/..., which wasn't bind-mounted anywhere.

Consequences:

  • SETUP.md Step 7's verification (ls ./google-credentials/) never reflects real auth state in this mode -- it stays empty even after a fully successful OAuth flow.
  • docker compose down (or any container recreation) silently wipes the Google OAuth session, forcing re-authentication every time, contrary to what Step 9's checklist implies.

Verified manually end-to-end: authenticated via Claude Code, confirmed Google Workspace tools worked, found ./google-credentials/ empty, located the real tokens via docker exec ... find /home/app/.local/share/fastmcp -iname *token*, then confirmed the fix by recreating the container and confirming tokens (and a live search_drive_files call) survived.

Fixes #1

Change

  • docker-compose.yml (and the synced copy in SETUP.md): add a second bind mount, ./google-oauth-proxy:/home/app/.local/share/fastmcp, with a comment explaining why.
  • SETUP.md Step 7: point the success-verification command at the new directory instead of ./google-credentials/, and note explicitly that ./google-credentials/ staying empty is expected/not a failure signal in OAuth 2.1 mode.
  • SETUP.md Step 9 checklist: same correction.

Testing

  • docker compose up -d with the new volume, authenticated via /mcp in Claude Code -- tokens appeared under ./google-oauth-proxy/oauth-proxy/*/S_mcp_refresh_tokens-*.
  • Recreated the container (docker compose up -d google-workspace-mcp, forcing recreate) -- tokens persisted, search_drive_files kept working without re-auth.

MCP_ENABLE_OAUTH21=true stores refresh/upstream tokens via fastmcp's
OAuth-proxy under /home/app/.local/share/fastmcp, not under
WORKSPACE_MCP_CREDENTIALS_DIR. That directory wasn't bind-mounted, so
docker compose down (or any container recreation) silently wiped the
Google OAuth session, and SETUP.md's ./google-credentials/ check in
Step 7 never actually reflected auth success in this mode.

Fixes #1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant