Skip to content

feat: proactively probe database on Auto-IAM refresh to update MCP tokens - #606

Draft
hessjcg wants to merge 2 commits into
mainfrom
mcp-iam-token-refresh
Draft

feat: proactively probe database on Auto-IAM refresh to update MCP tokens#606
hessjcg wants to merge 2 commits into
mainfrom
mcp-iam-token-refresh

Conversation

@hessjcg

@hessjcg hessjcg commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Fixes GoogleCloudPlatform/cloud-sql-proxy#2553
Fixes #585

When connecting to Cloud SQL for PostgreSQL with Managed Connection Pooling (MCP) enabled, the server-side MCP caches the IAM OAuth2 access token passed during connection establishment. Because IAM tokens expire after 1 hour, pooled backend sessions retain stale tokens and cause intermittent authentication failures (SQLSTATE 08P01).

This change adds a proactive connection test / probe during the background credential refresh cycle when Auto-IAM authentication is enabled. Immediately following a successful certificate refresh, the connector opens a TCP socket to the instance (port 3307), performs the TLS handshake to propagate the newly minted IAM token to the server's MCP daemon, and immediately closes the socket.

Code review comments addressed:
- Respect the IP settings in connection configuration (this.ipType) rather than probing all available IPs
- Use DEFAULT_SERVER_PROXY_PORT constant (3307)
- Use DEFAULT_CONNECT_TIMEOUT_MS constant (30000)
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