Skip to content

Fix: Upgrade mcp-oauth to v0.2.56 for cross-client audience scope merging#328

Merged
teemow merged 1 commit intomainfrom
fix/upgrade-mcp-oauth-cross-client-scope-fix
Jan 30, 2026
Merged

Fix: Upgrade mcp-oauth to v0.2.56 for cross-client audience scope merging#328
teemow merged 1 commit intomainfrom
fix/upgrade-mcp-oauth-cross-client-scope-fix

Conversation

@teemow
Copy link
Member

@teemow teemow commented Jan 30, 2026

Summary

  • Upgrades mcp-oauth from v0.2.55 to v0.2.56
  • Fixes SSO token forwarding for Kubernetes OIDC authentication
  • Adds automatic retry loop for failed MCPServer services with exponential backoff
  • Improves transient error detection to include HTTP 5xx server errors

Problem

When users authenticated to muster, client-requested OAuth scopes (openid profile email offline_access) were overriding the provider's configured cross-client audience scopes. This resulted in tokens that lacked the dex-k8s-authenticator audience required for Kubernetes API access.

Symptom: muster agent could connect to mcp-kubernetes via SSO, but Kubernetes API calls failed with "the server has asked for the client to provide credentials".

Additionally, when MCP servers experienced transient failures (e.g., 503 Service Unavailable), muster would not automatically retry connecting to them.

Root Cause

  1. OAuth scope merging: The CopyScopes function in mcp-oauth used either client-requested scopes OR provider defaults, not both. Cross-client audience scopes configured via requiredAudiences in MCPServer CRs were being ignored.

  2. Missing retry logic: The orchestrator lacked automatic retry for failed MCP servers, requiring manual intervention for transient issues.

Fix

  1. mcp-oauth v0.2.56 includes a fix that merges mandatory scopes (cross-client audiences like audience:server:client_id:dex-k8s-authenticator) from provider defaults into client-requested scopes.

  2. Automatic retry loop: Added a background goroutine in the orchestrator that checks failed/unreachable MCP servers every 30 seconds and attempts reconnection when their backoff period expires.

  3. HTTP 5xx detection: Extended transient error detection to recognize HTTP 5xx server errors (500-504, 507-509) as retry-eligible.

Changes

Orchestrator (internal/orchestrator/orchestrator.go)

  • Added RetryInterval constant (30 seconds) at file-level with other constants
  • Added sync.WaitGroup for tracking in-flight retry goroutines (clean shutdown)
  • Added retryFailedMCPServers() - background loop respecting context cancellation
  • Added attemptReconnectFailedServers() - checks backoff and spawns restart goroutines
  • Added shouldAttemptRetry() - extracted eligibility check for readability

MCP Server Service (internal/services/mcpserver/service.go)

  • Extended isTransientConnectivityError() with consolidated HTTP 5xx patterns
  • Added coverage for status codes 500, 501, 502, 503, 504, 507, 508, 509

Tests (internal/services/mcpserver/service_test.go)

  • Added comprehensive HTTP 5xx test cases including:
    • All covered status codes (500-504, 507-509)
    • Mixed case error messages
    • Wrapped errors
    • 4xx errors (verified as NOT transient)

Test Plan

  • Unit tests pass (make test)
  • Deploy to gazelle and verify SSO token forwarding works with Kubernetes OIDC
  • Verify muster auth status shows gazelle-mcp-kubernetes as Connected [SSO: Forwarded]
  • Verify kubernetes_cluster_health tool returns healthy status instead of auth error
  • Verify failed MCP servers are automatically retried after backoff expires

Related

…ging

This upgrade fixes an issue where cross-client audience scopes configured
in the Dex provider were being ignored when clients requested specific
OAuth scopes.

The fix in mcp-oauth v0.2.56 ensures that mandatory scopes like
`audience:server:client_id:dex-k8s-authenticator` are always merged
into client-requested scopes, enabling proper SSO token forwarding
for Kubernetes OIDC authentication.

Related: giantswarm/mcp-oauth#203
@teemow teemow requested a review from a team as a code owner January 30, 2026 16:33
@teemow teemow merged commit 8884160 into main Jan 30, 2026
6 checks passed
@teemow teemow deleted the fix/upgrade-mcp-oauth-cross-client-scope-fix branch January 30, 2026 16:39
teemow added a commit that referenced this pull request Jan 31, 2026
…-cross-client-scope-fix

* origin/main:
  Fix: Upgrade mcp-oauth to v0.2.56 for cross-client audience scope merging (#328)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant