Skip to content

Remote MCP servers repeatedly require interactive re-sign-in: persisted OAuth credentials become unreadable, cached refresh grants are lost #5651

Backlog

Description

@emiletherrien

Summary

Users of the GitHub Copilot desktop app have to sign in again to OAuth-protected remote MCP servers several times a day (one user reports at least 5 times a day). This happens to every Entra ID–protected server they use at once (three FastMCP AzureProvider servers and one ASP.NET server that validates Entra tokens directly). Server-side logs show the servers are not revoking or rejecting valid grants. The client logs show the app failing to read its persisted MCP credentials, then reporting no cached tokens and asking for interactive authentication.

There was no app update between the user's working state and the failures.

Environment

  • GitHub Copilot desktop app 1.5.0 (stamped build, not a local source build)
  • Seen on Windows (affected user) and macOS 27.0.1 (reporter)
  • Remote HTTP MCP servers using OAuth 2.1 with Microsoft Entra ID:
    • three FastMCP AzureProvider (OAuth proxy) servers: refresh tokens issued, 1-year refresh lifetime, persistent client storage, single replica
    • one ASP.NET server that validates Entra access tokens directly; the client refreshes with Entra itself
  • Servers configured through a plugin .mcp.json (type: http)

Observed behavior

  1. The user signs in to an MCP server (Customize > Installed > server > Sign in, browser flow). It works.
  2. Some time later, every Entra-backed MCP server shows as needing sign-in at once.
  3. Client log sequence (Windows user, UTC, server names anonymized):
2026-11-26T04:18:48Z WARNING mcp_session::client_auth  Explicit MCP cached refresh failed {"error":"MCP server \"server-a\" still requires authentication: no usable cached refresh grant; interactive authentication is required"}
2026-11-26T04:29:59Z WARNING mcp_client::oauth_flow    Cached MCP OAuth refresh refused {"reason":"no cached tokens"}
2026-11-30T21:11:28Z WARNING mcp_session::agent_host   MCP connection requires authentication; requesting bounded owned recovery {"server_name":"server-a"}
   ... repeated roughly hourly through 2026-12-01T13:36Z ...
2026-12-01T21:30:49Z WARNING rt_mcp_oauth_store       Could not read persisted MCP credentials
2026-12-01T21:30:59Z WARNING rt_mcp_oauth_store       Could not read persisted MCP credentials
2026-12-01T23:21:10Z WARNING rt_mcp_oauth_store       Could not read persisted MCP credentials   (x3, 5 s apart)
2026-12-01T23:21:28Z WARNING mcp_client::oauth_flow    Cached MCP OAuth refresh refused {"reason":"no cached tokens"}
2026-12-01T23:21:28Z WARNING mcp_session::client_auth  Explicit MCP cached refresh failed {"error":"MCP server \"server-b\" still requires authentication: cached OAuth refresh refused: no cached tokens"}
2026-12-02T00:50:24Z WARNING mcp_session::client_auth  Explicit MCP cached refresh failed {"error":"MCP server \"server-c\" still requires authentication: cached OAuth refresh refused: no cached tokens"}
  1. The reporter's macOS app logged the same warning at about the same time (2026-12-01 ~22:10–22:12Z), and again on 2026-12-02 19:21–19:26Z, each time followed by the servers being reported as needing auth:
2026-12-02T19:21:29Z WARNING rt_mcp_oauth_store          Could not read persisted MCP credentials
2026-12-02T19:22:01Z WARNING mcp_client::session_authorizer MCP OAuth authorization failed; reporting the server as needing auth {"server":"server-e"}
2026-12-02T19:22:11Z WARNING mcp_client::session_authorizer MCP OAuth authorization failed; reporting the server as needing auth {"server":"server-d"}

Server-side evidence (the servers are not the cause)

  • For one affected user, the server logs show a completed browser sign-in at 03:32Z. The client started getting 401s 4 minutes later, while that access token was still valid, and sent no refresh request before asking for interactive sign-in again. So the client was not using or refreshing the tokens it had just received.
  • 48 h on one FastMCP server: 301 successful refreshes and 50 invalid_grant rejections. 48 of the 50 were one Copilot desktop client resending the same already-rotated refresh token for two days (same token_hash, client=https://github.com/copilot/desktop/client-metadata.json). After an invalid_grant, the client should throw away that refresh token and not send it again.
  • On other servers, a few failures came 1–2 s after a successful refresh, which suggests two refreshes of the same grant ran at once from one client. FastMCP rotates refresh tokens once-only, as OAuth 2.1 recommends. Recent FastMCP versions end the whole grant when an old token is reused more than 60 s after rotation, which will make this client behavior worse.

Expected behavior

  • Persisted MCP OAuth credentials stay readable across app restarts and over time. If a read fails temporarily, the app retries; it does not treat the store as empty.
  • When the access token expires, the app refreshes silently with the stored refresh token and only asks for interactive sign-in when the server or IdP actually rejects the grant.
  • Only one refresh runs per server grant at a time, and the rotated refresh token is saved before it's used again.
  • After invalid_grant, the app discards that refresh token and doesn't send it again.

Impact

Users lose access to every remote data source several times a day, and have to sign in to each one again by hand.

Requests

  1. What makes rt_mcp_oauth_store log Could not read persisted MCP credentials, and can it say why (keychain/Credential Manager error, decryption failure, file lock, size limit)?
  2. Make refresh single-flight per server and save rotated refresh tokens before reuse.
  3. Stop resending a refresh token after it gets invalid_grant.

Additional redacted client and server logs can be provided.

Activity

  1. added
    triage:needs-human
    on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage:needs-human

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions