Skip to content

Commit 7a9dc03

Browse files
sharpninjaCopilot
andcommitted
Skip API key resolution when Bearer token is active
When a JWT Bearer token is set, the server ignores API keys entirely. Short-circuit ResolveActiveConnectionApiKeyAsync to avoid resolving a stale/wrong API key during workspace switches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 08a7b8d commit 7a9dc03

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/McpServerManager.Core/ViewModels/MainWindowViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,14 @@ private void ApplyActiveMcpBaseUrl(string mcpBaseUrl, string? mcpApiKey = null,
387387

388388
private async Task<string?> ResolveActiveConnectionApiKeyAsync(WorkspaceConnectionOption option, string baseUrl)
389389
{
390+
// JWT and API keys are mutually exclusive. When a Bearer token is available,
391+
// the server ignores API keys entirely — skip the resolution overhead.
392+
if (!string.IsNullOrWhiteSpace(_activeBearerToken))
393+
{
394+
_logger.LogDebug("[Workspace Switch] Bearer token active — skipping API key resolution");
395+
return null;
396+
}
397+
390398
var normalizedTargetBaseUrl = NormalizeMcpBaseUrl(baseUrl);
391399

392400
// Android OIDC flow injects an explicit MCP API key for the connection that completed sign-in.

0 commit comments

Comments
 (0)