Skip to content

Commit f5b4d89

Browse files
Dhruv KejriwalUbuntu
authored andcommitted
docs(auth): document expires_at rationale from mcp2cli reproduction
1 parent 7018afc commit f5b4d89

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/mcp/shared/auth.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ class OAuthToken(BaseModel):
2929
access_token: str
3030
token_type: Literal["Bearer"] = "Bearer"
3131
expires_in: int | None = None
32+
# Absolute unix timestamp when the access token expires. The spec's
33+
# `expires_in` is relative, so a persisted token alone can't tell a fresh
34+
# process whether it's already stale — that caused mcp2cli issues #50/#57
35+
# (a stale Bearer sent, then a wasted 401 round-trip before re-auth).
36+
# Persisting the absolute expiry and restoring it on _initialize fixes the
37+
# whole class. Backwards compatible: None means "unknown, re-auth once".
3238
expires_at: float | None = None
3339
scope: str | None = None
3440
refresh_token: str | None = None

0 commit comments

Comments
 (0)