Skip to content

[Bug]: DCR-only OAuth record is reported as authenticated with a valid token #1723

Closed

Description

@neylwalecki

Problem

A Dynamic Client Registration (DCR) record without an access token is reported as authenticated: true, oauth_status: authenticated, and oauth.token_valid: true when its expiry is zero. The CLI consequently prints Token: Valid, even though PersistentTokenStore.GetToken() correctly returns transport.ErrNoToken for the same record.

Observed on personal v0.71.1 (macOS arm64). Reproduced with temporary storage and synthetic fixtures on current main, 14cb288f.

Synthetic reproduction

  1. Create an isolated runtime with a temporary data directory and an enabled HTTP server named dcr-fixture, URL https://mcp.example.invalid/mcp. No real provider is needed.
  2. Persist only client registration via BoltDB.UpdateOAuthClientCredentials(oauth.GenerateServerKey(name, url), "synthetic-client", "", 0, ""). This creates a record with empty AccessToken and zero ExpiresAt.
  3. Add the server to the supervisor StateView as disconnected / pending auth, then call Runtime.GetAllServers().
  4. Read the same record through oauth.NewPersistentTokenStore(name, url, db).GetToken(context.Background()).

Actual projection: authenticated=true, oauth_status=authenticated, oauth.token_valid=true. The token store returns no token. This happens with both an explicit OAuth block and OAuth autodiscovery. A fixture with an empty access token but a future expiry and refresh metadata also reproduces it.

Expected: unauthenticated / login required, without a valid-token claim. Preserve the registration for the next login. Real access tokens with zero expiry must remain supported as non-expiring tokens.

Cause and proposed scope

Runtime.GetAllServers in internal/runtime/runtime.go checks only err == nil && token != nil, then treats a zero expiry as an indefinitely valid token. It reads an OAuthTokenRecord, which can contain only DCR client metadata. PersistentTokenStore.GetToken already checks for an empty access token (fixed in #308 / #305), but the runtime projection bypasses that guard.

A small projection-only fix can require AccessToken != "" before reporting authentication/expiry, while retaining the autodiscovery OAuth marker for DCR-only records. No token writes, OAuth flow changes, or schema changes are needed.

Related reports

Regression prepared: five storage scenarios in both explicit/autodiscovery modes. Before the fix, all four empty-access-token scenarios fail and the six real-token controls pass. With the minimal guard, all ten pass. Fixtures are synthetic; no production configuration, provider credentials, or user data are included.

Activity

  1. added a commit that references this issue on Oct 22, 2026
    f0f0eb1
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions