You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While running FastMCP's stored-token expiry tests on Windows, I observed intermittent failures with expires_in=0: the client sometimes reused the stored token instead of acquiring a fresh one.
I reproduced the behavior in isolated environments using MCP SDK 2.3.0 alone and FastMCP 4.1.1 with MCP SDK 2.3.0.
OAuthContext.is_token_valid() returns True when the current time exactly equals token_expiry_time, because it uses <=. Once the clock advances past that timestamp, it correctly returns False. The same equality behavior occurs with a normal 3600-second token checked exactly at expiry.
I expected the token to be invalid at its expiration timestamp. Could you confirm whether the inclusive boundary is intentional, or whether it should be considered expired at equality?
The observed impact is intermittent downstream test failures, not a demonstrated production authentication failure. The example below uses a fixed nonzero clock to make the boundary deterministic; it needs no network or real credentials.
Prepared with AI assistance; the reproductions were executed locally and reviewed before submission.
Windows
Python 3.12.15
MCP SDK 2.3.0
Pydantic 2.14.1
Also reproduced through FastMCP 4.1.1's client-credentials auth flow
with MCP SDK 2.3.0 in a separate environment.
Hi maintainers, I've investigated this issue and verified that RFC 7519 §4.1.4 specifies a token is invalid on or after the exp timestamp (i.e. now >= exp). In src/mcp/client/auth/oauth2.py and identity_assertion.py, changing expires_at <= now to < now treats the boundary timestamp as expired rather than valid, preventing intermittent downstream race conditions where the expiry timestamp matches the current clock tick.
I have a patch with tests ready and verified against the auth test suite and linters. Could you please assign this issue to me so the PR guard allows reopening/submitting? Thanks!
Hi maintainers — following up on @sattyamjjain's <= diagnosis and @pei711's ready patch in #3730 (closed by the require-linked-issue bot because the issue was unassigned, not on technical grounds). I'd like to respect that earlier claim and build on it rather than duplicate it.
An independent hard-oracle check on the strict < change went 9/12 baseline → 12/12 after fix → 9/12 on revert (the 3 exact-boundary cases raise AssertionError without the fix). The official auth suite passes 210 passed / 1 xfailed. The change touches the two time.time() <= expiry sites — OAuthContext.is_token_valid() (oauth2.py) and the cached-Bearer gate in IdentityAssertionOAuthProvider._auth_flow (identity_assertion.py) — and preserves negative expires_in, missing expiry, the still-unexpired reuse path, and the no-token path; the epoch-seconds time contract is unchanged. This aligns with RFC 7519 §4.1.4 (invalid on/after exp).
I have not opened a PR or pushed anything, to respect the assignment gate. Could a maintainer give direction, assign #3729, or reopen #3730 once eligible? Happy to collaborate with @pei711 on whichever path maintainers prefer.
Disclosure: this patch was drafted with AI assistance and verified locally; RFC interpretation and scope remain for maintainers to confirm.
Activity
sattyamjjain commentedon Oct 20, 2026
pei711 commentedon Oct 20, 2026
Hi maintainers, I've investigated this issue and verified that RFC 7519 §4.1.4 specifies a token is invalid on or after the
exptimestamp (i.e.now >= exp). Insrc/mcp/client/auth/oauth2.pyandidentity_assertion.py, changingexpires_at <= nowto< nowtreats the boundary timestamp as expired rather than valid, preventing intermittent downstream race conditions where the expiry timestamp matches the current clock tick.I have a patch with tests ready and verified against the auth test suite and linters. Could you please assign this issue to me so the PR guard allows reopening/submitting? Thanks!
linhongyu510 commentedon Oct 22, 2026
Hi maintainers — following up on @sattyamjjain's
<=diagnosis and @pei711's ready patch in #3730 (closed by the require-linked-issue bot because the issue was unassigned, not on technical grounds). I'd like to respect that earlier claim and build on it rather than duplicate it.An independent hard-oracle check on the strict
<change went 9/12 baseline → 12/12 after fix → 9/12 on revert (the 3 exact-boundary cases raise AssertionError without the fix). The official auth suite passes 210 passed / 1 xfailed. The change touches the twotime.time() <= expirysites —OAuthContext.is_token_valid()(oauth2.py) and the cached-Bearer gate inIdentityAssertionOAuthProvider._auth_flow(identity_assertion.py) — and preserves negativeexpires_in, missing expiry, the still-unexpired reuse path, and the no-token path; the epoch-seconds time contract is unchanged. This aligns with RFC 7519 §4.1.4 (invalid on/afterexp).I have not opened a PR or pushed anything, to respect the assignment gate. Could a maintainer give direction, assign #3729, or reopen #3730 once eligible? Happy to collaborate with @pei711 on whichever path maintainers prefer.
Disclosure: this patch was drafted with AI assistance and verified locally; RFC interpretation and scope remain for maintainers to confirm.
Ben-Home commentedon Oct 26, 2026
Ben-Home commentedon Oct 26, 2026