Repository navigation
Description
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
- Create an isolated runtime with a temporary data directory and an enabled HTTP server named
dcr-fixture, URLhttps://mcp.example.invalid/mcp. No real provider is needed. - Persist only client registration via
BoltDB.UpdateOAuthClientCredentials(oauth.GenerateServerKey(name, url), "synthetic-client", "", 0, ""). This creates a record with emptyAccessTokenand zeroExpiresAt. - Add the server to the supervisor StateView as disconnected / pending auth, then call
Runtime.GetAllServers(). - 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
- OAuth login loops after logout/restart: DCR placeholder token is treated as persisted token #305 / Fix OAuth reconnect loop caused by DCR-only placeholder token #308 fixed DCR placeholders in the token store and reconnect loop. That guard is present; this report concerns the runtime status projection.
- OAuth login fails after a successful browser approval: scan restart or quarantine expiry retires the pending flow #1722 covers a pending login being retired by instance replacement and the misleading callback UX. That can leave a DCR-only record behind, but the false token status reproduces without any replacement or browser flow. This report does not propose weakening the retirement barrier.
- [Bug]: MCP upstream list reports sign-in required with a valid OAuth token #1522 / fix(server): use canonical OAuth health in MCP upstream list #1525 concerned the opposite symptom, a login warning despite an actual token.
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
fix(runtime): require an access token for OAuth status (smart-mcp-pro…